ldap-1-backend/controller/api_controller.go

94 lines
2.5 KiB
Go
Raw Permalink Normal View History

2022-05-18 17:57:03 +08:00
package controller
import (
2022-05-29 10:06:21 +08:00
"github.com/eryajf/go-ldap-admin/logic"
"github.com/eryajf/go-ldap-admin/model/request"
2022-05-18 17:57:03 +08:00
"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
2022-05-18 17:57:03 +08:00
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
2022-05-18 17:57:03 +08:00
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
2022-05-18 17:57:03 +08:00
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
2022-05-18 17:57:03 +08:00
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
2022-05-18 17:57:03 +08:00
func (m *ApiController) Delete(c *gin.Context) {
req := new(request.ApiDeleteReq)
Run(c, req, func() (interface{}, interface{}) {
return logic.Api.Delete(c, req)
})
}