Adapt to old_id
This commit is contained in:
@@ -66,6 +66,19 @@ func (r *GormProductRepository) FindByCode(ctx context.Context, code string) (*e
|
||||
return &entity, nil
|
||||
}
|
||||
|
||||
// FindByOldID 根据旧ID查找产品
|
||||
func (r *GormProductRepository) FindByOldID(ctx context.Context, oldID string) (*entities.Product, error) {
|
||||
var entity entities.Product
|
||||
err := r.GetDB(ctx).Where("old_id = ?", oldID).First(&entity).Error
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, gorm.ErrRecordNotFound
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return &entity, nil
|
||||
}
|
||||
|
||||
// FindByCategoryID 根据分类ID查找产品
|
||||
func (r *GormProductRepository) FindByCategoryID(ctx context.Context, categoryID string) ([]*entities.Product, error) {
|
||||
var productEntities []entities.Product
|
||||
|
||||
Reference in New Issue
Block a user