feat: swagger

This commit is contained in:
Blizzard
2025-09-16 14:27:32 +08:00
parent 79c19bc47c
commit 237ac665e6
19 changed files with 4690 additions and 91 deletions
+53
View File
@@ -14,6 +14,15 @@ import (
type RoleApi struct {
}
// SaveRole
// @tags 角色管理
// @Summary 创建角色
// @Security ApiKeyAuth
// @accept json
// @Produce json
// @Param data body system.Role true "角色信息"
// @Success 200 {object} response.Response
// @Router /api/role/save [post]
func (a *RoleApi) SaveRole(context *gin.Context) {
var role system.Role
err := context.ShouldBindJSON(&role)
@@ -30,6 +39,15 @@ func (a *RoleApi) SaveRole(context *gin.Context) {
response.OkWithMsg("保存角色成功!", context)
}
// UpdateRole
// @tags 角色管理
// @Summary 修改角色
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body system.Role true "角色ID"
// @Success 200 {object} response.Response"
// @Router /api/role/update [post]
func (a *RoleApi) UpdateRole(context *gin.Context) {
var role system.Role
err := context.ShouldBindJSON(&role)
@@ -46,6 +64,15 @@ func (a *RoleApi) UpdateRole(context *gin.Context) {
response.OkWithMsg("更新角色成功!", context)
}
// GetRoleList
// @tags 角色管理
// @Summary 获取角色列表
// @Description 获取角色列表
// @Accept application/json
// @Produce application/json
// @Param data body systemreq.GetRoleList true "页码, 每页大小, 搜索条件"
// @success 200 {object} response.Response{data=response.PageResult,msg=string} "获取角色列表,返回包括列表,总数,页码,每页大小"
// @Router /api/role/getRoleList [post]
func (a *RoleApi) GetRoleList(c *gin.Context) {
var pageInfo systemreq.GetRoleList
err := c.ShouldBindJSON(&pageInfo)
@@ -66,6 +93,15 @@ func (a *RoleApi) GetRoleList(c *gin.Context) {
}, c)
}
// Delete
// @Tags 角色管理
// @Summary 删除角色
// @Description 删除角色
// @Accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除角色"
// @Success 200 {object} response.Response{msg=string} "删除角色"
// @Router /api/role/delete [post]
func (a *RoleApi) Delete(context *gin.Context) {
var ids request.IdsReq
err := context.ShouldBindJSON(&ids)
@@ -82,6 +118,14 @@ func (a *RoleApi) Delete(context *gin.Context) {
response.OkWithMsg("删除角色成功!", context)
}
// Detail
// @Tags 角色管理
// @Summary 角色详情
// @Security ApiKeyAuth
// @Produce application/json
// @Param id query string true "id"
// @Success 200 {object} response.Response{data=system.Role} "角色详情"
// @Router /api/role/detail [get]
func (a *RoleApi) Detail(context *gin.Context) {
id := context.Query("id")
role, err := roleService.GetRoleById(id)
@@ -93,6 +137,15 @@ func (a *RoleApi) Detail(context *gin.Context) {
response.OkWithData(role, context)
}
// GrantMenu
// @tags 角色管理
// @Summary 授权菜单给角色
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body systemreq.GrantMenu true "授权菜单给角色"
// @success 200 {object} response.Response "授权菜单给角色"
// @Router /api/role/grantMenu [post]
func (a *RoleApi) GrantMenu(c *gin.Context) {
var grantMenu systemreq.GrantMenu
err := c.ShouldBindJSON(&grantMenu)