拓展接口响应
This commit is contained in:
@@ -32,14 +32,14 @@ type Service interface {
|
||||
UpdateNutrient(ctx context.Context, id uint32, name, description string) (*models.Nutrient, error)
|
||||
DeleteNutrient(ctx context.Context, id uint32) error
|
||||
GetNutrient(ctx context.Context, id uint32) (*models.Nutrient, error)
|
||||
ListNutrients(ctx context.Context, page, pageSize int) ([]models.Nutrient, int64, error)
|
||||
ListNutrients(ctx context.Context, opts repository.NutrientListOptions, page, pageSize int) ([]models.Nutrient, int64, error)
|
||||
|
||||
// 原料相关接口
|
||||
CreateRawMaterial(ctx context.Context, name, description string) (*models.RawMaterial, error)
|
||||
UpdateRawMaterial(ctx context.Context, id uint32, name, description string) (*models.RawMaterial, error)
|
||||
DeleteRawMaterial(ctx context.Context, id uint32) error
|
||||
GetRawMaterial(ctx context.Context, id uint32) (*models.RawMaterial, error)
|
||||
ListRawMaterials(ctx context.Context, page, pageSize int) ([]models.RawMaterial, int64, error)
|
||||
ListRawMaterials(ctx context.Context, opts repository.RawMaterialListOptions, page, pageSize int) ([]models.RawMaterial, int64, error)
|
||||
|
||||
// 猪品种相关接口
|
||||
CreatePigBreed(ctx context.Context, breed *models.PigBreed) error
|
||||
@@ -175,10 +175,10 @@ func (s *recipeServiceImpl) GetNutrient(ctx context.Context, id uint32) (*models
|
||||
}
|
||||
|
||||
// ListNutrients 实现了列出营养种类的逻辑
|
||||
func (s *recipeServiceImpl) ListNutrients(ctx context.Context, page, pageSize int) ([]models.Nutrient, int64, error) {
|
||||
func (s *recipeServiceImpl) ListNutrients(ctx context.Context, opts repository.NutrientListOptions, page, pageSize int) ([]models.Nutrient, int64, error) {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "ListNutrients")
|
||||
|
||||
nutrients, total, err := s.nutrientRepo.ListNutrients(serviceCtx, page, pageSize)
|
||||
nutrients, total, err := s.nutrientRepo.ListNutrients(serviceCtx, opts, page, pageSize)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("获取营养种类列表失败: %w", err)
|
||||
}
|
||||
@@ -279,10 +279,10 @@ func (s *recipeServiceImpl) GetRawMaterial(ctx context.Context, id uint32) (*mod
|
||||
}
|
||||
|
||||
// ListRawMaterials 实现了列出原料的逻辑
|
||||
func (s *recipeServiceImpl) ListRawMaterials(ctx context.Context, page, pageSize int) ([]models.RawMaterial, int64, error) {
|
||||
func (s *recipeServiceImpl) ListRawMaterials(ctx context.Context, opts repository.RawMaterialListOptions, page, pageSize int) ([]models.RawMaterial, int64, error) {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "ListRawMaterials")
|
||||
|
||||
rawMaterials, total, err := s.rawMaterialRepo.ListRawMaterials(serviceCtx, page, pageSize)
|
||||
rawMaterials, total, err := s.rawMaterialRepo.ListRawMaterials(serviceCtx, opts, page, pageSize)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("获取原料列表失败: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user