添加区域主控相关路由

This commit is contained in:
2025-09-30 15:25:07 +08:00
parent 5d6fd315e3
commit 5022a2be1f
7 changed files with 1694 additions and 321 deletions

View File

@@ -15,6 +15,204 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/v1/area-controllers": {
"get": {
"description": "获取系统中所有区域主控的列表",
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "获取所有区域主控列表",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/device.AreaControllerResponse"
}
}
}
}
]
}
}
}
},
"post": {
"description": "根据提供的信息创建一个新区域主控",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "创建新区域主控",
"parameters": [
{
"description": "区域主控信息",
"name": "areaController",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/device.CreateAreaControllerRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/device.AreaControllerResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/area-controllers/{id}": {
"get": {
"description": "根据ID获取单个区域主控的详细信息",
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "获取区域主控信息",
"parameters": [
{
"type": "string",
"description": "区域主控ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/device.AreaControllerResponse"
}
}
}
]
}
}
}
},
"put": {
"description": "根据ID更新一个已存在的区域主控信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "更新区域主控信息",
"parameters": [
{
"type": "string",
"description": "区域主控ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "要更新的区域主控信息",
"name": "areaController",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/device.UpdateAreaControllerRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/device.AreaControllerResponse"
}
}
}
]
}
}
}
},
"delete": {
"description": "根据ID删除一个区域主控软删除",
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "删除区域主控",
"parameters": [
{
"type": "string",
"description": "区域主控ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
}
}
}
}
},
"/api/v1/devices": {
"get": {
"description": "获取系统中所有设备的列表",
@@ -381,7 +579,7 @@ const docTemplate = `{
}
},
"delete": {
"description": "根据计划ID删除计划。",
"description": "根据计划ID删除计划。(软删除)",
"produces": [
"application/json"
],
@@ -514,7 +712,7 @@ const docTemplate = `{
},
"/api/v1/users/login": {
"post": {
"description": "用户使用用户名和密码登录,成功后返回 JWT 令牌。",
"description": "用户可以使用用户名、邮箱、手机号、微信号或飞书账号进行登录,成功后返回 JWT 令牌。",
"consumes": [
"application/json"
],
@@ -557,6 +755,67 @@ const docTemplate = `{
}
}
}
},
"/api/v1/users/{id}/history": {
"get": {
"description": "根据用户ID分页获取该用户的操作审计日志。",
"produces": [
"application/json"
],
"tags": [
"用户管理"
],
"summary": "获取指定用户的操作历史",
"parameters": [
{
"type": "integer",
"description": "用户ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "integer",
"default": 1,
"description": "页码",
"name": "page",
"in": "query"
},
{
"type": "integer",
"default": 10,
"description": "每页大小",
"name": "page_size",
"in": "query"
},
{
"type": "string",
"description": "按操作类型过滤",
"name": "action_type",
"in": "query"
}
],
"responses": {
"200": {
"description": "业务码为200代表成功获取",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/user.ListHistoryResponse"
}
}
}
]
}
}
}
}
}
},
"definitions": {
@@ -565,7 +824,11 @@ const docTemplate = `{
"properties": {
"code": {
"description": "业务状态码",
"type": "integer"
"allOf": [
{
"$ref": "#/definitions/controller.ResponseCode"
}
]
},
"data": {
"description": "业务数据"
@@ -576,63 +839,50 @@ const docTemplate = `{
}
}
},
"device.CreateDeviceRequest": {
"type": "object",
"required": [
"name",
"type"
"controller.ResponseCode": {
"type": "integer",
"enum": [
2000,
2001,
4000,
4001,
4004,
4009,
5000,
5003
],
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"parent_id": {
"type": "integer"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"sub_type": {
"$ref": "#/definitions/models.DeviceSubType"
},
"type": {
"$ref": "#/definitions/models.DeviceType"
}
}
},
"device.UpdateDeviceRequest": {
"type": "object",
"required": [
"name",
"type"
"x-enum-comments": {
"CodeBadRequest": "请求参数错误",
"CodeConflict": "资源冲突",
"CodeCreated": "创建成功",
"CodeInternalError": "服务器内部错误",
"CodeNotFound": "资源未找到",
"CodeServiceUnavailable": "服务不可用",
"CodeSuccess": "操作成功",
"CodeUnauthorized": "未授权"
},
"x-enum-descriptions": [
"操作成功",
"创建成功",
"请求参数错误",
"未授权",
"资源未找到",
"资源冲突",
"服务器内部错误",
"服务不可用"
],
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"parent_id": {
"type": "integer"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"sub_type": {
"$ref": "#/definitions/models.DeviceSubType"
},
"type": {
"$ref": "#/definitions/models.DeviceType"
}
}
"x-enum-varnames": [
"CodeSuccess",
"CodeCreated",
"CodeBadRequest",
"CodeUnauthorized",
"CodeNotFound",
"CodeConflict",
"CodeInternalError",
"CodeServiceUnavailable"
]
},
"git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse": {
"device.AreaControllerResponse": {
"type": "object",
"properties": {
"created_at": {
@@ -647,57 +897,152 @@ const docTemplate = `{
"name": {
"type": "string"
},
"parent_id": {
"type": "integer"
"network_id": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"sub_type": {
"$ref": "#/definitions/models.DeviceSubType"
},
"type": {
"$ref": "#/definitions/models.DeviceType"
"status": {
"type": "string"
},
"updated_at": {
"type": "string"
}
}
},
"models.DeviceSubType": {
"type": "string",
"enum": [
"",
"temperature",
"humidity",
"ammonia",
"weight",
"feed_valve",
"fan",
"water_curtain"
"device.CreateAreaControllerRequest": {
"type": "object",
"required": [
"name",
"network_id"
],
"x-enum-varnames": [
"SubTypeNone",
"SubTypeSensorTemp",
"SubTypeSensorHumidity",
"SubTypeSensorAmmonia",
"SubTypeSensorWeight",
"SubTypeValveFeed",
"SubTypeFan",
"SubTypeWaterCurtain"
]
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"network_id": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
}
}
},
"models.DeviceType": {
"type": "string",
"enum": [
"area_controller",
"device"
"device.CreateDeviceRequest": {
"type": "object",
"required": [
"area_controller_id",
"device_template_id",
"name"
],
"x-enum-varnames": [
"DeviceTypeAreaController",
"DeviceTypeDevice"
]
"properties": {
"area_controller_id": {
"type": "integer"
},
"device_template_id": {
"type": "integer"
},
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
}
}
},
"device.UpdateAreaControllerRequest": {
"type": "object",
"required": [
"name",
"network_id"
],
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"network_id": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
}
}
},
"device.UpdateDeviceRequest": {
"type": "object",
"required": [
"area_controller_id",
"device_template_id",
"name"
],
"properties": {
"area_controller_id": {
"type": "integer"
},
"device_template_id": {
"type": "integer"
},
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
}
}
},
"git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse": {
"type": "object",
"properties": {
"area_controller_id": {
"type": "integer"
},
"area_controller_name": {
"type": "string"
},
"created_at": {
"type": "string"
},
"device_template_id": {
"type": "integer"
},
"device_template_name": {
"type": "string"
},
"id": {
"type": "integer"
},
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"updated_at": {
"type": "string"
}
}
},
"models.PlanContentType": {
"type": "string",
@@ -1075,16 +1420,24 @@ const docTemplate = `{
}
}
},
"user.LoginRequest": {
"user.HistoryResponse": {
"type": "object",
"required": [
"password",
"username"
],
"properties": {
"password": {
"action_type": {
"type": "string",
"example": "password123"
"example": "更新设备"
},
"description": {
"type": "string",
"example": "设备更新成功"
},
"target_resource": {},
"time": {
"type": "string"
},
"user_id": {
"type": "integer",
"example": 101
},
"username": {
"type": "string",
@@ -1092,6 +1445,39 @@ const docTemplate = `{
}
}
},
"user.ListHistoryResponse": {
"type": "object",
"properties": {
"history": {
"type": "array",
"items": {
"$ref": "#/definitions/user.HistoryResponse"
}
},
"total": {
"type": "integer",
"example": 100
}
}
},
"user.LoginRequest": {
"type": "object",
"required": [
"identifier",
"password"
],
"properties": {
"identifier": {
"description": "Identifier 可以是用户名、邮箱、手机号、微信号或飞书账号",
"type": "string",
"example": "testuser"
},
"password": {
"type": "string",
"example": "password123"
}
}
},
"user.LoginResponse": {
"type": "object",
"properties": {

View File

@@ -4,6 +4,204 @@
"contact": {}
},
"paths": {
"/api/v1/area-controllers": {
"get": {
"description": "获取系统中所有区域主控的列表",
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "获取所有区域主控列表",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/device.AreaControllerResponse"
}
}
}
}
]
}
}
}
},
"post": {
"description": "根据提供的信息创建一个新区域主控",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "创建新区域主控",
"parameters": [
{
"description": "区域主控信息",
"name": "areaController",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/device.CreateAreaControllerRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/device.AreaControllerResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/area-controllers/{id}": {
"get": {
"description": "根据ID获取单个区域主控的详细信息",
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "获取区域主控信息",
"parameters": [
{
"type": "string",
"description": "区域主控ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/device.AreaControllerResponse"
}
}
}
]
}
}
}
},
"put": {
"description": "根据ID更新一个已存在的区域主控信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "更新区域主控信息",
"parameters": [
{
"type": "string",
"description": "区域主控ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "要更新的区域主控信息",
"name": "areaController",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/device.UpdateAreaControllerRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/device.AreaControllerResponse"
}
}
}
]
}
}
}
},
"delete": {
"description": "根据ID删除一个区域主控软删除",
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "删除区域主控",
"parameters": [
{
"type": "string",
"description": "区域主控ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
}
}
}
}
},
"/api/v1/devices": {
"get": {
"description": "获取系统中所有设备的列表",
@@ -370,7 +568,7 @@
}
},
"delete": {
"description": "根据计划ID删除计划。",
"description": "根据计划ID删除计划。(软删除)",
"produces": [
"application/json"
],
@@ -503,7 +701,7 @@
},
"/api/v1/users/login": {
"post": {
"description": "用户使用用户名和密码登录,成功后返回 JWT 令牌。",
"description": "用户可以使用用户名、邮箱、手机号、微信号或飞书账号进行登录,成功后返回 JWT 令牌。",
"consumes": [
"application/json"
],
@@ -546,6 +744,67 @@
}
}
}
},
"/api/v1/users/{id}/history": {
"get": {
"description": "根据用户ID分页获取该用户的操作审计日志。",
"produces": [
"application/json"
],
"tags": [
"用户管理"
],
"summary": "获取指定用户的操作历史",
"parameters": [
{
"type": "integer",
"description": "用户ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "integer",
"default": 1,
"description": "页码",
"name": "page",
"in": "query"
},
{
"type": "integer",
"default": 10,
"description": "每页大小",
"name": "page_size",
"in": "query"
},
{
"type": "string",
"description": "按操作类型过滤",
"name": "action_type",
"in": "query"
}
],
"responses": {
"200": {
"description": "业务码为200代表成功获取",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/user.ListHistoryResponse"
}
}
}
]
}
}
}
}
}
},
"definitions": {
@@ -554,7 +813,11 @@
"properties": {
"code": {
"description": "业务状态码",
"type": "integer"
"allOf": [
{
"$ref": "#/definitions/controller.ResponseCode"
}
]
},
"data": {
"description": "业务数据"
@@ -565,63 +828,50 @@
}
}
},
"device.CreateDeviceRequest": {
"type": "object",
"required": [
"name",
"type"
"controller.ResponseCode": {
"type": "integer",
"enum": [
2000,
2001,
4000,
4001,
4004,
4009,
5000,
5003
],
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"parent_id": {
"type": "integer"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"sub_type": {
"$ref": "#/definitions/models.DeviceSubType"
},
"type": {
"$ref": "#/definitions/models.DeviceType"
}
}
},
"device.UpdateDeviceRequest": {
"type": "object",
"required": [
"name",
"type"
"x-enum-comments": {
"CodeBadRequest": "请求参数错误",
"CodeConflict": "资源冲突",
"CodeCreated": "创建成功",
"CodeInternalError": "服务器内部错误",
"CodeNotFound": "资源未找到",
"CodeServiceUnavailable": "服务不可用",
"CodeSuccess": "操作成功",
"CodeUnauthorized": "未授权"
},
"x-enum-descriptions": [
"操作成功",
"创建成功",
"请求参数错误",
"未授权",
"资源未找到",
"资源冲突",
"服务器内部错误",
"服务不可用"
],
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"parent_id": {
"type": "integer"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"sub_type": {
"$ref": "#/definitions/models.DeviceSubType"
},
"type": {
"$ref": "#/definitions/models.DeviceType"
}
}
"x-enum-varnames": [
"CodeSuccess",
"CodeCreated",
"CodeBadRequest",
"CodeUnauthorized",
"CodeNotFound",
"CodeConflict",
"CodeInternalError",
"CodeServiceUnavailable"
]
},
"git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse": {
"device.AreaControllerResponse": {
"type": "object",
"properties": {
"created_at": {
@@ -636,57 +886,152 @@
"name": {
"type": "string"
},
"parent_id": {
"type": "integer"
"network_id": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"sub_type": {
"$ref": "#/definitions/models.DeviceSubType"
},
"type": {
"$ref": "#/definitions/models.DeviceType"
"status": {
"type": "string"
},
"updated_at": {
"type": "string"
}
}
},
"models.DeviceSubType": {
"type": "string",
"enum": [
"",
"temperature",
"humidity",
"ammonia",
"weight",
"feed_valve",
"fan",
"water_curtain"
"device.CreateAreaControllerRequest": {
"type": "object",
"required": [
"name",
"network_id"
],
"x-enum-varnames": [
"SubTypeNone",
"SubTypeSensorTemp",
"SubTypeSensorHumidity",
"SubTypeSensorAmmonia",
"SubTypeSensorWeight",
"SubTypeValveFeed",
"SubTypeFan",
"SubTypeWaterCurtain"
]
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"network_id": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
}
}
},
"models.DeviceType": {
"type": "string",
"enum": [
"area_controller",
"device"
"device.CreateDeviceRequest": {
"type": "object",
"required": [
"area_controller_id",
"device_template_id",
"name"
],
"x-enum-varnames": [
"DeviceTypeAreaController",
"DeviceTypeDevice"
]
"properties": {
"area_controller_id": {
"type": "integer"
},
"device_template_id": {
"type": "integer"
},
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
}
}
},
"device.UpdateAreaControllerRequest": {
"type": "object",
"required": [
"name",
"network_id"
],
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"network_id": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
}
}
},
"device.UpdateDeviceRequest": {
"type": "object",
"required": [
"area_controller_id",
"device_template_id",
"name"
],
"properties": {
"area_controller_id": {
"type": "integer"
},
"device_template_id": {
"type": "integer"
},
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
}
}
},
"git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse": {
"type": "object",
"properties": {
"area_controller_id": {
"type": "integer"
},
"area_controller_name": {
"type": "string"
},
"created_at": {
"type": "string"
},
"device_template_id": {
"type": "integer"
},
"device_template_name": {
"type": "string"
},
"id": {
"type": "integer"
},
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"properties": {
"type": "object",
"additionalProperties": true
},
"updated_at": {
"type": "string"
}
}
},
"models.PlanContentType": {
"type": "string",
@@ -1064,16 +1409,24 @@
}
}
},
"user.LoginRequest": {
"user.HistoryResponse": {
"type": "object",
"required": [
"password",
"username"
],
"properties": {
"password": {
"action_type": {
"type": "string",
"example": "password123"
"example": "更新设备"
},
"description": {
"type": "string",
"example": "设备更新成功"
},
"target_resource": {},
"time": {
"type": "string"
},
"user_id": {
"type": "integer",
"example": 101
},
"username": {
"type": "string",
@@ -1081,6 +1434,39 @@
}
}
},
"user.ListHistoryResponse": {
"type": "object",
"properties": {
"history": {
"type": "array",
"items": {
"$ref": "#/definitions/user.HistoryResponse"
}
},
"total": {
"type": "integer",
"example": 100
}
}
},
"user.LoginRequest": {
"type": "object",
"required": [
"identifier",
"password"
],
"properties": {
"identifier": {
"description": "Identifier 可以是用户名、邮箱、手机号、微信号或飞书账号",
"type": "string",
"example": "testuser"
},
"password": {
"type": "string",
"example": "password123"
}
}
},
"user.LoginResponse": {
"type": "object",
"properties": {

View File

@@ -2,53 +2,54 @@ definitions:
controller.Response:
properties:
code:
allOf:
- $ref: '#/definitions/controller.ResponseCode'
description: 业务状态码
type: integer
data:
description: 业务数据
message:
description: 提示信息
type: string
type: object
device.CreateDeviceRequest:
properties:
location:
type: string
name:
type: string
parent_id:
type: integer
properties:
additionalProperties: true
type: object
sub_type:
$ref: '#/definitions/models.DeviceSubType'
type:
$ref: '#/definitions/models.DeviceType'
required:
- name
- type
type: object
device.UpdateDeviceRequest:
properties:
location:
type: string
name:
type: string
parent_id:
type: integer
properties:
additionalProperties: true
type: object
sub_type:
$ref: '#/definitions/models.DeviceSubType'
type:
$ref: '#/definitions/models.DeviceType'
required:
- name
- type
type: object
git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse:
controller.ResponseCode:
enum:
- 2000
- 2001
- 4000
- 4001
- 4004
- 4009
- 5000
- 5003
type: integer
x-enum-comments:
CodeBadRequest: 请求参数错误
CodeConflict: 资源冲突
CodeCreated: 创建成功
CodeInternalError: 服务器内部错误
CodeNotFound: 资源未找到
CodeServiceUnavailable: 服务不可用
CodeSuccess: 操作成功
CodeUnauthorized: 未授权
x-enum-descriptions:
- 操作成功
- 创建成功
- 请求参数错误
- 未授权
- 资源未找到
- 资源冲突
- 服务器内部错误
- 服务不可用
x-enum-varnames:
- CodeSuccess
- CodeCreated
- CodeBadRequest
- CodeUnauthorized
- CodeNotFound
- CodeConflict
- CodeInternalError
- CodeServiceUnavailable
device.AreaControllerResponse:
properties:
created_at:
type: string
@@ -58,46 +59,106 @@ definitions:
type: string
name:
type: string
parent_id:
type: integer
network_id:
type: string
properties:
additionalProperties: true
type: object
status:
type: string
updated_at:
type: string
type: object
device.CreateAreaControllerRequest:
properties:
location:
type: string
name:
type: string
network_id:
type: string
properties:
additionalProperties: true
type: object
required:
- name
- network_id
type: object
device.CreateDeviceRequest:
properties:
area_controller_id:
type: integer
device_template_id:
type: integer
location:
type: string
name:
type: string
properties:
additionalProperties: true
type: object
required:
- area_controller_id
- device_template_id
- name
type: object
device.UpdateAreaControllerRequest:
properties:
location:
type: string
name:
type: string
network_id:
type: string
properties:
additionalProperties: true
type: object
required:
- name
- network_id
type: object
device.UpdateDeviceRequest:
properties:
area_controller_id:
type: integer
device_template_id:
type: integer
location:
type: string
name:
type: string
properties:
additionalProperties: true
type: object
required:
- area_controller_id
- device_template_id
- name
type: object
git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse:
properties:
area_controller_id:
type: integer
area_controller_name:
type: string
created_at:
type: string
device_template_id:
type: integer
device_template_name:
type: string
id:
type: integer
location:
type: string
name:
type: string
properties:
additionalProperties: true
type: object
sub_type:
$ref: '#/definitions/models.DeviceSubType'
type:
$ref: '#/definitions/models.DeviceType'
updated_at:
type: string
type: object
models.DeviceSubType:
enum:
- ""
- temperature
- humidity
- ammonia
- weight
- feed_valve
- fan
- water_curtain
type: string
x-enum-varnames:
- SubTypeNone
- SubTypeSensorTemp
- SubTypeSensorHumidity
- SubTypeSensorAmmonia
- SubTypeSensorWeight
- SubTypeValveFeed
- SubTypeFan
- SubTypeWaterCurtain
models.DeviceType:
enum:
- area_controller
- device
type: string
x-enum-varnames:
- DeviceTypeAreaController
- DeviceTypeDevice
models.PlanContentType:
enum:
- sub_plans
@@ -358,17 +419,46 @@ definitions:
example: newuser
type: string
type: object
user.LoginRequest:
user.HistoryResponse:
properties:
password:
example: password123
action_type:
example: 更新设备
type: string
description:
example: 设备更新成功
type: string
target_resource: {}
time:
type: string
user_id:
example: 101
type: integer
username:
example: testuser
type: string
type: object
user.ListHistoryResponse:
properties:
history:
items:
$ref: '#/definitions/user.HistoryResponse'
type: array
total:
example: 100
type: integer
type: object
user.LoginRequest:
properties:
identifier:
description: Identifier 可以是用户名、邮箱、手机号、微信号或飞书账号
example: testuser
type: string
password:
example: password123
type: string
required:
- identifier
- password
- username
type: object
user.LoginResponse:
properties:
@@ -385,6 +475,125 @@ definitions:
info:
contact: {}
paths:
/api/v1/area-controllers:
get:
description: 获取系统中所有区域主控的列表
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
items:
$ref: '#/definitions/device.AreaControllerResponse'
type: array
type: object
summary: 获取所有区域主控列表
tags:
- 区域主控管理
post:
consumes:
- application/json
description: 根据提供的信息创建一个新区域主控
parameters:
- description: 区域主控信息
in: body
name: areaController
required: true
schema:
$ref: '#/definitions/device.CreateAreaControllerRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/device.AreaControllerResponse'
type: object
summary: 创建新区域主控
tags:
- 区域主控管理
/api/v1/area-controllers/{id}:
delete:
description: 根据ID删除一个区域主控软删除
parameters:
- description: 区域主控ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
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: OK
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/device.AreaControllerResponse'
type: object
summary: 获取区域主控信息
tags:
- 区域主控管理
put:
consumes:
- application/json
description: 根据ID更新一个已存在的区域主控信息
parameters:
- description: 区域主控ID
in: path
name: id
required: true
type: string
- description: 要更新的区域主控信息
in: body
name: areaController
required: true
schema:
$ref: '#/definitions/device.UpdateAreaControllerRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/device.AreaControllerResponse'
type: object
summary: 更新区域主控信息
tags:
- 区域主控管理
/api/v1/devices:
get:
description: 获取系统中所有设备的列表
@@ -550,7 +759,7 @@ paths:
- 计划管理
/api/v1/plans/{id}:
delete:
description: 根据计划ID删除计划。
description: 根据计划ID删除计划。(软删除)
parameters:
- description: 计划ID
in: path
@@ -686,11 +895,49 @@ paths:
summary: 创建新用户
tags:
- 用户管理
/api/v1/users/{id}/history:
get:
description: 根据用户ID分页获取该用户的操作审计日志。
parameters:
- description: 用户ID
in: path
name: id
required: true
type: integer
- default: 1
description: 页码
in: query
name: page
type: integer
- default: 10
description: 每页大小
in: query
name: page_size
type: integer
- description: 按操作类型过滤
in: query
name: action_type
type: string
produces:
- application/json
responses:
"200":
description: 业务码为200代表成功获取
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/user.ListHistoryResponse'
type: object
summary: 获取指定用户的操作历史
tags:
- 用户管理
/api/v1/users/login:
post:
consumes:
- application/json
description: 用户使用用户名和密码登录,成功后返回 JWT 令牌。
description: 用户可以使用用户名、邮箱、手机号、微信号或飞书账号进行登录,成功后返回 JWT 令牌。
parameters:
- description: 登录凭证
in: body