优化结构
This commit is contained in:
@@ -60,6 +60,9 @@ func (r *mediaRepo) CreateMedia(ctx context.Context, v *system.MediaFile) error
|
||||
func (r *mediaRepo) FindMedia(ctx context.Context, id uint) (*system.MediaFile, error) {
|
||||
var po mediaPO
|
||||
if err := r.data.DB().WithContext(ctx).First(&po, id).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, system.ErrMediaNotFound
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return mediaFromPO(po), nil
|
||||
|
||||
Reference in New Issue
Block a user