项目目录优化,任务模块后端代码

This commit is contained in:
PandaGoAdmin
2021-12-23 17:23:27 +08:00
parent 0caf81660c
commit 21ff92a93c
67 changed files with 802 additions and 206 deletions

50
apps/system/router/api.go Normal file
View File

@@ -0,0 +1,50 @@
package router
import (
"github.com/gin-gonic/gin"
api2 "pandax/apps/system/api"
services2 "pandax/apps/system/services"
"pandax/base/ctx"
)
func InitApiRouter(router *gin.RouterGroup) {
s := &api2.SystemApiApi{
ApiApp: services2.SysSysApiModelDao,
}
api := router.Group("api")
apiListLog := ctx.NewLogInfo("获取api分页列表")
api.GET("list", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(apiListLog).Handle(s.GetApiList)
})
apiListAllLog := ctx.NewLogInfo("获取所有api")
api.GET("all", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(apiListAllLog).Handle(s.GetAllApis)
})
apiListByRoleLog := ctx.NewLogInfo("获取角色拥有的api权限")
api.GET("getPolicyPathByRoleId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(apiListByRoleLog).Handle(s.GetPolicyPathByRoleId)
})
apiLog := ctx.NewLogInfo("获取api信息")
api.GET(":id", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(apiLog).Handle(s.GetApiById)
})
insertApiLog := ctx.NewLogInfo("添加api信息")
api.POST("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(insertApiLog).Handle(s.CreateApi)
})
updateApiLog := ctx.NewLogInfo("修改api信息")
api.PUT("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(updateApiLog).Handle(s.UpdateApi)
})
deleteApiLog := ctx.NewLogInfo("删除api信息")
api.DELETE(":id", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(deleteApiLog).Handle(s.DeleteApi)
})
}

View File

@@ -0,0 +1,45 @@
package router
import (
"github.com/gin-gonic/gin"
api2 "pandax/apps/system/api"
services2 "pandax/apps/system/services"
"pandax/base/ctx"
)
func InitConfigRouter(router *gin.RouterGroup) {
s := &api2.ConfigApi{
ConfigApp: services2.SysSysConfigModelDao,
}
config := router.Group("config")
configListLog := ctx.NewLogInfo("获取配置分页列表")
config.GET("list", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(configListLog).Handle(s.GetConfigList)
})
configListByKeyLog := ctx.NewLogInfo("获取配置列表通过ConfigKey")
config.GET("configKey", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(configListByKeyLog).Handle(s.GetConfigListByKey)
})
configLog := ctx.NewLogInfo("获取配置信息")
config.GET(":configId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(configLog).Handle(s.GetConfig)
})
insertConfigLog := ctx.NewLogInfo("添加配置信息")
config.POST("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(insertConfigLog).Handle(s.InsertConfig)
})
updateConfigLog := ctx.NewLogInfo("修改配置信息")
config.PUT("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(updateConfigLog).Handle(s.UpdateConfig)
})
deleteConfigLog := ctx.NewLogInfo("删除配置信息")
config.DELETE(":configId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(deleteConfigLog).Handle(s.DeleteConfig)
})
}

View File

@@ -0,0 +1,52 @@
package router
import (
"github.com/gin-gonic/gin"
api2 "pandax/apps/system/api"
services2 "pandax/apps/system/services"
"pandax/base/ctx"
)
func InitDeptRouter(router *gin.RouterGroup) {
r := &api2.DeptApi{
DeptApp: services2.SysDeptModelDao,
RoleApp: services2.SysRoleModelDao,
UserApp: services2.SysUserModelDao,
}
dept := router.Group("dept")
roleDeptTreSelectLog := ctx.NewLogInfo("获取角色部门树")
dept.GET("roleDeptTreeSelect/:roleId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(roleDeptTreSelectLog).Handle(r.GetDeptTreeRoleSelect)
})
deptTreeLog := ctx.NewLogInfo("获取所有部门树")
dept.GET("deptTree", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(deptTreeLog).Handle(r.GetDeptTree)
})
deptListLog := ctx.NewLogInfo("获取部门列表")
dept.GET("list", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(deptListLog).Handle(r.GetDeptList)
})
deptLog := ctx.NewLogInfo("获取部门信息")
dept.GET(":deptId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(deptLog).Handle(r.GetDept)
})
inertDeptLog := ctx.NewLogInfo("添加部门信息")
dept.POST("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(inertDeptLog).Handle(r.InsertDept)
})
updateDeptLog := ctx.NewLogInfo("修改部门信息")
dept.PUT("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(updateDeptLog).Handle(r.UpdateDept)
})
deleteDeptLog := ctx.NewLogInfo("删除部门信息")
dept.DELETE(":deptId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(deleteDeptLog).Handle(r.DeleteDept)
})
}

View File

@@ -0,0 +1,77 @@
package router
import (
"github.com/gin-gonic/gin"
api2 "pandax/apps/system/api"
services2 "pandax/apps/system/services"
"pandax/base/ctx"
)
func InitDictRouter(router *gin.RouterGroup) {
s := &api2.DictApi{
DictType: services2.SysDictTypeModelDao,
DictData: services2.SysDictDataModelDao,
}
dict := router.Group("dict")
typeList := ctx.NewLogInfo("获取字典类型分页列表")
dict.GET("type/list", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(typeList).Handle(s.GetDictTypeList)
})
typeLog := ctx.NewLogInfo("获取字典类型信息")
dict.GET("type/:dictId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(typeLog).Handle(s.GetDictType)
})
insertTypeLog := ctx.NewLogInfo("添加字典类型信息")
dict.POST("type", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(insertTypeLog).Handle(s.InsertDictType)
})
updateTypeLog := ctx.NewLogInfo("修改字典类型信息")
dict.PUT("type", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(updateTypeLog).Handle(s.UpdateDictType)
})
deleteTypeLog := ctx.NewLogInfo("删除字典类型信息")
dict.DELETE("type/:dictId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(deleteTypeLog).Handle(s.DeleteDictType)
})
exportTypeLog := ctx.NewLogInfo("导出字典类型信息")
dict.GET("type/export", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(exportTypeLog).Handle(s.ExportDictType)
})
dataListLog := ctx.NewLogInfo("获取字典数据分页列表")
dict.GET("data/list", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(dataListLog).Handle(s.GetDictDataList)
})
dataListByDictTypeLog := ctx.NewLogInfo("获取字典数据列表通过字典类型")
dict.GET("data/type", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(dataListByDictTypeLog).Handle(s.GetDictDataListByDictType)
})
dataLog := ctx.NewLogInfo("获取字典数据信息")
dict.GET("data/:dictCode", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(dataLog).Handle(s.GetDictData)
})
insertDataLog := ctx.NewLogInfo("添加字典数据信息")
dict.POST("data", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(insertDataLog).Handle(s.InsertDictData)
})
updateDataLog := ctx.NewLogInfo("修改字典数据信息")
dict.PUT("data", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(updateDataLog).Handle(s.UpdateDictData)
})
deleteDataLog := ctx.NewLogInfo("删除字典数据信息")
dict.DELETE("data/:dictCode", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(deleteDataLog).Handle(s.DeleteDictData)
})
}

View File

@@ -0,0 +1,63 @@
package router
import (
"github.com/gin-gonic/gin"
api2 "pandax/apps/system/api"
services2 "pandax/apps/system/services"
"pandax/base/ctx"
)
func InitMenuRouter(router *gin.RouterGroup) {
s := &api2.MenuApi{
MenuApp: services2.SysMenuModelDao,
RoleApp: services2.SysRoleModelDao,
RoleMenuApp: services2.SysRoleMenuModelDao,
DeptApp: services2.SysDeptModelDao,
}
menu := router.Group("menu")
getSetRole := ctx.NewLogInfo("获取菜单树")
menu.GET("menuTreeSelect", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(getSetRole).WithNeedToken(false).WithNeedCasbin(false).Handle(s.GetMenuTreeSelect)
})
menuRole := ctx.NewLogInfo("获取角色菜单")
menu.GET("menuRole", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(menuRole).Handle(s.GetMenuRole)
})
roleMenuTreSelect := ctx.NewLogInfo("获取角色菜单树")
menu.GET("roleMenuTreeSelect/:roleId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(roleMenuTreSelect).Handle(s.GetMenuTreeRoleSelect)
})
menuPaths := ctx.NewLogInfo("获取角色菜单路径列表")
menu.GET("menuPaths", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(menuPaths).Handle(s.GetMenuPaths)
})
menuList := ctx.NewLogInfo("获取菜单列表")
menu.GET("list", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(menuList).Handle(s.GetMenuList)
})
menuLog := ctx.NewLogInfo("获取菜单信息")
menu.GET(":menuId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(menuLog).Handle(s.GetMenu)
})
insertMenuLog := ctx.NewLogInfo("添加菜单信息")
menu.POST("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(insertMenuLog).Handle(s.InsertMenu)
})
updateMenuLog := ctx.NewLogInfo("修改菜单信息")
menu.PUT("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(updateMenuLog).Handle(s.UpdateMenu)
})
deleteMenuLog := ctx.NewLogInfo("删除菜单信息")
menu.DELETE(":menuId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(deleteMenuLog).Handle(s.DeleteMenu)
})
}

View File

@@ -0,0 +1,42 @@
package router
import (
"github.com/gin-gonic/gin"
api2 "pandax/apps/system/api"
services2 "pandax/apps/system/services"
"pandax/base/ctx"
)
func InitPostRouter(router *gin.RouterGroup) {
s := &api2.PostApi{
PostApp: services2.SysPostModelDao,
UserApp: services2.SysUserModelDao,
RoleApp: services2.SysRoleModelDao,
}
post := router.Group("post")
postList := ctx.NewLogInfo("获取岗位分页列表")
post.GET("list", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(postList).Handle(s.GetPostList)
})
postLog := ctx.NewLogInfo("获取岗位信息")
post.GET(":postId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(postLog).Handle(s.GetPost)
})
insertPostLog := ctx.NewLogInfo("添加岗位信息")
post.POST("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(insertPostLog).Handle(s.InsertPost)
})
updatePostLog := ctx.NewLogInfo("修改岗位信息")
post.PUT("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(updatePostLog).Handle(s.UpdatePost)
})
deletePostLog := ctx.NewLogInfo("删除岗位信息")
post.DELETE(":postId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(deletePostLog).Handle(s.DeletePost)
})
}

View File

@@ -0,0 +1,57 @@
package router
import (
"github.com/gin-gonic/gin"
api2 "pandax/apps/system/api"
services2 "pandax/apps/system/services"
"pandax/base/ctx"
)
func InitRoleRouter(router *gin.RouterGroup) {
s := &api2.RoleApi{
RoleApp: services2.SysRoleModelDao,
RoleMenuApp: services2.SysRoleMenuModelDao,
RoleDeptApp: services2.SysRoleDeptModelDao,
UserApp: services2.SysUserModelDao,
}
role := router.Group("role")
roleListLog := ctx.NewLogInfo("获取角色分页列表")
role.GET("list", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(roleListLog).Handle(s.GetRoleList)
})
roleLog := ctx.NewLogInfo("获取角色信息")
role.GET(":roleId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(roleLog).Handle(s.GetRole)
})
insertRoleLog := ctx.NewLogInfo("添加角色信息")
role.POST("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(insertRoleLog).Handle(s.InsertRole)
})
updateRoleLog := ctx.NewLogInfo("修改角色信息")
role.PUT("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(updateRoleLog).Handle(s.UpdateRole)
})
updateStaRoleLog := ctx.NewLogInfo("修改角色状态")
role.PUT("changeStatus", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(updateStaRoleLog).Handle(s.UpdateRoleStatus)
})
updateDaSRoleLog := ctx.NewLogInfo("修改角色部门权限")
role.PUT("dataScope", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(updateDaSRoleLog).Handle(s.UpdateRoleDataScope)
})
deleteRoleLog := ctx.NewLogInfo("删除角色信息")
role.DELETE(":roleId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(deleteRoleLog).Handle(s.DeleteRole)
})
exportRoleLog := ctx.NewLogInfo("导出角色信息")
role.GET("export", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(exportRoleLog).Handle(s.ExportRole)
})
}

View File

@@ -0,0 +1,16 @@
package router
import (
"github.com/gin-gonic/gin"
api2 "pandax/apps/system/api"
)
func InitSystemRouter(router *gin.RouterGroup) {
s := &api2.System{}
sys := router.Group("")
{
sys.GET("", s.ConnectWs)
sys.GET("server", s.ServerInfo)
}
}

View File

@@ -0,0 +1,88 @@
package router
import (
"github.com/gin-gonic/gin"
api2 "pandax/apps/system/api"
services2 "pandax/apps/system/services"
"pandax/base/ctx"
)
func InitUserRouter(router *gin.RouterGroup) {
s := &api2.UserApi{
RoleApp: services2.SysRoleModelDao,
MenuApp: services2.SysMenuModelDao,
RoleMenuApp: services2.SysRoleMenuModelDao,
UserApp: services2.SysUserModelDao,
LogLogin: services2.LogLoginModelDao,
DeptApp: services2.SysDeptModelDao,
PostApp: services2.SysPostModelDao,
}
user := router.Group("user")
// 获取验证码
user.GET("getCaptcha", s.GenerateCaptcha)
loginLog := ctx.NewLogInfo("登录")
user.POST("login", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(loginLog).WithNeedToken(false).WithNeedCasbin(false).Handle(s.Login)
})
logoutLog := ctx.NewLogInfo("退出登录")
user.POST("logout", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(logoutLog).WithNeedToken(false).WithNeedCasbin(false).Handle(s.LogOut)
})
sysUserListLog := ctx.NewLogInfo("得到用户分页列表")
user.GET("list", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(sysUserListLog).Handle(s.GetSysUserList)
})
avatarLog := ctx.NewLogInfo("修改用户头像")
user.POST("avatar", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(avatarLog).Handle(s.InsetSysUserAvatar)
})
pwdLog := ctx.NewLogInfo("修改用户密码")
user.PUT("pwd", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(pwdLog).Handle(s.SysUserUpdatePwd)
})
userLog := ctx.NewLogInfo("获取用户信息")
user.GET("getById/:userId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(userLog).Handle(s.GetSysUser)
})
getSysUserInitLog := ctx.NewLogInfo("获取初始化角色岗位信息(添加用户初始化)")
user.GET("getInit", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(getSysUserInitLog).Handle(s.GetSysUserInit)
})
getSysUserRoPoLog := ctx.NewLogInfo("获取用户角色岗位信息(添加用户初始化)")
user.GET("getRoPo", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(getSysUserRoPoLog).Handle(s.GetUserRolePost)
})
insertUserLog := ctx.NewLogInfo("添加用户信息")
user.POST("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(insertUserLog).Handle(s.InsertSysUser)
})
updateUserLog := ctx.NewLogInfo("修改用户信息")
user.PUT("", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(updateUserLog).Handle(s.UpdateSysUser)
})
updateUserStuLog := ctx.NewLogInfo("修改用户状态")
user.PUT("changeStatus", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(updateUserStuLog).Handle(s.UpdateSysUserStu)
})
deleteUserLog := ctx.NewLogInfo("删除用户信息")
user.DELETE(":userId", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(deleteUserLog).Handle(s.DeleteSysUser)
})
exportUserLog := ctx.NewLogInfo("导出用户信息")
user.GET("export", func(c *gin.Context) {
ctx.NewReqCtxWithGin(c).WithLog(exportUserLog).Handle(s.ExportUser)
})
}