-
-
Notifications
You must be signed in to change notification settings - Fork 276
/
Copy pathapi_controller.go
93 lines (85 loc) · 2.46 KB
/
api_controller.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
package controller
import (
"github.com/eryajf/go-ldap-admin/logic"
"github.com/eryajf/go-ldap-admin/model/request"
"github.com/gin-gonic/gin"
)
type ApiController struct{}
// List 记录列表
// @Summary 获取API接口列表
// Description: 获取API接口列表
// @Tags 接口管理
// @Accept application/json
// @Produce application/json
// @Success 200 {object} response.ResponseBody
// @Router /api/list [get]
// @Security ApiKeyAuth
func (m *ApiController) List(c *gin.Context) {
req := new(request.ApiListReq)
Run(c, req, func() (interface{}, interface{}) {
return logic.Api.List(c, req)
})
}
// GetTree 接口树
// @Summary 获取API接口树
// Description: 获取API接口树
// @Tags 接口管理
// @Accept application/json
// @Produce application/json
// @Success 200 {object} response.ResponseBody
// @Router /api/tree [get]
// @Security ApiKeyAuth
func (m *ApiController) GetTree(c *gin.Context) {
req := new(request.ApiGetTreeReq)
Run(c, req, func() (interface{}, interface{}) {
return logic.Api.GetTree(c, req)
})
}
// Add 新建记录
// @Summary 新建API接口
// @Tags 接口管理
// Description: 新建API接口
// @Accept application/json
// @Produce application/json
// @Param data body request.ApiAddReq true "新建API"
// @Success 200 {object} response.ResponseBody
// @Router /api/add [post]
// @Security ApiKeyAuth
func (m *ApiController) Add(c *gin.Context) {
req := new(request.ApiAddReq)
Run(c, req, func() (interface{}, interface{}) {
return logic.Api.Add(c, req)
})
}
// Update 更新记录
// @Summary 更新API接口
// @Tags 接口管理
// Description: 更新API接口
// @Accept application/json
// @Produce application/json
// @Param data body request.ApiUpdateReq true "更新API"
// @Success 200 {object} response.ResponseBody
// @Router /api/update [post]
// @Security ApiKeyAuth
func (m *ApiController) Update(c *gin.Context) {
req := new(request.ApiUpdateReq)
Run(c, req, func() (interface{}, interface{}) {
return logic.Api.Update(c, req)
})
}
// Delete 删除记录
// @Summary 删除API接口
// @Tags 接口管理
// Description: 删除API接口
// @Accept application/json
// @Produce application/json
// @Param data body request.ApiDeleteReq true "删除API"
// @Success 200 {object} response.ResponseBody
// @Router /api/delete [post]
// @Security ApiKeyAuth
func (m *ApiController) Delete(c *gin.Context) {
req := new(request.ApiDeleteReq)
Run(c, req, func() (interface{}, interface{}) {
return logic.Api.Delete(c, req)
})
}