/
api.go
118 lines (107 loc) · 3.78 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package broker
import (
"github.com/zgwit/iot-master/v4/api"
"github.com/zgwit/iot-master/v4/web/curd"
)
func init() {
api.Register("POST", "/broker/count", curd.ApiCount[Broker]())
api.Register("POST", "/broker/search", curd.ApiSearch[Broker]("id", "name", "port", "disabled", "created"))
api.Register("GET", "/broker/list", curd.ApiList[Broker]())
api.Register("POST", "/broker/create", curd.ApiCreateHook[Broker](curd.GenerateID[Broker](), nil))
api.Register("GET", "/broker/:id", curd.ParseParamStringId, curd.ApiGet[Broker]())
api.Register("POST", "/broker/:id", curd.ParseParamStringId, curd.ApiUpdate[Broker]())
api.Register("GET", "/broker/:id/delete", curd.ParseParamStringId, curd.ApiDeleteHook[Broker](nil, nil))
api.Register("GET", "/broker/:id/disable", curd.ParseParamStringId, curd.ApiDisableHook[Broker](true, nil, nil))
api.Register("GET", "/broker/:id/enable", curd.ParseParamStringId, curd.ApiDisableHook[Broker](false, nil, nil))
}
// @Summary 查询MQTT服务器数量
// @Schemes
// @Description 查询MQTT服务器数量
// @Tags broker
// @Param search body curd.ParamSearch true "查询参数"
// @Accept json
// @Produce json
// @Success 200 {object} curd.ReplyData[int64] 返回MQTT服务器数量
// @Router /broker/count [post]
func noopBrokerCount() {}
// @Summary 查询MQTT服务器
// @Schemes
// @Description 查询MQTT服务器
// @Tags broker
// @Param search body curd.ParamSearch true "查询参数"
// @Accept json
// @Produce json
// @Success 200 {object} curd.ReplyList[Broker] 返回MQTT服务器信息
// @Router /broker/search [post]
func noopBrokerSearch() {}
// @Summary 查询MQTT服务器
// @Schemes
// @Description 查询MQTT服务器
// @Tags broker
// @Param search query curd.ParamList true "查询参数"
// @Accept json
// @Produce json
// @Success 200 {object} curd.ReplyList[Broker] 返回MQTT服务器信息
// @Router /broker/list [get]
func noopBrokerList() {}
// @Summary 创建MQTT服务器
// @Schemes
// @Description 创建MQTT服务器
// @Tags broker
// @Param search body Broker true "MQTT服务器信息"
// @Accept json
// @Produce json
// @Success 200 {object} curd.ReplyData[Broker] 返回MQTT服务器信息
// @Router /broker/create [post]
func noopBrokerCreate() {}
// @Summary 修改MQTT服务器
// @Schemes
// @Description 修改MQTT服务器
// @Tags broker
// @Param id path int true "MQTT服务器ID"
// @Param broker body Broker true "MQTT服务器信息"
// @Accept json
// @Produce json
// @Success 200 {object} curd.ReplyData[Broker] 返回MQTT服务器信息
// @Router /broker/{id} [post]
func noopBrokerUpdate() {}
// @Summary 获取MQTT服务器
// @Schemes
// @Description 获取MQTT服务器
// @Tags broker
// @Param id path string true "MQTT服务器ID"
// @Accept json
// @Produce json
// @Success 200 {object} curd.ReplyData[Broker] 返回MQTT服务器信息
// @Router /broker/{id} [get]
func noopBrokerGet() {}
// @Summary 删除MQTT服务器
// @Schemes
// @Description 删除MQTT服务器
// @Tags broker
// @Param id path int true "MQTT服务器ID"
// @Accept json
// @Produce json
// @Success 200 {object} curd.ReplyData[Broker] 返回MQTT服务器信息
// @Router /broker/{id}/delete [get]
func noopBrokerDelete() {}
// @Summary 启用MQTT服务器
// @Schemes
// @Description 启用MQTT服务器
// @Tags broker
// @Param id path int true "MQTT服务器ID"
// @Accept json
// @Produce json
// @Success 200 {object} curd.ReplyData[Broker] 返回MQTT服务器信息
// @Router /broker/{id}/enable [get]
func noopBrokerEnable() {}
// @Summary 禁用MQTT服务器
// @Schemes
// @Description 禁用MQTT服务器
// @Tags broker
// @Param id path int true "MQTT服务器ID"
// @Accept json
// @Produce json
// @Success 200 {object} curd.ReplyData[Broker] 返回MQTT服务器信息
// @Router /broker/{id}/disable [get]
func noopBrokerDisable() {}