Files
pig-farm-controller/docs/swagger.yaml

711 lines
17 KiB
YAML
Raw Normal View History

2025-09-12 16:58:39 +08:00
definitions:
controller.Response:
properties:
code:
description: 业务状态码
type: integer
data:
description: 业务数据
message:
description: 提示信息
type: string
type: object
2025-09-12 17:43:42 +08:00
device.CreateDeviceRequest:
2025-09-19 23:51:13 +08:00
properties:
location:
type: string
name:
type: string
parent_id:
type: integer
properties:
2025-09-20 17:11:04 +08:00
additionalProperties: true
type: object
2025-09-19 23:51:13 +08:00
sub_type:
$ref: '#/definitions/models.DeviceSubType'
type:
$ref: '#/definitions/models.DeviceType'
required:
- name
- type
2025-09-12 17:43:42 +08:00
type: object
2025-09-19 13:18:05 +08:00
device.UpdateDeviceRequest:
2025-09-12 17:43:42 +08:00
properties:
location:
type: string
name:
type: string
parent_id:
type: integer
properties:
2025-09-20 17:11:04 +08:00
additionalProperties: true
type: object
2025-09-12 17:43:42 +08:00
sub_type:
$ref: '#/definitions/models.DeviceSubType'
type:
$ref: '#/definitions/models.DeviceType'
2025-09-19 13:18:05 +08:00
required:
- name
- type
2025-09-12 17:43:42 +08:00
type: object
2025-09-19 13:18:05 +08:00
git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse:
2025-09-12 17:43:42 +08:00
properties:
2025-09-19 13:18:05 +08:00
created_at:
type: string
id:
type: integer
2025-09-12 17:43:42 +08:00
location:
type: string
name:
type: string
parent_id:
type: integer
properties:
2025-09-20 17:11:04 +08:00
additionalProperties: true
type: object
2025-09-12 17:43:42 +08:00
sub_type:
$ref: '#/definitions/models.DeviceSubType'
type:
$ref: '#/definitions/models.DeviceType'
2025-09-19 13:18:05 +08:00
updated_at:
type: string
2025-09-12 17:43:42 +08:00
type: object
models.DeviceSubType:
enum:
- ""
- temperature
- humidity
- ammonia
- feed_valve
- fan
- water_curtain
type: string
x-enum-varnames:
- SubTypeNone
- SubTypeSensorTemp
- SubTypeSensorHumidity
- SubTypeSensorAmmonia
- SubTypeValveFeed
- SubTypeFan
- SubTypeWaterCurtain
models.DeviceType:
enum:
- area_controller
- device
type: string
x-enum-varnames:
- DeviceTypeAreaController
- DeviceTypeDevice
2025-09-14 21:30:20 +08:00
models.PlanContentType:
enum:
- sub_plans
- tasks
type: string
x-enum-comments:
PlanContentTypeSubPlans: 计划包含子计划
PlanContentTypeTasks: 计划包含任务
x-enum-descriptions:
- 计划包含子计划
- 计划包含任务
x-enum-varnames:
- PlanContentTypeSubPlans
- PlanContentTypeTasks
models.PlanExecutionType:
enum:
- automatic
- manual
type: string
x-enum-comments:
PlanExecutionTypeAutomatic: 自动执行 (包含定时和循环)
PlanExecutionTypeManual: 手动执行
x-enum-descriptions:
- 自动执行 (包含定时和循环)
- 手动执行
x-enum-varnames:
- PlanExecutionTypeAutomatic
- PlanExecutionTypeManual
2025-09-19 13:18:05 +08:00
models.PlanStatus:
enum:
- 0
- 1
- 2
2025-09-23 18:11:21 +08:00
- 3
2025-09-19 13:18:05 +08:00
format: int32
type: integer
x-enum-comments:
PlanStatusDisabled: 禁用计划
PlanStatusEnabled: 启用计划
2025-09-23 18:11:21 +08:00
PlanStatusFailed: 执行失败
2025-09-19 13:18:05 +08:00
PlanStatusStopeed: 执行完毕
x-enum-descriptions:
- 禁用计划
2025-09-23 18:11:21 +08:00
- 启用计划
2025-09-19 13:18:05 +08:00
- 执行完毕
2025-09-23 18:11:21 +08:00
- 执行失败
2025-09-19 13:18:05 +08:00
x-enum-varnames:
- PlanStatusDisabled
2025-09-23 18:11:21 +08:00
- PlanStatusEnabled
2025-09-19 13:18:05 +08:00
- PlanStatusStopeed
2025-09-23 18:11:21 +08:00
- PlanStatusFailed
2025-09-14 21:30:20 +08:00
models.TaskType:
enum:
2025-09-19 13:18:05 +08:00
- plan_analysis
2025-09-14 21:30:20 +08:00
- waiting
type: string
x-enum-comments:
2025-09-19 13:18:05 +08:00
TaskPlanAnalysis: 解析Plan的Task列表并添加到待执行队列的特殊任务
2025-09-14 21:30:20 +08:00
TaskTypeWaiting: 等待任务
x-enum-descriptions:
2025-09-19 13:18:05 +08:00
- 解析Plan的Task列表并添加到待执行队列的特殊任务
2025-09-14 21:30:20 +08:00
- 等待任务
x-enum-varnames:
2025-09-19 13:18:05 +08:00
- TaskPlanAnalysis
2025-09-14 21:30:20 +08:00
- TaskTypeWaiting
2025-09-13 14:09:22 +08:00
plan.CreatePlanRequest:
properties:
2025-09-14 21:30:20 +08:00
cron_expression:
example: 0 0 6 * * *
type: string
2025-09-13 14:09:22 +08:00
description:
example: 根据温度自动调节风扇和加热器
type: string
2025-09-19 15:55:56 +08:00
execute_num:
example: 10
type: integer
2025-09-14 21:30:20 +08:00
execution_type:
allOf:
- $ref: '#/definitions/models.PlanExecutionType'
example: automatic
2025-09-13 14:09:22 +08:00
name:
example: 猪舍温度控制计划
type: string
2025-09-14 21:30:20 +08:00
sub_plan_ids:
items:
type: integer
type: array
tasks:
items:
$ref: '#/definitions/plan.TaskRequest'
type: array
2025-09-13 14:09:22 +08:00
required:
2025-09-14 21:30:20 +08:00
- execution_type
2025-09-13 14:09:22 +08:00
- name
type: object
plan.ListPlansResponse:
properties:
plans:
items:
$ref: '#/definitions/plan.PlanResponse'
type: array
total:
example: 100
type: integer
type: object
plan.PlanResponse:
properties:
2025-09-14 21:30:20 +08:00
content_type:
allOf:
- $ref: '#/definitions/models.PlanContentType'
example: tasks
cron_expression:
example: 0 0 6 * * *
type: string
2025-09-13 14:09:22 +08:00
description:
example: 根据温度自动调节风扇和加热器
type: string
2025-09-19 13:18:05 +08:00
execute_count:
example: 0
type: integer
execute_num:
example: 10
type: integer
2025-09-14 21:30:20 +08:00
execution_type:
allOf:
- $ref: '#/definitions/models.PlanExecutionType'
example: automatic
2025-09-13 14:09:22 +08:00
id:
example: 1
type: integer
name:
example: 猪舍温度控制计划
type: string
2025-09-19 13:18:05 +08:00
status:
allOf:
- $ref: '#/definitions/models.PlanStatus'
example: 0
2025-09-14 21:30:20 +08:00
sub_plans:
items:
$ref: '#/definitions/plan.SubPlanResponse'
type: array
tasks:
items:
$ref: '#/definitions/plan.TaskResponse'
type: array
type: object
plan.SubPlanResponse:
properties:
child_plan:
$ref: '#/definitions/plan.PlanResponse'
child_plan_id:
example: 2
type: integer
execution_order:
example: 1
type: integer
id:
example: 1
type: integer
parent_plan_id:
example: 1
type: integer
type: object
plan.TaskRequest:
properties:
description:
example: 打开1号风扇
type: string
execution_order:
example: 1
type: integer
name:
example: 打开风扇
type: string
parameters:
2025-09-20 17:11:04 +08:00
additionalProperties: true
type: object
2025-09-14 21:30:20 +08:00
type:
allOf:
- $ref: '#/definitions/models.TaskType'
example: waiting
type: object
plan.TaskResponse:
properties:
description:
example: 打开1号风扇
type: string
execution_order:
example: 1
type: integer
id:
example: 1
type: integer
name:
example: 打开风扇
type: string
parameters:
2025-09-20 17:11:04 +08:00
additionalProperties: true
type: object
2025-09-14 21:30:20 +08:00
plan_id:
example: 1
type: integer
type:
allOf:
- $ref: '#/definitions/models.TaskType'
example: waiting
2025-09-13 14:09:22 +08:00
type: object
plan.UpdatePlanRequest:
properties:
2025-09-14 21:30:20 +08:00
cron_expression:
example: 0 0 6 * * *
type: string
2025-09-13 14:09:22 +08:00
description:
example: 更新后的描述
type: string
2025-09-19 15:55:56 +08:00
execute_num:
example: 10
type: integer
2025-09-14 21:30:20 +08:00
execution_type:
allOf:
- $ref: '#/definitions/models.PlanExecutionType'
example: automatic
2025-09-13 14:09:22 +08:00
name:
example: 猪舍温度控制计划V2
type: string
2025-09-14 21:30:20 +08:00
sub_plan_ids:
items:
type: integer
type: array
tasks:
items:
$ref: '#/definitions/plan.TaskRequest'
type: array
2025-09-13 14:09:22 +08:00
type: object
2025-09-12 16:58:39 +08:00
user.CreateUserRequest:
properties:
password:
example: password123
minLength: 6
type: string
username:
example: newuser
type: string
required:
- password
- username
type: object
user.CreateUserResponse:
properties:
id:
example: 1
type: integer
username:
example: newuser
type: string
type: object
user.LoginRequest:
properties:
password:
example: password123
type: string
username:
example: testuser
type: string
required:
- password
- username
type: object
user.LoginResponse:
properties:
id:
example: 1
type: integer
token:
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
type: string
username:
example: testuser
type: string
type: object
info:
2025-09-12 20:32:29 +08:00
contact: {}
2025-09-12 16:58:39 +08:00
paths:
2025-09-19 15:55:56 +08:00
/api/v1/devices:
2025-09-12 17:43:42 +08:00
get:
description: 获取系统中所有设备的列表
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: OK
2025-09-12 17:43:42 +08:00
schema:
2025-09-19 23:51:13 +08:00
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
items:
$ref: '#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse'
type: array
type: object
2025-09-12 17:43:42 +08:00
summary: 获取设备列表
tags:
- 设备管理
2025-09-12 16:58:39 +08:00
post:
consumes:
- application/json
2025-09-12 17:43:42 +08:00
description: 根据提供的信息创建一个新设备
2025-09-12 16:58:39 +08:00
parameters:
2025-09-12 17:43:42 +08:00
- description: 设备信息
2025-09-12 16:58:39 +08:00
in: body
2025-09-12 17:43:42 +08:00
name: device
2025-09-12 16:58:39 +08:00
required: true
schema:
2025-09-12 17:43:42 +08:00
$ref: '#/definitions/device.CreateDeviceRequest'
2025-09-12 16:58:39 +08:00
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: OK
2025-09-12 16:58:39 +08:00
schema:
2025-09-19 23:51:13 +08:00
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse'
type: object
2025-09-12 17:43:42 +08:00
summary: 创建新设备
tags:
- 设备管理
2025-09-19 15:55:56 +08:00
/api/v1/devices/{id}:
2025-09-12 17:43:42 +08:00
delete:
description: 根据设备ID删除一个设备软删除
parameters:
- description: 设备ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: OK
2025-09-12 16:58:39 +08:00
schema:
$ref: '#/definitions/controller.Response'
2025-09-12 17:43:42 +08:00
summary: 删除设备
tags:
- 设备管理
get:
description: 根据设备ID获取单个设备的详细信息
parameters:
- description: 设备ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: OK
2025-09-12 16:58:39 +08:00
schema:
2025-09-19 23:51:13 +08:00
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse'
type: object
2025-09-12 17:43:42 +08:00
summary: 获取设备信息
tags:
- 设备管理
put:
consumes:
- application/json
description: 根据设备ID更新一个已存在的设备信息
parameters:
- description: 设备ID
in: path
name: id
required: true
type: string
- description: 要更新的设备信息
in: body
name: device
required: true
schema:
$ref: '#/definitions/device.UpdateDeviceRequest'
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: OK
2025-09-12 17:43:42 +08:00
schema:
2025-09-19 23:51:13 +08:00
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse'
type: object
2025-09-12 17:43:42 +08:00
summary: 更新设备信息
tags:
- 设备管理
2025-09-19 15:55:56 +08:00
/api/v1/plans:
2025-09-13 14:09:22 +08:00
get:
description: 获取所有计划的列表
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: 业务码为200代表成功获取列表
2025-09-13 14:09:22 +08:00
schema:
2025-09-19 23:51:13 +08:00
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/plan.ListPlansResponse'
type: object
2025-09-13 14:09:22 +08:00
summary: 获取计划列表
tags:
- 计划管理
post:
consumes:
- application/json
description: 创建一个新的计划,包括其基本信息和所有关联的子计划/任务。
parameters:
- description: 计划信息
in: body
name: plan
required: true
schema:
$ref: '#/definitions/plan.CreatePlanRequest'
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: 业务码为201代表创建成功
2025-09-13 14:09:22 +08:00
schema:
2025-09-19 23:51:13 +08:00
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/plan.PlanResponse'
type: object
2025-09-13 14:09:22 +08:00
summary: 创建计划
tags:
- 计划管理
2025-09-19 15:55:56 +08:00
/api/v1/plans/{id}:
2025-09-13 14:09:22 +08:00
delete:
description: 根据计划ID删除计划。
parameters:
- description: 计划ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: 业务码为200代表删除成功
2025-09-13 14:09:22 +08:00
schema:
$ref: '#/definitions/controller.Response'
summary: 删除计划
tags:
- 计划管理
get:
description: 根据计划ID获取单个计划的详细信息。
parameters:
- description: 计划ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: 业务码为200代表成功获取
2025-09-13 14:09:22 +08:00
schema:
2025-09-19 23:51:13 +08:00
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/plan.PlanResponse'
type: object
2025-09-13 14:09:22 +08:00
summary: 获取计划详情
tags:
- 计划管理
put:
consumes:
- application/json
description: 根据计划ID更新计划的详细信息。
parameters:
- description: 计划ID
in: path
name: id
required: true
type: integer
- description: 更新后的计划信息
in: body
name: plan
required: true
schema:
$ref: '#/definitions/plan.UpdatePlanRequest'
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: 业务码为200代表更新成功
2025-09-13 14:09:22 +08:00
schema:
2025-09-19 23:51:13 +08:00
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/plan.PlanResponse'
type: object
2025-09-13 14:09:22 +08:00
summary: 更新计划
tags:
- 计划管理
2025-09-19 15:55:56 +08:00
/api/v1/plans/{id}/start:
2025-09-13 14:09:22 +08:00
post:
description: 根据计划ID启动一个计划的执行。
parameters:
- description: 计划ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: 业务码为200代表成功启动计划
2025-09-13 14:09:22 +08:00
schema:
$ref: '#/definitions/controller.Response'
summary: 启动计划
tags:
- 计划管理
2025-09-19 15:55:56 +08:00
/api/v1/plans/{id}/stop:
2025-09-13 14:09:22 +08:00
post:
description: 根据计划ID停止一个正在执行的计划。
parameters:
- description: 计划ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: 业务码为200代表成功停止计划
2025-09-13 14:09:22 +08:00
schema:
$ref: '#/definitions/controller.Response'
summary: 停止计划
tags:
- 计划管理
2025-09-19 15:55:56 +08:00
/api/v1/users:
2025-09-12 17:43:42 +08:00
post:
consumes:
- application/json
description: 根据用户名和密码创建一个新的系统用户。
parameters:
- description: 用户信息
in: body
name: user
required: true
schema:
$ref: '#/definitions/user.CreateUserRequest'
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: 业务码为201代表创建成功
2025-09-12 16:58:39 +08:00
schema:
2025-09-19 23:51:13 +08:00
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/user.CreateUserResponse'
type: object
2025-09-12 16:58:39 +08:00
summary: 创建新用户
tags:
- 用户管理
2025-09-19 15:55:56 +08:00
/api/v1/users/login:
2025-09-12 16:58:39 +08:00
post:
consumes:
- application/json
description: 用户使用用户名和密码登录,成功后返回 JWT 令牌。
parameters:
- description: 登录凭证
in: body
name: credentials
required: true
schema:
$ref: '#/definitions/user.LoginRequest'
produces:
- application/json
responses:
"200":
2025-09-19 23:51:13 +08:00
description: 业务码为200代表登录成功
2025-09-12 16:58:39 +08:00
schema:
2025-09-19 23:51:13 +08:00
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/user.LoginResponse'
type: object
2025-09-12 16:58:39 +08:00
summary: 用户登录
tags:
- 用户管理
swagger: "2.0"