Files
pig-farm-controller/docs/swagger.yaml
2025-09-12 17:43:42 +08:00

284 lines
6.8 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

basePath: /api/v1
definitions:
controller.Properties:
type: object
controller.Response:
properties:
code:
description: 业务状态码
type: integer
data:
description: 业务数据
message:
description: 提示信息
type: string
type: object
device.CreateDeviceRequest:
type: object
device.DeviceResponse:
properties:
created_at:
type: string
id:
type: integer
location:
type: string
name:
type: string
parent_id:
type: integer
properties:
$ref: '#/definitions/controller.Properties'
sub_type:
$ref: '#/definitions/models.DeviceSubType'
type:
$ref: '#/definitions/models.DeviceType'
updated_at:
type: string
type: object
device.UpdateDeviceRequest:
properties:
location:
type: string
name:
type: string
parent_id:
type: integer
properties:
$ref: '#/definitions/controller.Properties'
sub_type:
$ref: '#/definitions/models.DeviceSubType'
type:
$ref: '#/definitions/models.DeviceType'
required:
- name
- type
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
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
host: localhost:8086
info:
contact:
email: divano@example.com
name: Divano
url: http://www.example.com
description: 这是一个用于管理猪场设备的后端服务。
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
title: 猪场管理系统 API
version: "1.0"
paths:
/devices:
get:
description: 获取系统中所有设备的列表
produces:
- application/json
responses:
"200":
description: 业务失败,具体错误码和信息见响应体
schema:
$ref: '#/definitions/controller.Response'
summary: 获取设备列表
tags:
- 设备管理
post:
consumes:
- application/json
description: 根据提供的信息创建一个新设备
parameters:
- description: 设备信息
in: body
name: device
required: true
schema:
$ref: '#/definitions/device.CreateDeviceRequest'
produces:
- application/json
responses:
"200":
description: 业务失败,具体错误码和信息见响应体
schema:
$ref: '#/definitions/controller.Response'
summary: 创建新设备
tags:
- 设备管理
/devices/{id}:
delete:
description: 根据设备ID删除一个设备软删除
parameters:
- description: 设备ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: 业务失败,具体错误码和信息见响应体
schema:
$ref: '#/definitions/controller.Response'
summary: 删除设备
tags:
- 设备管理
get:
description: 根据设备ID获取单个设备的详细信息
parameters:
- description: 设备ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: 业务失败,具体错误码和信息见响应体
schema:
$ref: '#/definitions/controller.Response'
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":
description: 业务失败,具体错误码和信息见响应体
schema:
$ref: '#/definitions/controller.Response'
summary: 更新设备信息
tags:
- 设备管理
/users:
post:
consumes:
- application/json
description: 根据用户名和密码创建一个新的系统用户。
parameters:
- description: 用户信息
in: body
name: user
required: true
schema:
$ref: '#/definitions/user.CreateUserRequest'
produces:
- application/json
responses:
"200":
description: 业务失败具体错误码和信息见响应体例如400, 409, 500
schema:
$ref: '#/definitions/controller.Response'
summary: 创建新用户
tags:
- 用户管理
/users/login:
post:
consumes:
- application/json
description: 用户使用用户名和密码登录,成功后返回 JWT 令牌。
parameters:
- description: 登录凭证
in: body
name: credentials
required: true
schema:
$ref: '#/definitions/user.LoginRequest'
produces:
- application/json
responses:
"200":
description: 业务失败具体错误码和信息见响应体例如400, 401, 500
schema:
$ref: '#/definitions/controller.Response'
summary: 用户登录
tags:
- 用户管理
swagger: "2.0"