Skip to content

Commit

Permalink
feat:增加swag的依赖和用户接口显示 (opsre#345)
Browse files Browse the repository at this point in the history
feat:增加swag的依赖和用户接口显示
  • Loading branch information
nangongchengfeng authored May 20, 2024
1 parent 05dee50 commit 18941fb
Show file tree
Hide file tree
Showing 19 changed files with 8,662 additions and 33 deletions.
8 changes: 8 additions & 0 deletions controller/a_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ func Run(c *gin.Context, req interface{}, fn func() (interface{}, interface{}))
tools.Success(c, data)
}

// Demo
// @Summary 健康检测
// @Tags 基础管理
// @Produce json
// @Description 健康检测
// @Success 200 {object} response.ResponseBody
// @router /base/ping [get]
func Demo(c *gin.Context) {
// 健康检测
CodeDebug()
c.JSON(http.StatusOK, tools.H{"code": 200, "msg": "ok", "data": "pong"})
}
Expand Down
43 changes: 43 additions & 0 deletions controller/api_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import (
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{}) {
Expand All @@ -18,6 +26,14 @@ func (m *ApiController) List(c *gin.Context) {
}

// 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{}) {
Expand All @@ -26,6 +42,15 @@ func (m *ApiController) GetTree(c *gin.Context) {
}

// 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{}) {
Expand All @@ -34,6 +59,15 @@ func (m *ApiController) Add(c *gin.Context) {
}

// 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{}) {
Expand All @@ -42,6 +76,15 @@ func (m *ApiController) Update(c *gin.Context) {
}

// 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{}) {
Expand Down
41 changes: 40 additions & 1 deletion controller/base_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import (
type BaseController struct{}

// SendCode 给用户邮箱发送验证码
// @Summary 发送验证码
// @Description 向指定邮箱发送验证码
// @Tags 基础管理
// @Accept application/json
// @Produce application/json
// @Param data body request.BaseSendCodeReq true "发送验证码请求数据"
// @Success 200 {object} response.ResponseBody
// @Router /base/sendcode [post]
func (m *BaseController) SendCode(c *gin.Context) {
req := new(request.BaseSendCodeReq)
Run(c, req, func() (interface{}, interface{}) {
Expand All @@ -18,6 +26,14 @@ func (m *BaseController) SendCode(c *gin.Context) {
}

// ChangePwd 用户通过邮箱修改密码
// @Summary 用户通过邮箱修改密码
// @Description 使用邮箱验证码修改密码
// @Tags 基础管理
// @Accept application/json
// @Produce application/json
// @Param data body request.BaseChangePwdReq true "发送验证码请求数据"
// @Success 200 {object} response.ResponseBody
// @Router /base/changePwd [post]
func (m *BaseController) ChangePwd(c *gin.Context) {
req := new(request.BaseChangePwdReq)
Run(c, req, func() (interface{}, interface{}) {
Expand All @@ -26,14 +42,29 @@ func (m *BaseController) ChangePwd(c *gin.Context) {
}

// Dashboard 系统首页展示数据
// @Summary 获取仪表盘数据
// @Description 获取系统仪表盘概览数据
// @Tags 基础管理
// @Accept application/json
// @Produce application/json
// @Success 200 {object} response.ResponseBody
// @Router /base/dashboard [get]
func (m *BaseController) Dashboard(c *gin.Context) {
req := new(request.BaseDashboardReq)
Run(c, req, func() (interface{}, interface{}) {
return logic.Base.Dashboard(c, req)
})
}

// EncryptPasswd 生成加密密码
// EncryptPasswd 密码加密
// @Summary 密码加密
// @Description 将明文密码加密
// @Tags 基础管理
// @Accept application/json
// @Produce application/json
// @Param passwd query string true "需要加密的明文密码"
// @Success 200 {object} response.ResponseBody
// @Router /base/encryptpwd [get]
func (m *BaseController) EncryptPasswd(c *gin.Context) {
req := new(request.EncryptPasswdReq)
Run(c, req, func() (interface{}, interface{}) {
Expand All @@ -42,6 +73,14 @@ func (m *BaseController) EncryptPasswd(c *gin.Context) {
}

// DecryptPasswd 密码解密为明文
// @Summary 密码解密
// @Description 将加密后的密码解密为明文
// @Tags 基础管理
// @Accept application/json
// @Produce application/json
// @Param passwd query string true "需要解密的加密密码"
// @Success 200 {object} response.ResponseBody
// @Router /base/decryptpwd [get]
func (m *BaseController) DecryptPasswd(c *gin.Context) {
req := new(request.DecryptPasswdReq)
Run(c, req, func() (interface{}, interface{}) {
Expand Down
35 changes: 35 additions & 0 deletions controller/field_relation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import (
type FieldRelationController struct{}

// List 记录列表
// @Summary 获字段关系管理列表
// Description: 获字段关系管理列表
// @Tags 字段关系管理
// @Accept application/json
// @Produce application/json
// @Success 200 {object} response.ResponseBody
// @Router /fieldrelation/list [get]
// @Security ApiKeyAuth
func (m *FieldRelationController) List(c *gin.Context) {
req := new(request.FieldRelationListReq)
Run(c, req, func() (interface{}, interface{}) {
Expand All @@ -18,6 +26,15 @@ func (m *FieldRelationController) List(c *gin.Context) {
}

// Add 新建记录
// @Summary 新建字段关系管理记录
// Description: 新建字段关系管理记录
// @Tags 字段关系管理
// @Accept application/json
// @Produce application/json
// @Param data body request.FieldRelationAddReq true "新建字段关系管理记录"
// @Success 200 {object} response.ResponseBody
// @Router /fieldrelation/add [post]
// @Security ApiKeyAuth
func (m *FieldRelationController) Add(c *gin.Context) {
req := new(request.FieldRelationAddReq)
Run(c, req, func() (interface{}, interface{}) {
Expand All @@ -26,6 +43,15 @@ func (m *FieldRelationController) Add(c *gin.Context) {
}

// Update 更新记录
// @Summary 更新字段关系管理记录
// Description: 更新字段关系管理记录
// @Tags 字段关系管理
// @Accept application/json
// @Produce application/json
// @Param data body request.FieldRelationUpdateReq true "更新字段关系管理记录"
// @Success 200 {object} response.ResponseBody
// @Router /fieldrelation/update [post]
// @Security ApiKeyAuth
func (m *FieldRelationController) Update(c *gin.Context) {
req := new(request.FieldRelationUpdateReq)
Run(c, req, func() (interface{}, interface{}) {
Expand All @@ -34,6 +60,15 @@ func (m *FieldRelationController) Update(c *gin.Context) {
}

// Delete 删除记录
// @Summary 删除字段关系管理记录
// Description: 删除字段关系管理记录
// @Tags 字段关系管理
// @Accept application/json
// @Produce application/json
// @Param data body request.FieldRelationDeleteReq true "删除字段关系管理记录"
// @Success 200 {object} response.ResponseBody
// @Router /fieldrelation/delete [post]
// @Security ApiKeyAuth
func (m *FieldRelationController) Delete(c *gin.Context) {
req := new(request.FieldRelationDeleteReq)
Run(c, req, func() (interface{}, interface{}) {
Expand Down
Loading

0 comments on commit 18941fb

Please sign in to comment.