【修改查询路径逻辑。超级管理员全部返回】

This commit is contained in:
weizhihong 2023-09-01 17:55:47 +08:00
parent f5a2106634
commit d5b5a221df

View File

@ -185,9 +185,19 @@ func QueryAuthApiPath(id int32) *model.AuthAPIPath {
// 根据角色ID查询路径信息
func QueryAuthApiPathByRids(rids []int32) []*model.AuthAPIPath {
if len(rids) == 0 {
rn := len(rids)
if rn == 0 {
return nil
}
// 判断是否是超级管理
isAdmin := false
for i := 0; i < rn && !isAdmin; i++ {
isAdmin = rids[i] == int32(dto.ADMIN)
}
if isAdmin { // 超级管理员查询所有路径
apiPaths, _ := dbquery.AuthAPIPath.Find()
return apiPaths
}
linkPids, err2 := dbquery.AuthRoleAPIPath.Distinct(dbquery.AuthRoleAPIPath.Pid).Where(dbquery.AuthRoleAPIPath.Rid.In(rids...)).Find()
if err2 != nil {
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err2.Error()})