mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-24 03:18:35 +08:00
项目目录优化,任务模块后端代码
This commit is contained in:
@@ -2,8 +2,8 @@ package api
|
||||
|
||||
import (
|
||||
"log"
|
||||
entity2 "pandax/apps/system/entity"
|
||||
services2 "pandax/apps/system/services"
|
||||
entity "pandax/apps/system/entity"
|
||||
services "pandax/apps/system/services"
|
||||
"pandax/base/casbin"
|
||||
"pandax/base/ctx"
|
||||
"pandax/base/ginx"
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
type SystemApiApi struct {
|
||||
ApiApp services2.SysApiModel
|
||||
ApiApp services.SysApiModel
|
||||
}
|
||||
|
||||
// @Tags SysApi
|
||||
@@ -23,7 +23,7 @@ type SystemApiApi struct {
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
|
||||
// @Router /system/api [post]
|
||||
func (s *SystemApiApi) CreateApi(rc *ctx.ReqCtx) {
|
||||
var api entity2.SysApi
|
||||
var api entity.SysApi
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &api)
|
||||
log.Println(api)
|
||||
s.ApiApp.Insert(api)
|
||||
@@ -61,7 +61,7 @@ func (s *SystemApiApi) GetApiList(rc *ctx.ReqCtx) {
|
||||
description := rc.GinCtx.Query("description")
|
||||
method := rc.GinCtx.Query("method")
|
||||
apiGroup := rc.GinCtx.Query("apiGroup")
|
||||
api := entity2.SysApi{Path: path, Description: description, Method: method, ApiGroup: apiGroup}
|
||||
api := entity.SysApi{Path: path, Description: description, Method: method, ApiGroup: apiGroup}
|
||||
list, total := s.ApiApp.FindListPage(pageNum, pageSize, api)
|
||||
rc.ResData = map[string]interface{}{
|
||||
"data": list,
|
||||
@@ -94,7 +94,7 @@ func (s *SystemApiApi) GetApiById(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
|
||||
// @Router /api/api [put]
|
||||
func (s *SystemApiApi) UpdateApi(rc *ctx.ReqCtx) {
|
||||
var api entity2.SysApi
|
||||
var api entity.SysApi
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &api)
|
||||
s.ApiApp.Update(api)
|
||||
}
|
||||
@@ -107,7 +107,7 @@ func (s *SystemApiApi) UpdateApi(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /system/api/all [get]
|
||||
func (s *SystemApiApi) GetAllApis(rc *ctx.ReqCtx) {
|
||||
rc.ResData = s.ApiApp.FindList(entity2.SysApi{})
|
||||
rc.ResData = s.ApiApp.FindList(entity.SysApi{})
|
||||
}
|
||||
|
||||
// @Tags SysApi
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
entity2 "pandax/apps/system/entity"
|
||||
services2 "pandax/apps/system/services"
|
||||
entity "pandax/apps/system/entity"
|
||||
services "pandax/apps/system/services"
|
||||
"pandax/base/biz"
|
||||
"pandax/base/ctx"
|
||||
"pandax/base/ginx"
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type ConfigApi struct {
|
||||
ConfigApp services2.SysConfigModel
|
||||
ConfigApp services.SysConfigModel
|
||||
}
|
||||
|
||||
// @Summary 配置列表数据
|
||||
@@ -30,7 +30,7 @@ func (p *ConfigApi) GetConfigList(rc *ctx.ReqCtx) {
|
||||
configName := rc.GinCtx.Query("configName")
|
||||
configKey := rc.GinCtx.Query("configKey")
|
||||
configType := rc.GinCtx.Query("configType")
|
||||
config := entity2.SysConfig{ConfigName: configName, ConfigKey: configKey, ConfigType: configType}
|
||||
config := entity.SysConfig{ConfigName: configName, ConfigKey: configKey, ConfigType: configType}
|
||||
list, total := p.ConfigApp.FindListPage(pageNum, pageSize, config)
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
@@ -51,7 +51,7 @@ func (p *ConfigApi) GetConfigList(rc *ctx.ReqCtx) {
|
||||
func (p *ConfigApi) GetConfigListByKey(rc *ctx.ReqCtx) {
|
||||
configKey := rc.GinCtx.Query("configKey")
|
||||
biz.IsTrue(configKey != "", "请传入配置Key")
|
||||
rc.ResData = p.ConfigApp.FindList(entity2.SysConfig{ConfigKey: configKey})
|
||||
rc.ResData = p.ConfigApp.FindList(entity.SysConfig{ConfigKey: configKey})
|
||||
}
|
||||
|
||||
// @Summary 获取配置
|
||||
@@ -77,7 +77,7 @@ func (p *ConfigApi) GetConfig(rc *ctx.ReqCtx) {
|
||||
// @Router /system/config [post]
|
||||
// @Security X-TOKEN
|
||||
func (p *ConfigApi) InsertConfig(rc *ctx.ReqCtx) {
|
||||
var config entity2.SysConfig
|
||||
var config entity.SysConfig
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &config)
|
||||
|
||||
p.ConfigApp.Insert(config)
|
||||
@@ -94,7 +94,7 @@ func (p *ConfigApi) InsertConfig(rc *ctx.ReqCtx) {
|
||||
// @Router /system/config [put]
|
||||
// @Security X-TOKEN
|
||||
func (p *ConfigApi) UpdateConfig(rc *ctx.ReqCtx) {
|
||||
var post entity2.SysConfig
|
||||
var post entity.SysConfig
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &post)
|
||||
p.ConfigApp.Update(post)
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package api
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
entity2 "pandax/apps/system/entity"
|
||||
services2 "pandax/apps/system/services"
|
||||
entity "pandax/apps/system/entity"
|
||||
services "pandax/apps/system/services"
|
||||
"pandax/base/biz"
|
||||
"pandax/base/ctx"
|
||||
"pandax/base/ginx"
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
)
|
||||
|
||||
type DeptApi struct {
|
||||
DeptApp services2.SysDeptModel
|
||||
UserApp services2.SysUserModel
|
||||
RoleApp services2.SysRoleModel
|
||||
DeptApp services.SysDeptModel
|
||||
UserApp services.SysUserModel
|
||||
RoleApp services.SysRoleModel
|
||||
}
|
||||
|
||||
// @Summary 获取角色的部门树
|
||||
@@ -29,11 +29,11 @@ type DeptApi struct {
|
||||
func (m *DeptApi) GetDeptTreeRoleSelect(rc *ctx.ReqCtx) {
|
||||
roleId := ginx.PathParamInt(rc.GinCtx, "roleId")
|
||||
|
||||
result := m.DeptApp.SelectDeptLable(entity2.SysDept{})
|
||||
result := m.DeptApp.SelectDeptLable(entity.SysDept{})
|
||||
|
||||
deptIds := make([]int64, 0)
|
||||
if roleId != 0 {
|
||||
deptIds = m.RoleApp.GetRoleDeptId(entity2.SysRole{RoleId: int64(roleId)})
|
||||
deptIds = m.RoleApp.GetRoleDeptId(entity.SysRole{RoleId: int64(roleId)})
|
||||
}
|
||||
rc.ResData = map[string]interface{}{
|
||||
"depts": result,
|
||||
@@ -56,7 +56,7 @@ func (a *DeptApi) GetDeptList(rc *ctx.ReqCtx) {
|
||||
deptName := rc.GinCtx.Query("deptName")
|
||||
status := rc.GinCtx.Query("status")
|
||||
deptId := ginx.QueryInt(rc.GinCtx, "deptId", 0)
|
||||
dept := entity2.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)}
|
||||
dept := entity.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)}
|
||||
|
||||
if dept.DeptName == "" {
|
||||
rc.ResData = a.DeptApp.SelectDept(dept)
|
||||
@@ -72,7 +72,7 @@ func (a *DeptApi) GetDeptList(rc *ctx.ReqCtx) {
|
||||
// @Router /system/dept/ordinaryDeptLis [get]
|
||||
// @Security
|
||||
func (a *DeptApi) GetOrdinaryDeptList(rc *ctx.ReqCtx) {
|
||||
rc.ResData = a.DeptApp.FindList(entity2.SysDept{})
|
||||
rc.ResData = a.DeptApp.FindList(entity.SysDept{})
|
||||
}
|
||||
|
||||
// @Summary 所有部门树数据
|
||||
@@ -88,7 +88,7 @@ func (a *DeptApi) GetDeptTree(rc *ctx.ReqCtx) {
|
||||
deptName := rc.GinCtx.Query("deptName")
|
||||
status := rc.GinCtx.Query("status")
|
||||
deptId := ginx.QueryInt(rc.GinCtx, "deptId", 0)
|
||||
dept := entity2.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)}
|
||||
dept := entity.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)}
|
||||
|
||||
rc.ResData = a.DeptApp.SelectDept(dept)
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func (a *DeptApi) GetDept(rc *ctx.ReqCtx) {
|
||||
// @Router /system/dept [post]
|
||||
// @Security Bearer
|
||||
func (a *DeptApi) InsertDept(rc *ctx.ReqCtx) {
|
||||
var dept entity2.SysDept
|
||||
var dept entity.SysDept
|
||||
g := rc.GinCtx
|
||||
ginx.BindJsonAndValid(g, &dept)
|
||||
|
||||
@@ -135,7 +135,7 @@ func (a *DeptApi) InsertDept(rc *ctx.ReqCtx) {
|
||||
// @Router /system/dept [put]
|
||||
// @Security Bearer
|
||||
func (a *DeptApi) UpdateDept(rc *ctx.ReqCtx) {
|
||||
var dept entity2.SysDept
|
||||
var dept entity.SysDept
|
||||
g := rc.GinCtx
|
||||
ginx.BindJsonAndValid(g, &dept)
|
||||
|
||||
@@ -156,7 +156,7 @@ func (a *DeptApi) DeleteDept(rc *ctx.ReqCtx) {
|
||||
|
||||
deList := make([]int64, 0)
|
||||
for _, id := range deptIds {
|
||||
user := entity2.SysUser{}
|
||||
user := entity.SysUser{}
|
||||
user.DeptId = id
|
||||
list := a.UserApp.FindList(user)
|
||||
if len(*list) == 0 {
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"github.com/kakuilan/kgo"
|
||||
"os"
|
||||
entity2 "pandax/apps/system/entity"
|
||||
services2 "pandax/apps/system/services"
|
||||
entity "pandax/apps/system/entity"
|
||||
services "pandax/apps/system/services"
|
||||
"pandax/base/biz"
|
||||
"pandax/base/config"
|
||||
"pandax/base/ctx"
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
)
|
||||
|
||||
type DictApi struct {
|
||||
DictType services2.SysDictTypeModel
|
||||
DictData services2.SysDictDataModel
|
||||
DictType services.SysDictTypeModel
|
||||
DictData services.SysDictDataModel
|
||||
}
|
||||
|
||||
// @Summary 字典类型列表数据
|
||||
@@ -37,7 +37,7 @@ func (p *DictApi) GetDictTypeList(rc *ctx.ReqCtx) {
|
||||
dictName := rc.GinCtx.Query("dictName")
|
||||
dictType := rc.GinCtx.Query("dictType")
|
||||
|
||||
list, total := p.DictType.FindListPage(pageNum, pageSize, entity2.SysDictType{Status: status, DictName: dictName, DictType: dictType})
|
||||
list, total := p.DictType.FindListPage(pageNum, pageSize, entity.SysDictType{Status: status, DictName: dictName, DictType: dictType})
|
||||
rc.ResData = map[string]interface{}{
|
||||
"data": list,
|
||||
"total": total,
|
||||
@@ -69,7 +69,7 @@ func (p *DictApi) GetDictType(rc *ctx.ReqCtx) {
|
||||
// @Router /system/dict/type [post]
|
||||
// @Security X-TOKEN
|
||||
func (p *DictApi) InsertDictType(rc *ctx.ReqCtx) {
|
||||
var dict entity2.SysDictType
|
||||
var dict entity.SysDictType
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &dict)
|
||||
|
||||
dict.CreateBy = rc.LoginAccount.UserName
|
||||
@@ -87,7 +87,7 @@ func (p *DictApi) InsertDictType(rc *ctx.ReqCtx) {
|
||||
// @Router /system/dict/type [put]
|
||||
// @Security X-TOKEN
|
||||
func (p *DictApi) UpdateDictType(rc *ctx.ReqCtx) {
|
||||
var dict entity2.SysDictType
|
||||
var dict entity.SysDictType
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &dict)
|
||||
|
||||
dict.CreateBy = rc.LoginAccount.UserName
|
||||
@@ -108,7 +108,7 @@ func (p *DictApi) DeleteDictType(rc *ctx.ReqCtx) {
|
||||
deList := make([]int64, 0)
|
||||
for _, id := range dictIds {
|
||||
one := p.DictType.FindOne(id)
|
||||
list := p.DictData.FindList(entity2.SysDictData{DictType: one.DictType})
|
||||
list := p.DictData.FindList(entity.SysDictData{DictType: one.DictType})
|
||||
if len(*list) == 0 {
|
||||
deList = append(deList, id)
|
||||
} else {
|
||||
@@ -132,7 +132,7 @@ func (p *DictApi) ExportDictType(rc *ctx.ReqCtx) {
|
||||
dictName := rc.GinCtx.Query("dictName")
|
||||
dictType := rc.GinCtx.Query("dictType")
|
||||
|
||||
list := p.DictType.FindList(entity2.SysDictType{Status: status, DictName: dictName, DictType: dictType})
|
||||
list := p.DictType.FindList(entity.SysDictType{Status: status, DictName: dictName, DictType: dictType})
|
||||
fileName := utils.GetFileName(config.Conf.Server.ExcelDir, "字典")
|
||||
utils.InterfaceToExcel(*list, fileName)
|
||||
|
||||
@@ -157,7 +157,7 @@ func (p *DictApi) GetDictDataList(rc *ctx.ReqCtx) {
|
||||
dictLabel := rc.GinCtx.Query("dictLabel")
|
||||
dictType := rc.GinCtx.Query("dictType")
|
||||
status := rc.GinCtx.Query("status")
|
||||
rc.ResData = p.DictData.FindList(entity2.SysDictData{Status: status, DictType: dictType, DictLabel: dictLabel})
|
||||
rc.ResData = p.DictData.FindList(entity.SysDictData{Status: status, DictType: dictType, DictLabel: dictLabel})
|
||||
}
|
||||
|
||||
// @Summary 字典数据获取
|
||||
@@ -170,7 +170,7 @@ func (p *DictApi) GetDictDataList(rc *ctx.ReqCtx) {
|
||||
func (p *DictApi) GetDictDataListByDictType(rc *ctx.ReqCtx) {
|
||||
dictType := rc.GinCtx.Query("dictType")
|
||||
biz.IsTrue(dictType != "", "请传入字典类型")
|
||||
rc.ResData = p.DictData.FindList(entity2.SysDictData{DictType: dictType})
|
||||
rc.ResData = p.DictData.FindList(entity.SysDictData{DictType: dictType})
|
||||
}
|
||||
|
||||
// @Summary 获取字典数据
|
||||
@@ -196,7 +196,7 @@ func (p *DictApi) GetDictData(rc *ctx.ReqCtx) {
|
||||
// @Router /system/dict/data [post]
|
||||
// @Security X-TOKEN
|
||||
func (p *DictApi) InsertDictData(rc *ctx.ReqCtx) {
|
||||
var data entity2.SysDictData
|
||||
var data entity.SysDictData
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &data)
|
||||
|
||||
data.CreateBy = rc.LoginAccount.UserName
|
||||
@@ -214,7 +214,7 @@ func (p *DictApi) InsertDictData(rc *ctx.ReqCtx) {
|
||||
// @Router /system/dict/data [put]
|
||||
// @Security X-TOKEN
|
||||
func (p *DictApi) UpdateDictData(rc *ctx.ReqCtx) {
|
||||
var data entity2.SysDictData
|
||||
var data entity.SysDictData
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &data)
|
||||
|
||||
data.CreateBy = rc.LoginAccount.UserName
|
||||
|
||||
@@ -2,19 +2,19 @@ package api
|
||||
|
||||
import (
|
||||
"log"
|
||||
entity2 "pandax/apps/system/entity"
|
||||
services2 "pandax/apps/system/services"
|
||||
entity "pandax/apps/system/entity"
|
||||
services "pandax/apps/system/services"
|
||||
"pandax/base/biz"
|
||||
"pandax/base/ctx"
|
||||
"pandax/base/ginx"
|
||||
)
|
||||
|
||||
type MenuApi struct {
|
||||
MenuApp services2.SysMenuModel
|
||||
DeptApp services2.SysDeptModel
|
||||
MenuApp services.SysMenuModel
|
||||
DeptApp services.SysDeptModel
|
||||
|
||||
RoleMenuApp services2.SysRoleMenuModel
|
||||
RoleApp services2.SysRoleModel
|
||||
RoleMenuApp services.SysRoleMenuModel
|
||||
RoleApp services.SysRoleModel
|
||||
}
|
||||
|
||||
// @Summary 获取菜单树
|
||||
@@ -25,7 +25,7 @@ type MenuApi struct {
|
||||
// @Router /system/menu/menuTreSelect [get]
|
||||
// @Security X-TOKEN
|
||||
func (m *MenuApi) GetMenuTreeSelect(rc *ctx.ReqCtx) {
|
||||
lable := m.MenuApp.SelectMenuLable(entity2.SysMenu{})
|
||||
lable := m.MenuApp.SelectMenuLable(entity.SysMenu{})
|
||||
rc.ResData = lable
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ func (m *MenuApi) GetMenuRole(rc *ctx.ReqCtx) {
|
||||
func (m *MenuApi) GetMenuTreeRoleSelect(rc *ctx.ReqCtx) {
|
||||
roleId := ginx.PathParamInt(rc.GinCtx, "roleId")
|
||||
|
||||
result := m.MenuApp.SelectMenuLable(entity2.SysMenu{})
|
||||
result := m.MenuApp.SelectMenuLable(entity.SysMenu{})
|
||||
menuIds := make([]int64, 0)
|
||||
if roleId != 0 {
|
||||
menuIds = m.RoleApp.GetRoleMeunId(entity2.SysRole{RoleId: int64(roleId)})
|
||||
menuIds = m.RoleApp.GetRoleMeunId(entity.SysRole{RoleId: int64(roleId)})
|
||||
}
|
||||
rc.ResData = map[string]interface{}{
|
||||
"menus": result,
|
||||
@@ -73,7 +73,7 @@ func (m *MenuApi) GetMenuTreeRoleSelect(rc *ctx.ReqCtx) {
|
||||
func (m *MenuApi) GetMenuPaths(rc *ctx.ReqCtx) {
|
||||
roleKey := rc.GinCtx.Query("roleKey")
|
||||
biz.IsTrue(roleKey != "", "请传入角色Key")
|
||||
rc.ResData = m.RoleMenuApp.GetMenuPaths(entity2.SysRoleMenu{RoleName: roleKey})
|
||||
rc.ResData = m.RoleMenuApp.GetMenuPaths(entity.SysRoleMenu{RoleName: roleKey})
|
||||
}
|
||||
|
||||
// @Summary Menu列表数据
|
||||
@@ -90,7 +90,7 @@ func (m *MenuApi) GetMenuList(rc *ctx.ReqCtx) {
|
||||
menuName := rc.GinCtx.Query("menuName")
|
||||
status := rc.GinCtx.Query("status")
|
||||
|
||||
menu := entity2.SysMenu{MenuName: menuName, Status: status}
|
||||
menu := entity.SysMenu{MenuName: menuName, Status: status}
|
||||
log.Println(menuName)
|
||||
if menu.MenuName == "" {
|
||||
rc.ResData = m.MenuApp.SelectMenu(menu)
|
||||
@@ -122,7 +122,7 @@ func (m *MenuApi) GetMenu(rc *ctx.ReqCtx) {
|
||||
// @Router /system/menu [post]
|
||||
// @Security X-TOKEN
|
||||
func (m *MenuApi) InsertMenu(rc *ctx.ReqCtx) {
|
||||
var menu entity2.SysMenu
|
||||
var menu entity.SysMenu
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &menu)
|
||||
menu.CreateBy = rc.LoginAccount.UserName
|
||||
m.MenuApp.Insert(menu)
|
||||
@@ -143,7 +143,7 @@ func (m *MenuApi) InsertMenu(rc *ctx.ReqCtx) {
|
||||
// @Router /system/menu [put]
|
||||
// @Security X-TOKEN
|
||||
func (m *MenuApi) UpdateMenu(rc *ctx.ReqCtx) {
|
||||
var menu entity2.SysMenu
|
||||
var menu entity.SysMenu
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &menu)
|
||||
menu.UpdateBy = rc.LoginAccount.UserName
|
||||
m.MenuApp.Update(menu)
|
||||
|
||||
@@ -3,8 +3,8 @@ package api
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
entity2 "pandax/apps/system/entity"
|
||||
services2 "pandax/apps/system/services"
|
||||
entity "pandax/apps/system/entity"
|
||||
services "pandax/apps/system/services"
|
||||
"pandax/base/biz"
|
||||
"pandax/base/ctx"
|
||||
"pandax/base/ginx"
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
)
|
||||
|
||||
type PostApi struct {
|
||||
PostApp services2.SysPostModel
|
||||
UserApp services2.SysUserModel
|
||||
RoleApp services2.SysRoleModel
|
||||
PostApp services.SysPostModel
|
||||
UserApp services.SysUserModel
|
||||
RoleApp services.SysRoleModel
|
||||
}
|
||||
|
||||
// @Summary 职位列表数据
|
||||
@@ -36,7 +36,7 @@ func (p *PostApi) GetPostList(rc *ctx.ReqCtx) {
|
||||
status := rc.GinCtx.Query("status")
|
||||
postName := rc.GinCtx.Query("postName")
|
||||
postCode := rc.GinCtx.Query("postCode")
|
||||
post := entity2.SysPost{Status: status, PostName: postName, PostCode: postCode}
|
||||
post := entity.SysPost{Status: status, PostName: postName, PostCode: postCode}
|
||||
list, total := p.PostApp.FindListPage(pageNum, pageSize, post)
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
@@ -70,7 +70,7 @@ func (p *PostApi) GetPost(rc *ctx.ReqCtx) {
|
||||
// @Router /system/post [post]
|
||||
// @Security X-TOKEN
|
||||
func (p *PostApi) InsertPost(rc *ctx.ReqCtx) {
|
||||
var post entity2.SysPost
|
||||
var post entity.SysPost
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &post)
|
||||
|
||||
post.CreateBy = rc.LoginAccount.UserName
|
||||
@@ -88,7 +88,7 @@ func (p *PostApi) InsertPost(rc *ctx.ReqCtx) {
|
||||
// @Router /system/post [put]
|
||||
// @Security X-TOKEN
|
||||
func (p *PostApi) UpdatePost(rc *ctx.ReqCtx) {
|
||||
var post entity2.SysPost
|
||||
var post entity.SysPost
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &post)
|
||||
|
||||
post.CreateBy = rc.LoginAccount.UserName
|
||||
@@ -109,7 +109,7 @@ func (p *PostApi) DeletePost(rc *ctx.ReqCtx) {
|
||||
|
||||
deList := make([]int64, 0)
|
||||
for _, id := range postIds {
|
||||
user := entity2.SysUser{}
|
||||
user := entity.SysUser{}
|
||||
user.PostId = id
|
||||
list := p.UserApp.FindList(user)
|
||||
if len(*list) == 0 {
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
"github.com/kakuilan/kgo"
|
||||
"os"
|
||||
entity2 "pandax/apps/system/entity"
|
||||
services2 "pandax/apps/system/services"
|
||||
entity "pandax/apps/system/entity"
|
||||
services "pandax/apps/system/services"
|
||||
"pandax/base/biz"
|
||||
"pandax/base/casbin"
|
||||
"pandax/base/config"
|
||||
@@ -17,10 +17,10 @@ import (
|
||||
)
|
||||
|
||||
type RoleApi struct {
|
||||
RoleApp services2.SysRoleModel
|
||||
UserApp services2.SysUserModel
|
||||
RoleMenuApp services2.SysRoleMenuModel
|
||||
RoleDeptApp services2.SysRoleDeptModel
|
||||
RoleApp services.SysRoleModel
|
||||
UserApp services.SysUserModel
|
||||
RoleMenuApp services.SysRoleMenuModel
|
||||
RoleDeptApp services.SysRoleDeptModel
|
||||
}
|
||||
|
||||
// @Summary 角色列表数据
|
||||
@@ -41,7 +41,7 @@ func (r *RoleApi) GetRoleList(rc *ctx.ReqCtx) {
|
||||
roleName := rc.GinCtx.Query("roleName")
|
||||
roleKey := rc.GinCtx.Query("roleKey")
|
||||
|
||||
role := entity2.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey}
|
||||
role := entity.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey}
|
||||
list, total := r.RoleApp.FindListPage(pageNum, pageSize, role)
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
@@ -63,7 +63,7 @@ func (r *RoleApi) GetRoleList(rc *ctx.ReqCtx) {
|
||||
func (r *RoleApi) GetRole(rc *ctx.ReqCtx) {
|
||||
roleId := ginx.PathParamInt(rc.GinCtx, "roleId")
|
||||
role := r.RoleApp.FindOne(int64(roleId))
|
||||
role.MenuIds = r.RoleApp.GetRoleMeunId(entity2.SysRole{RoleId: int64(roleId)})
|
||||
role.MenuIds = r.RoleApp.GetRoleMeunId(entity.SysRole{RoleId: int64(roleId)})
|
||||
|
||||
rc.ResData = role
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func (r *RoleApi) GetRole(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
|
||||
// @Router /system/role [post]
|
||||
func (r *RoleApi) InsertRole(rc *ctx.ReqCtx) {
|
||||
var role entity2.SysRole
|
||||
var role entity.SysRole
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &role)
|
||||
role.CreateBy = rc.LoginAccount.UserName
|
||||
insert := r.RoleApp.Insert(role)
|
||||
@@ -98,7 +98,7 @@ func (r *RoleApi) InsertRole(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 400, "message": "修改失败"}"
|
||||
// @Router /system/role [put]
|
||||
func (r *RoleApi) UpdateRole(rc *ctx.ReqCtx) {
|
||||
var role entity2.SysRole
|
||||
var role entity.SysRole
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &role)
|
||||
role.UpdateBy = rc.LoginAccount.UserName
|
||||
// 修改角色
|
||||
@@ -121,7 +121,7 @@ func (r *RoleApi) UpdateRole(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 400, "message": "修改失败"}"
|
||||
// @Router /system/role/changeStatus [put]
|
||||
func (r *RoleApi) UpdateRoleStatus(rc *ctx.ReqCtx) {
|
||||
var role entity2.SysRole
|
||||
var role entity.SysRole
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &role)
|
||||
role.UpdateBy = rc.LoginAccount.UserName
|
||||
// 修改角色
|
||||
@@ -138,14 +138,14 @@ func (r *RoleApi) UpdateRoleStatus(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 400, "message": "修改失败"}"
|
||||
// @Router /system/role/dataScope [put]
|
||||
func (r *RoleApi) UpdateRoleDataScope(rc *ctx.ReqCtx) {
|
||||
var role entity2.SysRole
|
||||
var role entity.SysRole
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &role)
|
||||
role.UpdateBy = rc.LoginAccount.UserName
|
||||
// 修改角色
|
||||
update := r.RoleApp.Update(role)
|
||||
if role.DataScope == "2" {
|
||||
// 删除角色的部门绑定
|
||||
r.RoleDeptApp.Delete(entity2.SysRoleDept{RoleId: update.RoleId})
|
||||
r.RoleDeptApp.Delete(entity.SysRoleDept{RoleId: update.RoleId})
|
||||
// 添加角色部门绑定
|
||||
r.RoleDeptApp.Insert(role.RoleId, role.DeptIds)
|
||||
}
|
||||
@@ -162,7 +162,7 @@ func (r *RoleApi) DeleteRole(rc *ctx.ReqCtx) {
|
||||
roleId := rc.GinCtx.Param("roleId")
|
||||
roleIds := utils.IdsStrToIdsIntGroup(roleId)
|
||||
|
||||
user := entity2.SysUser{}
|
||||
user := entity.SysUser{}
|
||||
delList := make([]int64, 0)
|
||||
// 判断角色下面是否绑定用户
|
||||
for _, rid := range roleIds {
|
||||
@@ -198,7 +198,7 @@ func (p *RoleApi) ExportRole(rc *ctx.ReqCtx) {
|
||||
roleName := rc.GinCtx.Query("roleName")
|
||||
roleKey := rc.GinCtx.Query("roleKey")
|
||||
|
||||
list := p.RoleApp.FindList(entity2.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey})
|
||||
list := p.RoleApp.FindList(entity.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey})
|
||||
fileName := utils.GetFileName(config.Conf.Server.ExcelDir, "角色")
|
||||
utils.InterfaceToExcel(*list, fileName)
|
||||
|
||||
|
||||
@@ -7,10 +7,14 @@ import (
|
||||
"github.com/mssola/user_agent"
|
||||
"net/http"
|
||||
"os"
|
||||
form2 "pandax/apps/system/api/form"
|
||||
vo2 "pandax/apps/system/api/vo"
|
||||
entity2 "pandax/apps/system/entity"
|
||||
services2 "pandax/apps/system/services"
|
||||
"pandax/apps/system/api/form"
|
||||
"pandax/apps/system/api/vo"
|
||||
"pandax/apps/system/entity"
|
||||
|
||||
logEntity "pandax/apps/log/entity"
|
||||
logServices "pandax/apps/log/services"
|
||||
|
||||
"pandax/apps/system/services"
|
||||
"pandax/base/biz"
|
||||
"pandax/base/captcha"
|
||||
"pandax/base/config"
|
||||
@@ -23,13 +27,13 @@ import (
|
||||
)
|
||||
|
||||
type UserApi struct {
|
||||
UserApp services2.SysUserModel
|
||||
MenuApp services2.SysMenuModel
|
||||
PostApp services2.SysPostModel
|
||||
RoleApp services2.SysRoleModel
|
||||
RoleMenuApp services2.SysRoleMenuModel
|
||||
DeptApp services2.SysDeptModel
|
||||
LogLogin services2.LogLoginModel
|
||||
UserApp services.SysUserModel
|
||||
MenuApp services.SysMenuModel
|
||||
PostApp services.SysPostModel
|
||||
RoleApp services.SysRoleModel
|
||||
RoleMenuApp services.SysRoleMenuModel
|
||||
DeptApp services.SysDeptModel
|
||||
LogLogin logServices.LogLoginModel
|
||||
}
|
||||
|
||||
// @Tags Base
|
||||
@@ -61,11 +65,11 @@ func (u *UserApi) RefreshToken(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}"
|
||||
// @Router /system/user/login [post]
|
||||
func (u *UserApi) Login(rc *ctx.ReqCtx) {
|
||||
var l form2.Login
|
||||
var l form.Login
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &l)
|
||||
biz.IsTrue(captcha.Verify(l.CaptchaId, l.Captcha), "验证码认证失败")
|
||||
|
||||
login := u.UserApp.Login(entity2.Login{Username: l.Username, Password: l.Password})
|
||||
login := u.UserApp.Login(entity.Login{Username: l.Username, Password: l.Password})
|
||||
role := u.RoleApp.FindOne(login.RoleId)
|
||||
|
||||
token, err := ctx.CreateToken(
|
||||
@@ -96,7 +100,7 @@ func (u *UserApi) Login(rc *ctx.ReqCtx) {
|
||||
"expire": time.Now().Unix() + config.Conf.Jwt.ExpireTime,
|
||||
}
|
||||
|
||||
var loginLog entity2.LogLogin
|
||||
var loginLog logEntity.LogLogin
|
||||
ua := user_agent.New(rc.GinCtx.Request.UserAgent())
|
||||
loginLog.Ipaddr = rc.GinCtx.ClientIP()
|
||||
loginLog.LoginLocation = utils.GetRealAddressByIP(rc.GinCtx.ClientIP())
|
||||
@@ -119,7 +123,7 @@ func (u *UserApi) Login(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}"
|
||||
// @Router /system/user/logout [post]
|
||||
func (u *UserApi) LogOut(rc *ctx.ReqCtx) {
|
||||
var loginLog entity2.LogLogin
|
||||
var loginLog logEntity.LogLogin
|
||||
ua := user_agent.New(rc.GinCtx.Request.UserAgent())
|
||||
loginLog.Ipaddr = rc.GinCtx.ClientIP()
|
||||
loginLog.LoginTime = time.Now()
|
||||
@@ -153,7 +157,7 @@ func (u *UserApi) GetSysUserList(rc *ctx.ReqCtx) {
|
||||
userName := rc.GinCtx.Query("username")
|
||||
phone := rc.GinCtx.Query("phone")
|
||||
deptId := ginx.QueryInt(rc.GinCtx, "deptId", 0)
|
||||
var user entity2.SysUser
|
||||
var user entity.SysUser
|
||||
user.Status = status
|
||||
user.Username = userName
|
||||
user.Phone = phone
|
||||
@@ -176,16 +180,16 @@ func (u *UserApi) GetSysUserList(rc *ctx.ReqCtx) {
|
||||
// @Security
|
||||
func (u *UserApi) GetSysUserProfile(rc *ctx.ReqCtx) {
|
||||
|
||||
sysUser := entity2.SysUser{}
|
||||
sysUser := entity.SysUser{}
|
||||
sysUser.UserId = rc.LoginAccount.UserId
|
||||
user := u.UserApp.FindOne(sysUser)
|
||||
|
||||
//获取角色列表
|
||||
roleList := u.RoleApp.FindList(entity2.SysRole{RoleId: rc.LoginAccount.RoleId})
|
||||
roleList := u.RoleApp.FindList(entity.SysRole{RoleId: rc.LoginAccount.RoleId})
|
||||
//岗位列表
|
||||
postList := u.PostApp.FindList(entity2.SysPost{PostId: rc.LoginAccount.PostId})
|
||||
postList := u.PostApp.FindList(entity.SysPost{PostId: rc.LoginAccount.PostId})
|
||||
//获取部门列表
|
||||
deptList := u.DeptApp.FindList(entity2.SysDept{DeptId: rc.LoginAccount.DeptId})
|
||||
deptList := u.DeptApp.FindList(entity.SysDept{DeptId: rc.LoginAccount.DeptId})
|
||||
|
||||
postIds := make([]int64, 0)
|
||||
postIds = append(postIds, rc.LoginAccount.PostId)
|
||||
@@ -222,7 +226,7 @@ func (u *UserApi) InsetSysUserAvatar(rc *ctx.ReqCtx) {
|
||||
// 上传文件至指定目录
|
||||
biz.ErrIsNil(rc.GinCtx.SaveUploadedFile(file, filPath), "保存头像失败")
|
||||
}
|
||||
sysuser := entity2.SysUser{}
|
||||
sysuser := entity.SysUser{}
|
||||
sysuser.UserId = rc.LoginAccount.UserId
|
||||
sysuser.Avatar = "/" + filPath
|
||||
sysuser.UpdateBy = rc.LoginAccount.UserName
|
||||
@@ -238,10 +242,10 @@ func (u *UserApi) InsetSysUserAvatar(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /system/user/updatePwd [post]
|
||||
func (u *UserApi) SysUserUpdatePwd(rc *ctx.ReqCtx) {
|
||||
var pws entity2.SysUserPwd
|
||||
var pws entity.SysUserPwd
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &pws)
|
||||
|
||||
user := entity2.SysUser{}
|
||||
user := entity.SysUser{}
|
||||
user.UserId = rc.LoginAccount.UserId
|
||||
u.UserApp.SetPwd(user, pws)
|
||||
}
|
||||
@@ -256,13 +260,13 @@ func (u *UserApi) SysUserUpdatePwd(rc *ctx.ReqCtx) {
|
||||
func (u *UserApi) GetSysUser(rc *ctx.ReqCtx) {
|
||||
userId := ginx.PathParamInt(rc.GinCtx, "userId")
|
||||
|
||||
user := entity2.SysUser{}
|
||||
user := entity.SysUser{}
|
||||
user.UserId = int64(userId)
|
||||
result := u.UserApp.FindOne(user)
|
||||
|
||||
roles := u.RoleApp.FindList(entity2.SysRole{})
|
||||
roles := u.RoleApp.FindList(entity.SysRole{})
|
||||
|
||||
posts := u.PostApp.FindList(entity2.SysPost{})
|
||||
posts := u.PostApp.FindList(entity.SysPost{})
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
"data": result,
|
||||
@@ -280,9 +284,9 @@ func (u *UserApi) GetSysUser(rc *ctx.ReqCtx) {
|
||||
// @Router /system/user/getInit [get]
|
||||
// @Security
|
||||
func (u *UserApi) GetSysUserInit(rc *ctx.ReqCtx) {
|
||||
roles := u.RoleApp.FindList(entity2.SysRole{})
|
||||
roles := u.RoleApp.FindList(entity.SysRole{})
|
||||
|
||||
posts := u.PostApp.FindList(entity2.SysPost{})
|
||||
posts := u.PostApp.FindList(entity.SysPost{})
|
||||
mp := make(map[string]interface{}, 2)
|
||||
mp["roles"] = roles
|
||||
mp["posts"] = posts
|
||||
@@ -296,13 +300,13 @@ func (u *UserApi) GetSysUserInit(rc *ctx.ReqCtx) {
|
||||
// @Router /system/user/getInit [get]
|
||||
// @Security
|
||||
func (u *UserApi) GetUserRolePost(rc *ctx.ReqCtx) {
|
||||
var user entity2.SysUser
|
||||
var user entity.SysUser
|
||||
user.UserId = rc.LoginAccount.UserId
|
||||
|
||||
resData := u.UserApp.FindOne(user)
|
||||
|
||||
roles := make([]entity2.SysRole, 0)
|
||||
posts := make([]entity2.SysPost, 0)
|
||||
roles := make([]entity.SysRole, 0)
|
||||
posts := make([]entity.SysPost, 0)
|
||||
for _, roleId := range strings.Split(resData.RoleIds, ",") {
|
||||
ro := u.RoleApp.FindOne(kgo.KConv.Str2Int64(roleId))
|
||||
roles = append(roles, *ro)
|
||||
@@ -327,7 +331,7 @@ func (u *UserApi) GetUserRolePost(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
|
||||
// @Router /system/user/sysUser [post]
|
||||
func (u *UserApi) InsertSysUser(rc *ctx.ReqCtx) {
|
||||
var sysUser entity2.SysUser
|
||||
var sysUser entity.SysUser
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &sysUser)
|
||||
sysUser.CreateBy = rc.LoginAccount.UserName
|
||||
u.UserApp.Insert(sysUser)
|
||||
@@ -343,7 +347,7 @@ func (u *UserApi) InsertSysUser(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
|
||||
// @Router /system/user/sysUser [put]
|
||||
func (u *UserApi) UpdateSysUser(rc *ctx.ReqCtx) {
|
||||
var sysUser entity2.SysUser
|
||||
var sysUser entity.SysUser
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &sysUser)
|
||||
sysUser.CreateBy = rc.LoginAccount.UserName
|
||||
u.UserApp.Update(sysUser)
|
||||
@@ -359,7 +363,7 @@ func (u *UserApi) UpdateSysUser(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 400, "message": "添加失败"}"
|
||||
// @Router /system/user/sysUser [put]
|
||||
func (u *UserApi) UpdateSysUserStu(rc *ctx.ReqCtx) {
|
||||
var sysUser entity2.SysUser
|
||||
var sysUser entity.SysUser
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &sysUser)
|
||||
sysUser.CreateBy = rc.LoginAccount.UserName
|
||||
u.UserApp.Update(sysUser)
|
||||
@@ -392,7 +396,7 @@ func (u *UserApi) ExportUser(rc *ctx.ReqCtx) {
|
||||
userName := rc.GinCtx.Query("username")
|
||||
phone := rc.GinCtx.Query("phone")
|
||||
|
||||
var user entity2.SysUser
|
||||
var user entity.SysUser
|
||||
user.Status = status
|
||||
user.Username = userName
|
||||
user.Phone = phone
|
||||
@@ -409,7 +413,7 @@ func (u *UserApi) ExportUser(rc *ctx.ReqCtx) {
|
||||
}
|
||||
|
||||
// 构建前端路由
|
||||
func Build(menus []entity2.SysMenu) []vo2.RouterVo {
|
||||
func Build(menus []entity.SysMenu) []vo.RouterVo {
|
||||
equals := func(a string, b string) bool {
|
||||
if a == b {
|
||||
return true
|
||||
@@ -419,9 +423,9 @@ func Build(menus []entity2.SysMenu) []vo2.RouterVo {
|
||||
if len(menus) == 0 {
|
||||
|
||||
}
|
||||
rvs := make([]vo2.RouterVo, 0)
|
||||
rvs := make([]vo.RouterVo, 0)
|
||||
for _, ms := range menus {
|
||||
var rv vo2.RouterVo
|
||||
var rv vo.RouterVo
|
||||
rv.Name = ms.Path
|
||||
rv.Path = ms.Path
|
||||
rv.Component = ms.Component
|
||||
@@ -429,7 +433,7 @@ func Build(menus []entity2.SysMenu) []vo2.RouterVo {
|
||||
if ms.Permission != "" {
|
||||
auth = strings.Split(ms.Permission, ",")
|
||||
}
|
||||
rv.Meta = vo2.MetaVo{
|
||||
rv.Meta = vo.MetaVo{
|
||||
Title: ms.MenuName,
|
||||
IsLink: ms.IsLink,
|
||||
IsHide: equals("1", ms.IsHide),
|
||||
|
||||
Reference in New Issue
Block a user