fix: align admin behavior and Kratos integrations
This commit is contained in:
+10
-10
@@ -29,14 +29,14 @@ func (s *MediaService) Upload(ctx context.Context, userID uint, name, mime strin
|
||||
return mediaDTO(v), nil
|
||||
}
|
||||
func (s *MediaService) Media(ctx context.Context, id uint) (map[string]any, error) {
|
||||
v, err := s.uc.Repo().FindMedia(ctx, id)
|
||||
v, err := s.uc.FindMedia(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mediaDTO(v), nil
|
||||
}
|
||||
func (s *MediaService) MediaList(ctx context.Context, page, size int, keyword string, categoryID int, tag string, userID uint) ([]map[string]any, int64, error) {
|
||||
items, total, err := s.uc.Repo().ListMedia(ctx, page, size, keyword, categoryID, tag, userID)
|
||||
func (s *MediaService) MediaList(ctx context.Context, filter biz.MediaFilter) ([]map[string]any, int64, error) {
|
||||
items, total, err := s.uc.ListMedia(ctx, filter)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
@@ -48,15 +48,15 @@ func (s *MediaService) MediaList(ctx context.Context, page, size int, keyword st
|
||||
}
|
||||
func (s *MediaService) Delete(ctx context.Context, id uint) error { return s.uc.Delete(ctx, id) }
|
||||
func (s *MediaService) Rename(ctx context.Context, id uint, name string) error {
|
||||
return s.uc.Repo().UpdateMediaName(ctx, id, name)
|
||||
return s.uc.UpdateMediaName(ctx, id, name)
|
||||
}
|
||||
func (s *MediaService) ImportURLs(ctx context.Context, items []*biz.MediaFile) error {
|
||||
return s.uc.Repo().CreateMediaBatch(ctx, items)
|
||||
return s.uc.CreateMediaBatch(ctx, items)
|
||||
}
|
||||
func (s *MediaService) ImportURLRequests(ctx context.Context, userID uint, values []dto.ImportMediaRequest) error {
|
||||
func (s *MediaService) ImportURLRequests(ctx context.Context, values []dto.ImportMediaRequest) error {
|
||||
items := make([]*biz.MediaFile, 0, len(values))
|
||||
for _, value := range values {
|
||||
items = append(items, &biz.MediaFile{Name: value.Name, CategoryID: value.ClassID, URL: value.URL, Tag: value.Tag, Key: value.Key, Size: value.Size, Mime: value.Mime, MD5: value.MD5, UserID: userID})
|
||||
items = append(items, &biz.MediaFile{Name: value.Name, CategoryID: value.ClassID, URL: value.URL, Tag: value.Tag, Key: value.Key, Size: value.Size, Mime: value.Mime, MD5: value.MD5, UserID: value.UserID})
|
||||
}
|
||||
return s.ImportURLs(ctx, items)
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func (s *MediaService) Storage(ctx context.Context, prefix, cursor string, limit
|
||||
return out, next, more, nil
|
||||
}
|
||||
func (s *MediaService) Categories(ctx context.Context) ([]map[string]any, error) {
|
||||
items, err := s.uc.Repo().ListCategories(ctx)
|
||||
items, err := s.uc.ListCategories(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -83,11 +83,11 @@ func (s *MediaService) Categories(ctx context.Context) ([]map[string]any, error)
|
||||
return out, nil
|
||||
}
|
||||
func (s *MediaService) SaveCategory(ctx context.Context, v *biz.AttachmentCategory) error {
|
||||
return s.uc.Repo().SaveCategory(ctx, v)
|
||||
return s.uc.SaveCategory(ctx, v)
|
||||
}
|
||||
func (s *MediaService) SaveCategoryRequest(ctx context.Context, value *dto.CategoryRequest) error {
|
||||
return s.SaveCategory(ctx, &biz.AttachmentCategory{ID: value.ID, Name: value.Name, ParentID: value.PID})
|
||||
}
|
||||
func (s *MediaService) DeleteCategory(ctx context.Context, id uint) error {
|
||||
return s.uc.Repo().DeleteCategory(ctx, id)
|
||||
return s.uc.DeleteCategory(ctx, id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user