【更新】更新swagger文档

This commit is contained in:
PandaGoAdmin
2022-08-04 16:57:18 +08:00
parent 6db51fb2c9
commit 6d893f7c4e
39 changed files with 439 additions and 214 deletions

View File

@@ -2,9 +2,9 @@ package api
import (
"github.com/XM-GO/PandaKit/casbin"
"github.com/XM-GO/PandaKit/model"
"github.com/XM-GO/PandaKit/restfulx"
"github.com/XM-GO/PandaKit/utils"
"log"
entity "pandax/apps/system/entity"
services "pandax/apps/system/services"
"strconv"
@@ -17,7 +17,6 @@ type SystemApiApi struct {
func (s *SystemApiApi) CreateApi(rc *restfulx.ReqCtx) {
var api entity.SysApi
restfulx.BindQuery(rc, &api)
log.Println(api)
s.ApiApp.Insert(api)
}
@@ -35,11 +34,11 @@ func (s *SystemApiApi) GetApiList(rc *restfulx.ReqCtx) {
apiGroup := rc.Request.QueryParameter("apiGroup")
api := entity.SysApi{Path: path, Description: description, Method: method, ApiGroup: apiGroup}
list, total := s.ApiApp.FindListPage(pageNum, pageSize, api)
rc.ResData = map[string]any{
"data": list,
"total": total,
"pageNum": pageNum,
"pageSize": pageSize,
rc.ResData = model.ResultPage{
Total: total,
PageNum: int64(pageNum),
PageSize: int64(pageNum),
Data: list,
}
}

View File

@@ -2,6 +2,7 @@ package api
import (
"github.com/XM-GO/PandaKit/biz"
"github.com/XM-GO/PandaKit/model"
"github.com/XM-GO/PandaKit/restfulx"
"github.com/XM-GO/PandaKit/utils"
entity "pandax/apps/system/entity"
@@ -21,11 +22,11 @@ func (p *ConfigApi) GetConfigList(rc *restfulx.ReqCtx) {
config := entity.SysConfig{ConfigName: configName, ConfigKey: configKey, ConfigType: configType}
list, total := p.ConfigApp.FindListPage(pageNum, pageSize, config)
rc.ResData = map[string]any{
"data": list,
"total": total,
"pageNum": pageNum,
"pageSize": pageSize,
rc.ResData = model.ResultPage{
Total: total,
PageNum: int64(pageNum),
PageSize: int64(pageNum),
Data: list,
}
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/XM-GO/PandaKit/biz"
"github.com/XM-GO/PandaKit/restfulx"
"github.com/XM-GO/PandaKit/utils"
"pandax/apps/system/api/vo"
"pandax/apps/system/entity"
"pandax/apps/system/services"
"pandax/pkg/global"
@@ -29,9 +30,9 @@ func (m *DeptApi) GetDeptTreeRoleSelect(rc *restfulx.ReqCtx) {
if roleId != 0 {
deptIds = m.RoleApp.GetRoleDeptId(entity.SysRole{RoleId: int64(roleId)})
}
rc.ResData = map[string]any{
"depts": result,
"checkedKeys": deptIds,
rc.ResData = vo.DeptTreeVo{
Depts: result,
CheckedKeys: deptIds,
}
}

View File

@@ -3,6 +3,7 @@ package api
import (
"fmt"
"github.com/XM-GO/PandaKit/biz"
"github.com/XM-GO/PandaKit/model"
"github.com/XM-GO/PandaKit/restfulx"
"github.com/XM-GO/PandaKit/utils"
entity "pandax/apps/system/entity"
@@ -23,11 +24,11 @@ func (p *DictApi) GetDictTypeList(rc *restfulx.ReqCtx) {
dictType := restfulx.QueryParam(rc, "dictType")
list, total := p.DictType.FindListPage(pageNum, pageSize, entity.SysDictType{Status: status, DictName: dictName, DictType: dictType})
rc.ResData = map[string]any{
"data": list,
"total": total,
"pageNum": pageNum,
"pageSize": pageSize,
rc.ResData = model.ResultPage{
Total: total,
PageNum: int64(pageNum),
PageSize: int64(pageNum),
Data: list,
}
}

View File

@@ -4,6 +4,7 @@ import (
"github.com/XM-GO/PandaKit/biz"
"github.com/XM-GO/PandaKit/restfulx"
"github.com/XM-GO/PandaKit/utils"
"pandax/apps/system/api/vo"
entity "pandax/apps/system/entity"
services "pandax/apps/system/services"
)
@@ -35,9 +36,9 @@ func (m *MenuApi) GetMenuTreeRoleSelect(rc *restfulx.ReqCtx) {
if roleId != 0 {
menuIds = m.RoleApp.GetRoleMeunId(entity.SysRole{RoleId: int64(roleId)})
}
rc.ResData = map[string]any{
"menus": result,
"checkedKeys": menuIds,
rc.ResData = vo.MenuTreeVo{
Menus: *result,
CheckedKeys: menuIds,
}
}
@@ -72,9 +73,9 @@ func (m *MenuApi) InsertMenu(rc *restfulx.ReqCtx) {
m.MenuApp.Insert(menu)
permis := m.RoleMenuApp.GetPermis(rc.LoginAccount.RoleId)
menus := m.MenuApp.SelectMenuRole(rc.LoginAccount.RoleKey)
rc.ResData = map[string]any{
"permissions": permis,
"menus": Build(*menus),
rc.ResData = vo.MenuPermisVo{
Menus: Build(*menus),
Permissions: permis,
}
}
@@ -85,9 +86,9 @@ func (m *MenuApi) UpdateMenu(rc *restfulx.ReqCtx) {
m.MenuApp.Update(menu)
permis := m.RoleMenuApp.GetPermis(rc.LoginAccount.RoleId)
menus := m.MenuApp.SelectMenuRole(rc.LoginAccount.RoleKey)
rc.ResData = map[string]any{
"permissions": permis,
"menus": Build(*menus),
rc.ResData = vo.MenuPermisVo{
Menus: Build(*menus),
Permissions: permis,
}
}

View File

@@ -1,6 +1,7 @@
package api
import (
"github.com/XM-GO/PandaKit/model"
"github.com/XM-GO/PandaKit/restfulx"
"github.com/XM-GO/PandaKit/utils"
"pandax/apps/system/entity"
@@ -28,11 +29,11 @@ func (p *NoticeApi) GetNoticeList(rc *restfulx.ReqCtx) {
notice := entity.SysNotice{NoticeType: noticeType, Title: title, DeptIds: ids}
list, total := p.NoticeApp.FindListPage(pageNum, pageSize, notice)
rc.ResData = map[string]any{
"data": list,
"total": total,
"pageNum": pageNum,
"pageSize": pageSize,
rc.ResData = model.ResultPage{
Total: total,
PageNum: int64(pageNum),
PageSize: int64(pageNum),
Data: list,
}
}

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"github.com/XM-GO/PandaKit/biz"
"github.com/XM-GO/PandaKit/model"
"github.com/XM-GO/PandaKit/restfulx"
"github.com/XM-GO/PandaKit/utils"
"pandax/apps/system/entity"
@@ -33,11 +34,11 @@ func (p *PostApi) GetPostList(rc *restfulx.ReqCtx) {
list, total := p.PostApp.FindListPage(pageNum, pageSize, post)
rc.ResData = map[string]any{
"data": list,
"total": total,
"pageNum": pageNum,
"pageSize": pageSize,
rc.ResData = model.ResultPage{
Total: total,
PageNum: int64(pageNum),
PageSize: int64(pageNum),
Data: list,
}
}

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"github.com/XM-GO/PandaKit/biz"
"github.com/XM-GO/PandaKit/casbin"
"github.com/XM-GO/PandaKit/model"
"github.com/XM-GO/PandaKit/restfulx"
"github.com/XM-GO/PandaKit/utils"
entity "pandax/apps/system/entity"
@@ -35,11 +36,11 @@ func (r *RoleApi) GetRoleList(rc *restfulx.ReqCtx) {
list, total := r.RoleApp.FindListPage(pageNum, pageSize, role)
rc.ResData = map[string]any{
"data": list,
"total": total,
"pageNum": pageNum,
"pageSize": pageSize,
rc.ResData = model.ResultPage{
Total: total,
PageNum: int64(pageNum),
PageSize: int64(pageNum),
Data: list,
}
}

View File

@@ -6,6 +6,7 @@ package api
* @Date 2022/7/14 17:55
**/
import (
"github.com/XM-GO/PandaKit/model"
"github.com/XM-GO/PandaKit/restfulx"
"github.com/XM-GO/PandaKit/utils"
"pandax/apps/system/entity"
@@ -23,11 +24,11 @@ func (p *SysTenantsApi) GetSysTenantsList(rc *restfulx.ReqCtx) {
list, total := p.SysTenantsApp.FindListPage(pageNum, pageSize, data)
rc.ResData = map[string]interface{}{
"data": list,
"total": total,
"pageNum": pageNum,
"pageSize": pageSize,
rc.ResData = model.ResultPage{
Total: total,
PageNum: int64(pageNum),
PageSize: int64(pageNum),
Data: list,
}
}

View File

@@ -1,6 +1,7 @@
package api
import (
"github.com/XM-GO/PandaKit/model"
"github.com/XM-GO/PandaKit/token"
"github.com/dgrijalva/jwt-go"
"github.com/emicklei/go-restful/v3"
@@ -39,7 +40,7 @@ type UserApi struct {
// GenerateCaptcha 获取验证码
func (u *UserApi) GenerateCaptcha(request *restful.Request, response *restful.Response) {
id, image := captcha.Generate()
response.WriteEntity(map[string]any{"base64Captcha": image, "captchaId": id})
response.WriteEntity(vo.CaptchaVo{Base64Captcha: image, CaptchaId: id})
}
// RefreshToken 刷新token
@@ -48,7 +49,10 @@ func (u *UserApi) RefreshToken(rc *restfulx.ReqCtx) {
j := token.NewJWT("", []byte(global.Conf.Jwt.Key), jwt.SigningMethodHS256)
token, err := j.RefreshToken(tokenStr)
biz.ErrIsNil(err, "刷新token失败")
rc.ResData = map[string]any{"token": token, "expire": time.Now().Unix() + global.Conf.Jwt.ExpireTime}
rc.ResData = vo.TokenVo{
Token: token,
Expire: time.Now().Unix() + global.Conf.Jwt.ExpireTime,
}
}
// Login 用户登录
@@ -77,9 +81,9 @@ func (u *UserApi) Login(rc *restfulx.ReqCtx) {
})
biz.ErrIsNil(err, "生成Token失败")
rc.ResData = map[string]any{
"token": token,
"expire": time.Now().Unix() + global.Conf.Jwt.ExpireTime,
rc.ResData = vo.TokenVo{
Token: token,
Expire: time.Now().Unix() + global.Conf.Jwt.ExpireTime,
}
var loginLog logEntity.LogLogin
@@ -111,11 +115,11 @@ func (u *UserApi) Auth(rc *restfulx.ReqCtx) {
permis := u.RoleMenuApp.GetPermis(role.RoleId)
menus := u.MenuApp.SelectMenuRole(role.RoleKey)
rc.ResData = map[string]any{
"user": userData,
"role": role,
"permissions": permis,
"menus": Build(*menus),
rc.ResData = vo.AuthVo{
User: *userData,
Role: *role,
Permissions: permis,
Menus: Build(*menus),
}
}
@@ -156,11 +160,11 @@ func (u *UserApi) GetSysUserList(rc *restfulx.ReqCtx) {
}
list, total := u.UserApp.FindListPage(pageNum, pageSize, user)
rc.ResData = map[string]any{
"data": list,
"total": total,
"pageNum": pageNum,
"pageSize": pageSize,
rc.ResData = model.ResultPage{
Total: total,
PageNum: int64(pageNum),
PageSize: int64(pageNum),
Data: list,
}
}
@@ -184,13 +188,13 @@ func (u *UserApi) GetSysUserProfile(rc *restfulx.ReqCtx) {
roleIds := make([]int64, 0)
roleIds = append(roleIds, rc.LoginAccount.RoleId)
rc.ResData = map[string]any{
"data": user,
"postIds": postIds,
"roleIds": roleIds,
"roles": roleList,
"posts": postList,
"dept": deptList,
rc.ResData = vo.UserProfileVo{
Data: user,
PostIds: postIds,
RoleIds: roleIds,
Roles: *roleList,
Posts: *postList,
Dept: *deptList,
}
}
@@ -244,12 +248,12 @@ func (u *UserApi) GetSysUser(rc *restfulx.ReqCtx) {
}
posts := u.PostApp.FindList(post)
rc.ResData = map[string]any{
"data": result,
"postIds": result.PostIds,
"roleIds": result.RoleIds,
"roles": roles,
"posts": posts,
rc.ResData = vo.UserVo{
Data: result,
PostIds: result.PostIds,
RoleIds: result.RoleIds,
Roles: *roles,
Posts: *posts,
}
}
@@ -266,10 +270,10 @@ func (u *UserApi) GetSysUserInit(rc *restfulx.ReqCtx) {
post.TenantId = rc.LoginAccount.TenantId
}
posts := u.PostApp.FindList(post)
mp := make(map[string]any, 2)
mp["roles"] = roles
mp["posts"] = posts
rc.ResData = mp
rc.ResData = vo.UserRolePost{
Roles: *roles,
Posts: *posts,
}
}
// GetUserRolePost 获取添加用户角色和职位
@@ -289,10 +293,10 @@ func (u *UserApi) GetUserRolePost(rc *restfulx.ReqCtx) {
po := u.PostApp.FindOne(kgo.KConv.Str2Int64(postId))
posts = append(posts, *po)
}
mp := make(map[string]any, 2)
mp["roles"] = roles
mp["posts"] = posts
rc.ResData = mp
rc.ResData = vo.UserRolePost{
Roles: roles,
Posts: posts,
}
}
// InsertSysUser 创建用户

View File

@@ -0,0 +1,63 @@
package vo
import "pandax/apps/system/entity"
/**
* @Description
* @Author 熊猫
* @Date 2022/8/4 15:25
**/
type DeptTreeVo struct {
Depts []entity.DeptLable `json:"depts"`
CheckedKeys []int64 `json:"checkedKeys"`
}
type MenuTreeVo struct {
Menus []entity.MenuLable `json:"menus"`
CheckedKeys []int64 `json:"checkedKeys"`
}
type MenuPermisVo struct {
Menus []RouterVo `json:"menus"`
Permissions []string `json:"permissions"`
}
type CaptchaVo struct {
Base64Captcha string `json:"base64Captcha"`
CaptchaId string `json:"captchaId"`
}
type TokenVo struct {
Token string `json:"token"`
Expire int64 `json:"expire"`
}
type AuthVo struct {
User entity.SysUserView `json:"user"`
Role entity.SysRole `json:"role"`
Permissions []string `json:"permissions"`
Menus []RouterVo `json:"menus"`
}
type UserProfileVo struct {
Data any `json:"data"`
PostIds []int64 `json:"postIds"`
RoleIds []int64 `json:"roleIds"`
Roles []entity.SysRole `json:"roles"`
Posts []entity.SysPost `json:"posts"`
Dept []entity.SysDept `json:"dept"`
}
type UserVo struct {
Data any `json:"data"`
PostIds string `json:"postIds"`
RoleIds string `json:"roleIds"`
Roles []entity.SysRole `json:"roles"`
Posts []entity.SysPost `json:"posts"`
}
type UserRolePost struct {
Roles []entity.SysRole `json:"roles"`
Posts []entity.SysPost `json:"posts"`
}