配方增删改查服务层和控制器

This commit is contained in:
2025-11-24 13:25:15 +08:00
parent 1200f36d14
commit d7deaa346b
13 changed files with 1411 additions and 1 deletions

View File

@@ -423,6 +423,24 @@ definitions:
required:
- name
type: object
dto.CreateRecipeRequest:
properties:
description:
description: 配方描述
maxLength: 255
type: string
name:
description: 配方名称
maxLength: 100
type: string
recipe_ingredients:
description: 配方原料组成
items:
$ref: '#/definitions/dto.RecipeIngredientDto'
type: array
required:
- name
type: object
dto.CreateUserRequest:
properties:
password:
@@ -735,6 +753,15 @@ definitions:
pagination:
$ref: '#/definitions/dto.PaginationDTO'
type: object
dto.ListRecipeResponse:
properties:
list:
items:
$ref: '#/definitions/dto.RecipeResponse'
type: array
pagination:
$ref: '#/definitions/dto.PaginationDTO'
type: object
dto.ListSensorDataResponse:
properties:
list:
@@ -1379,6 +1406,32 @@ definitions:
$ref: '#/definitions/dto.RawMaterialNutrientDTO'
type: array
type: object
dto.RecipeIngredientDto:
properties:
percentage:
description: 原料在配方中的百分比 (0-1之间)
maximum: 1
minimum: 0
type: number
raw_material_id:
description: 原料ID
type: integer
required:
- raw_material_id
type: object
dto.RecipeResponse:
properties:
description:
type: string
id:
type: integer
name:
type: string
recipe_ingredients:
items:
$ref: '#/definitions/dto.RecipeIngredientDto'
type: array
type: object
dto.ReclassifyPenToNewBatchRequest:
properties:
pen_id:
@@ -2024,6 +2077,24 @@ definitions:
required:
- name
type: object
dto.UpdateRecipeRequest:
properties:
description:
description: 配方描述
maxLength: 255
type: string
name:
description: 配方名称
maxLength: 100
type: string
recipe_ingredients:
description: 配方原料组成
items:
$ref: '#/definitions/dto.RecipeIngredientDto'
type: array
required:
- name
type: object
dto.UserActionLogDTO:
properties:
action_type:
@@ -4386,6 +4457,150 @@ paths:
summary: 全量更新原料的营养成分
tags:
- 饲料管理-原料
/api/v1/feed/recipes:
get:
description: 获取所有配方的列表,支持分页和过滤。
parameters:
- description: 按名称模糊查询
in: query
name: name
type: string
- description: 排序字段,例如 "id DESC"
in: query
name: order_by
type: string
- description: 页码
in: query
name: page
type: integer
- description: 每页数量
in: query
name: page_size
type: integer
produces:
- application/json
responses:
"200":
description: 业务码为200代表成功获取列表
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/dto.ListRecipeResponse'
type: object
security:
- BearerAuth: []
summary: 获取配方列表
tags:
- 饲料管理-配方
post:
consumes:
- application/json
description: 创建一个新的配方,包含其原料组成。
parameters:
- description: 配方信息
in: body
name: recipe
required: true
schema:
$ref: '#/definitions/dto.CreateRecipeRequest'
produces:
- application/json
responses:
"200":
description: 业务码为201代表创建成功
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/dto.RecipeResponse'
type: object
security:
- BearerAuth: []
summary: 创建配方
tags:
- 饲料管理-配方
/api/v1/feed/recipes/{id}:
delete:
description: 根据ID删除配方。
parameters:
- description: 配方ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: 业务码为200代表删除成功
schema:
$ref: '#/definitions/controller.Response'
security:
- BearerAuth: []
summary: 删除配方
tags:
- 饲料管理-配方
get:
description: 根据ID获取单个配方的详细信息。
parameters:
- description: 配方ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: 业务码为200代表成功获取
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/dto.RecipeResponse'
type: object
security:
- BearerAuth: []
summary: 获取配方详情
tags:
- 饲料管理-配方
put:
consumes:
- application/json
description: 根据ID更新配方信息及其原料组成。
parameters:
- description: 配方ID
in: path
name: id
required: true
type: integer
- description: 更新后的配方信息
in: body
name: recipe
required: true
schema:
$ref: '#/definitions/dto.UpdateRecipeRequest'
produces:
- application/json
responses:
"200":
description: 业务码为200代表更新成功
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/dto.RecipeResponse'
type: object
security:
- BearerAuth: []
summary: 更新配方
tags:
- 饲料管理-配方
/api/v1/monitor/device-command-logs:
get:
description: 根据提供的过滤条件,分页获取设备命令日志