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

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

@@ -3021,6 +3021,252 @@ const docTemplate = `{
}
}
},
"/api/v1/feed/recipes": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "获取所有配方的列表,支持分页和过滤。",
"produces": [
"application/json"
],
"tags": [
"饲料管理-配方"
],
"summary": "获取配方列表",
"parameters": [
{
"type": "string",
"description": "按名称模糊查询",
"name": "name",
"in": "query"
},
{
"type": "string",
"description": "排序字段,例如 \"id DESC\"",
"name": "order_by",
"in": "query"
},
{
"type": "integer",
"description": "页码",
"name": "page",
"in": "query"
},
{
"type": "integer",
"description": "每页数量",
"name": "page_size",
"in": "query"
}
],
"responses": {
"200": {
"description": "业务码为200代表成功获取列表",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.ListRecipeResponse"
}
}
}
]
}
}
}
},
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "创建一个新的配方,包含其原料组成。",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"饲料管理-配方"
],
"summary": "创建配方",
"parameters": [
{
"description": "配方信息",
"name": "recipe",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.CreateRecipeRequest"
}
}
],
"responses": {
"200": {
"description": "业务码为201代表创建成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.RecipeResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/feed/recipes/{id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据ID获取单个配方的详细信息。",
"produces": [
"application/json"
],
"tags": [
"饲料管理-配方"
],
"summary": "获取配方详情",
"parameters": [
{
"type": "integer",
"description": "配方ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "业务码为200代表成功获取",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.RecipeResponse"
}
}
}
]
}
}
}
},
"put": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据ID更新配方信息及其原料组成。",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"饲料管理-配方"
],
"summary": "更新配方",
"parameters": [
{
"type": "integer",
"description": "配方ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "更新后的配方信息",
"name": "recipe",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.UpdateRecipeRequest"
}
}
],
"responses": {
"200": {
"description": "业务码为200代表更新成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.RecipeResponse"
}
}
}
]
}
}
}
},
"delete": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据ID删除配方。",
"produces": [
"application/json"
],
"tags": [
"饲料管理-配方"
],
"summary": "删除配方",
"parameters": [
{
"type": "integer",
"description": "配方ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "业务码为200代表删除成功",
"schema": {
"$ref": "#/definitions/controller.Response"
}
}
}
}
},
"/api/v1/monitor/device-command-logs": {
"get": {
"security": [
@@ -6761,6 +7007,31 @@ const docTemplate = `{
}
}
},
"dto.CreateRecipeRequest": {
"type": "object",
"required": [
"name"
],
"properties": {
"description": {
"description": "配方描述",
"type": "string",
"maxLength": 255
},
"name": {
"description": "配方名称",
"type": "string",
"maxLength": 100
},
"recipe_ingredients": {
"description": "配方原料组成",
"type": "array",
"items": {
"$ref": "#/definitions/dto.RecipeIngredientDto"
}
}
}
},
"dto.CreateUserRequest": {
"type": "object",
"required": [
@@ -7241,6 +7512,20 @@ const docTemplate = `{
}
}
},
"dto.ListRecipeResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.RecipeResponse"
}
},
"pagination": {
"$ref": "#/definitions/dto.PaginationDTO"
}
}
},
"dto.ListSensorDataResponse": {
"type": "object",
"properties": {
@@ -8214,6 +8499,44 @@ const docTemplate = `{
}
}
},
"dto.RecipeIngredientDto": {
"type": "object",
"required": [
"raw_material_id"
],
"properties": {
"percentage": {
"description": "原料在配方中的百分比 (0-1之间)",
"type": "number",
"maximum": 1,
"minimum": 0
},
"raw_material_id": {
"description": "原料ID",
"type": "integer"
}
}
},
"dto.RecipeResponse": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"recipe_ingredients": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.RecipeIngredientDto"
}
}
}
},
"dto.ReclassifyPenToNewBatchRequest": {
"type": "object",
"required": [
@@ -9150,6 +9473,31 @@ const docTemplate = `{
}
}
},
"dto.UpdateRecipeRequest": {
"type": "object",
"required": [
"name"
],
"properties": {
"description": {
"description": "配方描述",
"type": "string",
"maxLength": 255
},
"name": {
"description": "配方名称",
"type": "string",
"maxLength": 100
},
"recipe_ingredients": {
"description": "配方原料组成",
"type": "array",
"items": {
"$ref": "#/definitions/dto.RecipeIngredientDto"
}
}
}
},
"dto.UserActionLogDTO": {
"type": "object",
"properties": {

View File

@@ -3013,6 +3013,252 @@
}
}
},
"/api/v1/feed/recipes": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "获取所有配方的列表,支持分页和过滤。",
"produces": [
"application/json"
],
"tags": [
"饲料管理-配方"
],
"summary": "获取配方列表",
"parameters": [
{
"type": "string",
"description": "按名称模糊查询",
"name": "name",
"in": "query"
},
{
"type": "string",
"description": "排序字段,例如 \"id DESC\"",
"name": "order_by",
"in": "query"
},
{
"type": "integer",
"description": "页码",
"name": "page",
"in": "query"
},
{
"type": "integer",
"description": "每页数量",
"name": "page_size",
"in": "query"
}
],
"responses": {
"200": {
"description": "业务码为200代表成功获取列表",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.ListRecipeResponse"
}
}
}
]
}
}
}
},
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "创建一个新的配方,包含其原料组成。",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"饲料管理-配方"
],
"summary": "创建配方",
"parameters": [
{
"description": "配方信息",
"name": "recipe",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.CreateRecipeRequest"
}
}
],
"responses": {
"200": {
"description": "业务码为201代表创建成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.RecipeResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/feed/recipes/{id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据ID获取单个配方的详细信息。",
"produces": [
"application/json"
],
"tags": [
"饲料管理-配方"
],
"summary": "获取配方详情",
"parameters": [
{
"type": "integer",
"description": "配方ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "业务码为200代表成功获取",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.RecipeResponse"
}
}
}
]
}
}
}
},
"put": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据ID更新配方信息及其原料组成。",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"饲料管理-配方"
],
"summary": "更新配方",
"parameters": [
{
"type": "integer",
"description": "配方ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "更新后的配方信息",
"name": "recipe",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.UpdateRecipeRequest"
}
}
],
"responses": {
"200": {
"description": "业务码为200代表更新成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.RecipeResponse"
}
}
}
]
}
}
}
},
"delete": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据ID删除配方。",
"produces": [
"application/json"
],
"tags": [
"饲料管理-配方"
],
"summary": "删除配方",
"parameters": [
{
"type": "integer",
"description": "配方ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "业务码为200代表删除成功",
"schema": {
"$ref": "#/definitions/controller.Response"
}
}
}
}
},
"/api/v1/monitor/device-command-logs": {
"get": {
"security": [
@@ -6753,6 +6999,31 @@
}
}
},
"dto.CreateRecipeRequest": {
"type": "object",
"required": [
"name"
],
"properties": {
"description": {
"description": "配方描述",
"type": "string",
"maxLength": 255
},
"name": {
"description": "配方名称",
"type": "string",
"maxLength": 100
},
"recipe_ingredients": {
"description": "配方原料组成",
"type": "array",
"items": {
"$ref": "#/definitions/dto.RecipeIngredientDto"
}
}
}
},
"dto.CreateUserRequest": {
"type": "object",
"required": [
@@ -7233,6 +7504,20 @@
}
}
},
"dto.ListRecipeResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.RecipeResponse"
}
},
"pagination": {
"$ref": "#/definitions/dto.PaginationDTO"
}
}
},
"dto.ListSensorDataResponse": {
"type": "object",
"properties": {
@@ -8206,6 +8491,44 @@
}
}
},
"dto.RecipeIngredientDto": {
"type": "object",
"required": [
"raw_material_id"
],
"properties": {
"percentage": {
"description": "原料在配方中的百分比 (0-1之间)",
"type": "number",
"maximum": 1,
"minimum": 0
},
"raw_material_id": {
"description": "原料ID",
"type": "integer"
}
}
},
"dto.RecipeResponse": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"recipe_ingredients": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.RecipeIngredientDto"
}
}
}
},
"dto.ReclassifyPenToNewBatchRequest": {
"type": "object",
"required": [
@@ -9142,6 +9465,31 @@
}
}
},
"dto.UpdateRecipeRequest": {
"type": "object",
"required": [
"name"
],
"properties": {
"description": {
"description": "配方描述",
"type": "string",
"maxLength": 255
},
"name": {
"description": "配方名称",
"type": "string",
"maxLength": 100
},
"recipe_ingredients": {
"description": "配方原料组成",
"type": "array",
"items": {
"$ref": "#/definitions/dto.RecipeIngredientDto"
}
}
}
},
"dto.UserActionLogDTO": {
"type": "object",
"properties": {

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: 根据提供的过滤条件,分页获取设备命令日志