mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-25 03:48:35 +08:00
【新增】部门岗位租户功能
This commit is contained in:
@@ -28,8 +28,12 @@ type DeptApi struct {
|
||||
// @Security X-TOKEN
|
||||
func (m *DeptApi) GetDeptTreeRoleSelect(rc *ctx.ReqCtx) {
|
||||
roleId := ginx.PathParamInt(rc.GinCtx, "roleId")
|
||||
var dept entity.SysDept
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
dept.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
|
||||
result := m.DeptApp.SelectDeptLable(entity.SysDept{})
|
||||
result := m.DeptApp.SelectDeptLable(dept)
|
||||
|
||||
deptIds := make([]int64, 0)
|
||||
if roleId != 0 {
|
||||
@@ -57,7 +61,9 @@ func (a *DeptApi) GetDeptList(rc *ctx.ReqCtx) {
|
||||
status := rc.GinCtx.Query("status")
|
||||
deptId := ginx.QueryInt(rc.GinCtx, "deptId", 0)
|
||||
dept := entity.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)}
|
||||
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
dept.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
if dept.DeptName == "" {
|
||||
rc.ResData = a.DeptApp.SelectDept(dept)
|
||||
} else {
|
||||
@@ -72,7 +78,12 @@ 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(entity.SysDept{})
|
||||
var dept entity.SysDept
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
dept.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
|
||||
rc.ResData = a.DeptApp.FindList(dept)
|
||||
}
|
||||
|
||||
// @Summary 所有部门树数据
|
||||
@@ -89,7 +100,9 @@ func (a *DeptApi) GetDeptTree(rc *ctx.ReqCtx) {
|
||||
status := rc.GinCtx.Query("status")
|
||||
deptId := ginx.QueryInt(rc.GinCtx, "deptId", 0)
|
||||
dept := entity.SysDept{DeptName: deptName, Status: status, DeptId: int64(deptId)}
|
||||
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
dept.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
rc.ResData = a.DeptApp.SelectDept(dept)
|
||||
}
|
||||
|
||||
@@ -119,7 +132,7 @@ func (a *DeptApi) InsertDept(rc *ctx.ReqCtx) {
|
||||
var dept entity.SysDept
|
||||
g := rc.GinCtx
|
||||
ginx.BindJsonAndValid(g, &dept)
|
||||
|
||||
dept.TenantId = rc.LoginAccount.TenantId
|
||||
dept.CreateBy = rc.LoginAccount.UserName
|
||||
a.DeptApp.Insert(dept)
|
||||
}
|
||||
|
||||
@@ -37,6 +37,11 @@ func (p *PostApi) GetPostList(rc *ctx.ReqCtx) {
|
||||
postName := rc.GinCtx.Query("postName")
|
||||
postCode := rc.GinCtx.Query("postCode")
|
||||
post := entity.SysPost{Status: status, PostName: postName, PostCode: postCode}
|
||||
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
post.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
|
||||
list, total := p.PostApp.FindListPage(pageNum, pageSize, post)
|
||||
|
||||
rc.ResData = map[string]any{
|
||||
@@ -72,7 +77,7 @@ func (p *PostApi) GetPost(rc *ctx.ReqCtx) {
|
||||
func (p *PostApi) InsertPost(rc *ctx.ReqCtx) {
|
||||
var post entity.SysPost
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &post)
|
||||
|
||||
post.TenantId = rc.LoginAccount.TenantId
|
||||
post.CreateBy = rc.LoginAccount.UserName
|
||||
p.PostApp.Insert(post)
|
||||
}
|
||||
|
||||
@@ -38,8 +38,12 @@ func (r *RoleApi) GetRoleList(rc *ctx.ReqCtx) {
|
||||
status := rc.GinCtx.Query("status")
|
||||
roleName := rc.GinCtx.Query("roleName")
|
||||
roleKey := rc.GinCtx.Query("roleKey")
|
||||
|
||||
role := entity.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey}
|
||||
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
role.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
|
||||
list, total := r.RoleApp.FindListPage(pageNum, pageSize, role)
|
||||
|
||||
rc.ResData = map[string]any{
|
||||
@@ -199,8 +203,12 @@ func (p *RoleApi) ExportRole(rc *ctx.ReqCtx) {
|
||||
status := rc.GinCtx.Query("status")
|
||||
roleName := rc.GinCtx.Query("roleName")
|
||||
roleKey := rc.GinCtx.Query("roleKey")
|
||||
role := entity.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey}
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
role.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
list := p.RoleApp.FindList(role)
|
||||
|
||||
list := p.RoleApp.FindList(entity.SysRole{Status: status, RoleName: roleName, RoleKey: roleKey})
|
||||
fileName := utils.GetFileName(global.Conf.Server.ExcelDir, filename)
|
||||
utils.InterfaceToExcel(*list, fileName)
|
||||
rc.Download(fileName)
|
||||
|
||||
@@ -113,3 +113,11 @@ func (p *SysTenantsApi) DeleteSysTenants(rc *ctx.ReqCtx) {
|
||||
tenantIds := utils.IdsStrToIdsIntGroup(tenantId)
|
||||
p.SysTenantsApp.Delete(tenantIds)
|
||||
}
|
||||
|
||||
// IsTenantAdmin 是否为主租户
|
||||
func IsTenantAdmin(tenantId int64) bool {
|
||||
if tenantId == 1 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -179,6 +179,10 @@ func (u *UserApi) GetSysUserList(rc *ctx.ReqCtx) {
|
||||
user.Username = userName
|
||||
user.Phone = phone
|
||||
user.DeptId = int64(deptId)
|
||||
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
user.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
list, total := u.UserApp.FindListPage(pageNum, pageSize, user)
|
||||
|
||||
rc.ResData = map[string]any{
|
||||
@@ -281,9 +285,17 @@ func (u *UserApi) GetSysUser(rc *ctx.ReqCtx) {
|
||||
user.UserId = int64(userId)
|
||||
result := u.UserApp.FindOne(user)
|
||||
|
||||
roles := u.RoleApp.FindList(entity.SysRole{})
|
||||
var role entity.SysRole
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
role.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
roles := u.RoleApp.FindList(role)
|
||||
|
||||
posts := u.PostApp.FindList(entity.SysPost{})
|
||||
var post entity.SysPost
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
post.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
posts := u.PostApp.FindList(post)
|
||||
|
||||
rc.ResData = map[string]any{
|
||||
"data": result,
|
||||
@@ -301,9 +313,17 @@ func (u *UserApi) GetSysUser(rc *ctx.ReqCtx) {
|
||||
// @Router /system/user/getInit [get]
|
||||
// @Security
|
||||
func (u *UserApi) GetSysUserInit(rc *ctx.ReqCtx) {
|
||||
roles := u.RoleApp.FindList(entity.SysRole{})
|
||||
|
||||
posts := u.PostApp.FindList(entity.SysPost{})
|
||||
var role entity.SysRole
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
role.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
roles := u.RoleApp.FindList(role)
|
||||
var post entity.SysPost
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
post.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
posts := u.PostApp.FindList(post)
|
||||
mp := make(map[string]any, 2)
|
||||
mp["roles"] = roles
|
||||
mp["posts"] = posts
|
||||
@@ -418,22 +438,24 @@ func (u *UserApi) ExportUser(rc *ctx.ReqCtx) {
|
||||
user.Status = status
|
||||
user.Username = userName
|
||||
user.Phone = phone
|
||||
|
||||
if !IsTenantAdmin(rc.LoginAccount.TenantId) {
|
||||
user.TenantId = rc.LoginAccount.TenantId
|
||||
}
|
||||
|
||||
list := u.UserApp.FindList(user)
|
||||
fileName := utils.GetFileName(global.Conf.Server.ExcelDir, filename)
|
||||
utils.InterfaceToExcel(*list, fileName)
|
||||
rc.Download(fileName)
|
||||
}
|
||||
|
||||
// 构建前端路由
|
||||
// Build 构建前端路由
|
||||
func Build(menus []entity.SysMenu) []vo.RouterVo {
|
||||
equals := func(a string, b string) bool {
|
||||
if a == b {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
if len(menus) == 0 {
|
||||
|
||||
}
|
||||
rvs := make([]vo.RouterVo, 0)
|
||||
for _, ms := range menus {
|
||||
|
||||
Reference in New Issue
Block a user