You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
530 lines
18 KiB
530 lines
18 KiB
package grantpowers
|
|
|
|
import (
|
|
"appPlatform/models/modelAppPlatform"
|
|
"appPlatform/models/modelshr"
|
|
"appPlatform/models/modelssystempermission"
|
|
"appPlatform/overall"
|
|
"appPlatform/overall/publicmethod"
|
|
"encoding/json"
|
|
"sort"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-12-23 13:48:02
|
|
@ 功能: 初始化App双轴选项卡
|
|
*/
|
|
func (a *ApiMethod) GetAppGroupo(c *gin.Context) {
|
|
var requestData AppConfig
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.PowerType == "" {
|
|
publicmethod.Result(1, requestData, c, "未知配权系统!不可进行配权")
|
|
return
|
|
}
|
|
powerId := publicmethod.TypeToInterface(requestData.PowerId)
|
|
if powerId == "" {
|
|
publicmethod.Result(1, requestData, c, "未知配权系统!不可进行配权")
|
|
return
|
|
}
|
|
|
|
groupIsTrue, pickGroupAry := GainAppGroupAuth(requestData.PowerType, powerId)
|
|
|
|
var groupInfo modelAppPlatform.CustomerFormGroup
|
|
groupAry, _ := groupInfo.ContMap("`state` = 1")
|
|
//进行排序
|
|
sort.Slice(groupAry, func(i, j int) bool {
|
|
return groupAry[i].Sort < groupAry[j].Sort
|
|
})
|
|
var groupList []AppGroupInfo
|
|
|
|
for _, v := range groupAry {
|
|
groupId := strconv.FormatInt(v.Id, 10)
|
|
var groupCont AppGroupInfo
|
|
groupCont.Id = groupId //识别符
|
|
groupCont.Name = v.Title //名称
|
|
groupCont.ParentId = strconv.FormatInt(v.Superior, 10) //上级
|
|
groupCont.IsPick = false
|
|
groupCont.IsTrue = publicmethod.IsInTrue[string](groupId, pickGroupAry) //是否选中
|
|
groupList = append(groupList, groupCont)
|
|
}
|
|
sendGroupApp := publicmethod.MapOut[string]()
|
|
sendGroupApp["groupList"] = groupList
|
|
sendGroupApp["groupButPower"] = groupIsTrue
|
|
publicmethod.Result(0, sendGroupApp, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-12-26 08:34:59
|
|
@ 功能: 获取分组权限
|
|
|
|
#powerType 授权类型
|
|
#systemKey 授权对象值
|
|
*/
|
|
func GainAppGroupAuth(powerType, systemKey string) (butAry, groupAry []string) {
|
|
var groupPower modelssystempermission.AuthGroupPower
|
|
groupPower.GetCont(map[string]interface{}{"`appType`": "app", "`orgPowerType`": powerType, "`orgOrUserKey`": systemKey})
|
|
if groupPower.PowerInfo != "" {
|
|
json.Unmarshal([]byte(groupPower.PowerInfo), &butAry)
|
|
}
|
|
if groupPower.GroupStatus != "" {
|
|
json.Unmarshal([]byte(groupPower.GroupStatus), &groupAry)
|
|
}
|
|
if powerType == "person" && groupPower.Id == 0 {
|
|
//Step 1: 获取人员相关权限
|
|
var userCont modelshr.PersonArchives
|
|
userCont.GetCont(map[string]interface{}{"`key`": systemKey})
|
|
//Step 2: 获取相关角色
|
|
var SystemRole []int64
|
|
overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.SystemRole{}).Select("`id`").Where("`state` = 1 AND `types` = 1").Where("FIND_IN_SET(?, `roleuser`)", systemKey).Find(&SystemRole)
|
|
var roleIdAry []string
|
|
if userCont.Role != "" {
|
|
myRole := strings.Split(userCont.Role, ",")
|
|
roleIdAry = publicmethod.MergeStruct[string](myRole, roleIdAry)
|
|
}
|
|
for _, v := range SystemRole {
|
|
val := strconv.FormatInt(v, 10)
|
|
if !publicmethod.IsInTrue[string](val, roleIdAry) {
|
|
roleIdAry = append(roleIdAry, val)
|
|
}
|
|
}
|
|
if len(roleIdAry) > 0 {
|
|
var rolePowerAry []modelssystempermission.AuthGroupPower
|
|
overall.CONSTANT_DB_System_Permission.Where("`appType` = ? AND `orgPowerType` = ? AND `orgOrUserKey` IN ?", "app", "role", roleIdAry).Find(&rolePowerAry)
|
|
for _, v := range rolePowerAry {
|
|
if v.PowerInfo != "" {
|
|
var roleButAry []string
|
|
json.Unmarshal([]byte(v.PowerInfo), &roleButAry)
|
|
butAry = publicmethod.MergeStruct[string](roleButAry, butAry)
|
|
}
|
|
if v.GroupStatus != "" {
|
|
var roleGroupAry []string
|
|
json.Unmarshal([]byte(v.GroupStatus), &roleGroupAry)
|
|
groupAry = publicmethod.MergeStruct[string](roleGroupAry, groupAry)
|
|
}
|
|
}
|
|
}
|
|
|
|
//行政组织
|
|
var groupPower modelssystempermission.AuthGroupPower
|
|
groupPower.GetCont(map[string]interface{}{"`appType`": "app", "`orgPowerType`": "org", "`orgOrUserKey`": systemKey})
|
|
if groupPower.Id > 0 {
|
|
if groupPower.PowerInfo != "" {
|
|
var roleButAry []string
|
|
json.Unmarshal([]byte(groupPower.PowerInfo), &roleButAry)
|
|
butAry = publicmethod.MergeStruct[string](roleButAry, butAry)
|
|
}
|
|
if groupPower.GroupStatus != "" {
|
|
var roleGroupAry []string
|
|
json.Unmarshal([]byte(groupPower.GroupStatus), &roleGroupAry)
|
|
groupAry = publicmethod.MergeStruct[string](roleGroupAry, groupAry)
|
|
}
|
|
} else {
|
|
var allFirstOrgId publicmethod.GetOrgAllParent
|
|
orgId, _ := strconv.ParseInt(systemKey, 10, 64)
|
|
allFirstOrgId.GetOrgFirst(orgId)
|
|
if len(allFirstOrgId.Id) > 0 {
|
|
for _, v := range allFirstOrgId.Id {
|
|
var groupPowerFirst modelssystempermission.AuthGroupPower
|
|
groupPowerFirst.GetCont(map[string]interface{}{"`appType`": "app", "`orgPowerType`": "org", "`orgOrUserKey`": v})
|
|
if groupPowerFirst.Id > 0 {
|
|
if groupPowerFirst.PowerInfo != "" {
|
|
var roleButAry []string
|
|
json.Unmarshal([]byte(groupPowerFirst.PowerInfo), &roleButAry)
|
|
butAry = publicmethod.MergeStruct[string](roleButAry, butAry)
|
|
}
|
|
if groupPowerFirst.GroupStatus != "" {
|
|
var roleGroupAry []string
|
|
json.Unmarshal([]byte(groupPowerFirst.GroupStatus), &roleGroupAry)
|
|
groupAry = publicmethod.MergeStruct[string](roleGroupAry, groupAry)
|
|
}
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//职务
|
|
var groupPowerPostst modelssystempermission.AuthGroupPower
|
|
groupPowerPostst.GetCont(map[string]interface{}{"`appType`": "app", "`orgPowerType`": "job", "`orgOrUserKey`": userCont.Position})
|
|
if groupPowerPostst.PowerInfo != "" {
|
|
var roleButAry []string
|
|
json.Unmarshal([]byte(groupPowerPostst.PowerInfo), &roleButAry)
|
|
butAry = publicmethod.MergeStruct[string](roleButAry, butAry)
|
|
}
|
|
if groupPowerPostst.GroupStatus != "" {
|
|
var roleGroupAry []string
|
|
json.Unmarshal([]byte(groupPowerPostst.GroupStatus), &roleGroupAry)
|
|
groupAry = publicmethod.MergeStruct[string](roleGroupAry, groupAry)
|
|
}
|
|
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-12-24 13:38:13
|
|
@ 功能: 根据分组获取App列表
|
|
*/
|
|
func (a *ApiMethod) GetGroupAppList(c *gin.Context) {
|
|
var requestData GetGroupAppList
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.PowerType == "" {
|
|
publicmethod.Result(1, requestData, c, "未知配权系统!不可进行配权")
|
|
return
|
|
}
|
|
|
|
if requestData.RoleId == "" {
|
|
publicmethod.Result(1, requestData, c, "未知配权系统!不可进行配权")
|
|
return
|
|
}
|
|
if requestData.Group == "" {
|
|
publicmethod.Result(1, requestData, c, "未知配权系统分组!不可进行配权")
|
|
return
|
|
}
|
|
list := GetGroupAppListIng(requestData.Group, requestData.PowerType, "app", requestData.RoleId)
|
|
publicmethod.Result(0, list, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-12-17 11:08:15
|
|
@ 功能: 获取分组App
|
|
*/
|
|
// func (a *AppGroupInfo) GetGroupApp() {
|
|
func GetGroupAppListIng(uuId, powerType, appType, powerId string) (appAry []AppInfoPower) {
|
|
// defer syncSeting.Done()
|
|
var appList []modelAppPlatform.CustomerForm
|
|
overall.CONSTANT_DB_AppPlatform.Model(&modelAppPlatform.CustomerForm{}).Select("`id`,`signCode` ,`name`,`tablename`").Where("`classify` = 3 AND `states` = 1 AND `groupid` = ?", uuId).Find(&appList)
|
|
for _, v := range appList {
|
|
// fmt.Printf("获取分组App----->%v----->%v\n\n", a.Id, len(appList))
|
|
|
|
var appCont AppInfoPower
|
|
appCont.Id = strconv.FormatInt(v.SignCode, 10) //识别符
|
|
appCont.Name = v.Name //名称
|
|
appCont.ParentId = strconv.FormatInt(v.Groupid, 10) //上级
|
|
appCont.IsPick = false
|
|
|
|
appCont.IsTrue, appCont.OperationButton, _ = AppCallBackShow(v.SignCode, powerType, appType, powerId) //是否选中
|
|
if len(appCont.OperationButton) < 1 {
|
|
appCont.OperationButton = []string{}
|
|
}
|
|
if len(appCont.AppMenuTree) < 1 {
|
|
appCont.AppMenuTree = []AppMenuTreeInit{}
|
|
}
|
|
appAry = append(appAry, appCont)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-12-24 15:39:54
|
|
@ 功能: 获取app菜单
|
|
*/
|
|
func (a *ApiMethod) GetAppMenuList(c *gin.Context) {
|
|
var requestData GetGroupAppList
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.PowerType == "" {
|
|
publicmethod.Result(1, requestData, c, "未知配权系统!不可进行配权")
|
|
return
|
|
}
|
|
|
|
if requestData.RoleId == "" {
|
|
publicmethod.Result(1, requestData, c, "未知配权系统!不可进行配权")
|
|
return
|
|
}
|
|
if requestData.AppId == "" {
|
|
publicmethod.Result(1, requestData, c, "未知配权App!不可进行配权")
|
|
return
|
|
}
|
|
|
|
var menuList []modelAppPlatform.Appmenus
|
|
err := overall.CONSTANT_DB_AppPlatform.Where("`state` = 1 AND `isLock` = 2 AND `appkey` = ?", requestData.AppId).Find(&menuList).Error
|
|
if err != nil {
|
|
return
|
|
}
|
|
sort.Slice(menuList, func(i, j int) bool {
|
|
return menuList[i].EditTime < menuList[j].EditTime
|
|
})
|
|
sort.Slice(menuList, func(i, j int) bool {
|
|
return menuList[i].Sort < menuList[j].Sort
|
|
})
|
|
key, _ := strconv.ParseInt(requestData.AppId, 10, 64)
|
|
// list := AppTreeMenusnOne(key, menuList)
|
|
var authId []int64
|
|
switch requestData.PowerType {
|
|
case "role":
|
|
var authPower modelssystempermission.AuthPower
|
|
authPower.GetCont(map[string]interface{}{"`appType`": "app", "`orgPowerType`": requestData.PowerType, "`orgOrUserKey`": requestData.RoleId, "`appKey`": requestData.AppId}, "`id`", "`isTrue`", "`appButPower`")
|
|
if authPower.Id != 0 {
|
|
authId = append(authId, authPower.Id)
|
|
}
|
|
case "org":
|
|
var authPower modelssystempermission.AuthPower
|
|
authPower.GetCont(map[string]interface{}{"`appType`": "app", "`orgPowerType`": requestData.PowerType, "`orgOrUserKey`": requestData.RoleId, "`appKey`": requestData.AppId}, "`id`", "`isTrue`", "`appButPower`")
|
|
if authPower.Id != 0 {
|
|
authId = append(authId, authPower.Id)
|
|
} else {
|
|
orgIdInt, _ := strconv.ParseInt(requestData.RoleId, 10, 64)
|
|
var allFirstOrgId publicmethod.GetOrgAllParent
|
|
allFirstOrgId.GetOrgFirst(orgIdInt)
|
|
if len(allFirstOrgId.Id) > 0 {
|
|
for _, v := range allFirstOrgId.Id {
|
|
if v != 0 {
|
|
var authPowerIng modelssystempermission.AuthPower
|
|
authPowerIng.GetCont(map[string]interface{}{"`appType`": "app", "`orgPowerType`": requestData.PowerType, "`orgOrUserKey`": v, "`appKey`": requestData.AppId}, "`id`", "`isTrue`", "`appButPower`")
|
|
if authPower.Id != 0 {
|
|
authId = append(authId, authPowerIng.Id)
|
|
break
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
case "job":
|
|
var authPower modelssystempermission.AuthPower
|
|
authPower.GetCont(map[string]interface{}{"`appType`": "app", "`orgPowerType`": requestData.PowerType, "`orgOrUserKey`": requestData.RoleId, "`appKey`": requestData.AppId}, "`id`", "`isTrue`", "`appButPower`")
|
|
if authPower.Id != 0 {
|
|
authId = append(authId, authPower.Id)
|
|
}
|
|
case "person":
|
|
var authPower modelssystempermission.AuthPower
|
|
authPower.GetCont(map[string]interface{}{"`appType`": "app", "`orgPowerType`": requestData.PowerType, "`orgOrUserKey`": requestData.RoleId, "`appKey`": requestData.AppId}, "`id`", "`isTrue`", "`appButPower`")
|
|
if authPower.Id != 0 {
|
|
authId = append(authId, authPower.Id)
|
|
} else {
|
|
appType := "app"
|
|
appId, _ := strconv.ParseInt(requestData.AppId, 10, 64)
|
|
var authPower GainAppPowerTop
|
|
//角色
|
|
syncSeting.Add(1)
|
|
go authPower.HaveAppAuthPower(appId, "role", appType, requestData.RoleId)
|
|
//行政组织
|
|
syncSeting.Add(1)
|
|
go authPower.HaveAppAuthPower(appId, "org", appType, requestData.RoleId)
|
|
syncSeting.Wait()
|
|
//岗位
|
|
syncSeting.Add(1)
|
|
go authPower.HaveAppAuthPower(appId, "job", appType, requestData.RoleId)
|
|
syncSeting.Wait()
|
|
if len(authPower.List) > 0 {
|
|
for _, v := range authPower.List {
|
|
if v.IsTrue == 1 {
|
|
authId = append(authId, v.Id)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
default:
|
|
}
|
|
|
|
menuTree := AppTreeMenus(key, authId, menuList)
|
|
publicmethod.Result(0, menuTree, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-04-23 13:42:51
|
|
@ 功能: App菜单树处理
|
|
*/
|
|
func AppTreeMenusnOne(parentId int64, menuList []modelAppPlatform.Appmenus) (menusTree []AppMenuTreeInit) {
|
|
for _, v := range menuList {
|
|
if v.Parent == parentId {
|
|
var menuCont AppMenuTreeInit
|
|
menuCont.Id = strconv.FormatInt(v.Id, 10) //
|
|
menuCont.Name = v.Label //名称
|
|
menuCont.ParentId = strconv.FormatInt(v.Parent, 10) //上级
|
|
menuCont.AppKey = strconv.FormatInt(v.Appkey, 10)
|
|
menuCont.IsPick = false //是否激活
|
|
menuCont.IsTrue = false //是否选中
|
|
menuCont.MenuType = v.Types
|
|
|
|
menuCont.FormPower = []string{}
|
|
menuCont.ListPower = []string{}
|
|
menuCont.PagePower = []string{}
|
|
|
|
menuCont.VisibleRange.Types = 1
|
|
menuCont.VisibleRange.Attribute = []int64{}
|
|
menuCont.Children = AppTreeMenusnOne(v.Id, menuList)
|
|
menusTree = append(menusTree, menuCont)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-12-26 15:54:30
|
|
@ 功能: 分组授权
|
|
*/
|
|
func (a *ApiMethod) AppGroupPowerConfig(c *gin.Context) {
|
|
var requestData ConfigSetupGroup
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.PowerType == "" {
|
|
publicmethod.Result(1, requestData, c, "未知配权系统!不可进行配权")
|
|
return
|
|
}
|
|
|
|
if requestData.PowerId == "" {
|
|
publicmethod.Result(1, requestData, c, "未知配权系统!不可进行配权")
|
|
return
|
|
}
|
|
powerInfo, jsonErr := json.Marshal(requestData.GroupButPower)
|
|
|
|
var groupInfo modelssystempermission.AuthGroupPower
|
|
groupInfo.GetCont(map[string]interface{}{"`appType`": "app", "`orgPowerType`": requestData.PowerType, "`orgOrUserKey`": requestData.PowerId})
|
|
if groupInfo.Id != 0 {
|
|
saveData := publicmethod.MapOut[string]()
|
|
if jsonErr == nil {
|
|
saveData["powerInfo"] = string(powerInfo)
|
|
} else {
|
|
saveData["powerInfo"] = "[]"
|
|
}
|
|
saveData["`time`"] = time.Now().Unix()
|
|
var saveInfo modelssystempermission.AuthGroupPower
|
|
saveInfo.EiteCont(map[string]interface{}{"`id`": groupInfo.Id}, saveData)
|
|
} else {
|
|
uuid := publicmethod.GetUUid(1)
|
|
powerId := publicmethod.TypeToInterface(requestData.PowerId)
|
|
var saveGroupPower modelssystempermission.AuthGroupPower
|
|
saveGroupPower.Id = uuid
|
|
saveGroupPower.AppType = "app"
|
|
saveGroupPower.OrgPowerType = requestData.PowerType
|
|
saveGroupPower.OrgOrUserKey, _ = strconv.ParseInt(powerId, 10, 64)
|
|
saveGroupPower.Time = time.Now().Unix()
|
|
saveGroupPower.PowerInfo = string(powerInfo)
|
|
saveGroupPower.GroupStatus = "[]"
|
|
overall.CONSTANT_DB_System_Permission.Create(&saveGroupPower)
|
|
}
|
|
publicmethod.Result(0, groupInfo, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-12-27 08:13:42
|
|
@ 功能: 写入App及相关菜单权限
|
|
*/
|
|
func (a *ApiMethod) AppPowerConfig(c *gin.Context) {
|
|
var requestData AppMenuPower
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.PowerType == "" {
|
|
publicmethod.Result(1, requestData, c, "未知配权系统!不可进行配权")
|
|
return
|
|
}
|
|
|
|
if requestData.PowerId == "" {
|
|
publicmethod.Result(1, requestData, c, "未知配权系统!不可进行配权")
|
|
return
|
|
}
|
|
if requestData.AppId == "" {
|
|
publicmethod.Result(1, requestData, c, "未知配权应用!不可进行配权")
|
|
return
|
|
}
|
|
appPowerJson, _ := json.Marshal(requestData.MenuList)
|
|
appType := "app"
|
|
uuid := publicmethod.GetUUid(1)
|
|
var appPowerInfo modelssystempermission.AuthPower
|
|
appPowerInfo.GetCont(map[string]interface{}{"`appType`": appType, "`orgPowerType`": requestData.PowerType, "`orgOrUserKey`": requestData.PowerId, "`appKey`": requestData.AppId}, "`id`", "`isTrue`", "`appButPower`")
|
|
if appPowerInfo.Id == 0 { //新增
|
|
var newAppPowerInfo modelssystempermission.AuthPower
|
|
newAppPowerInfo.Id = uuid
|
|
newAppPowerInfo.OrgPowerType = requestData.PowerType
|
|
newAppPowerInfo.OrgOrUserKey, _ = strconv.ParseInt(requestData.PowerId, 10, 64)
|
|
newAppPowerInfo.AppType = appType
|
|
newAppPowerInfo.AppKey, _ = strconv.ParseInt(requestData.AppId, 10, 64)
|
|
newAppPowerInfo.Time = time.Now().Unix()
|
|
if requestData.AppIsTrue {
|
|
newAppPowerInfo.IsTrue = 1 //1:有;非1:无)
|
|
} else {
|
|
newAppPowerInfo.IsTrue = 0
|
|
}
|
|
newAppPowerInfo.PowerInfo = string(appPowerJson)
|
|
operAtionBut, _ := json.Marshal(requestData.AppPower)
|
|
newAppPowerInfo.AppButPower = string(operAtionBut)
|
|
overall.CONSTANT_DB_System_Permission.Create(&newAppPowerInfo)
|
|
var oldPower modelssystempermission.PowerInfo
|
|
oldPower.DelCont(map[string]interface{}{"`authId`": uuid})
|
|
var menuPowList AppMenuAry
|
|
menuPowList.List = []AppMenuInfo{}
|
|
menuPowList.AppMenuTreeSubNew(requestData.MenuList, uuid)
|
|
} else { //编辑
|
|
uuid = appPowerInfo.Id
|
|
saveData := publicmethod.MapOut[string]()
|
|
saveData["powerInfo"] = string(appPowerJson)
|
|
if requestData.AppIsTrue {
|
|
saveData["isTrue"] = 1
|
|
} else {
|
|
saveData["isTrue"] = 0
|
|
}
|
|
operAtionBut, _ := json.Marshal(requestData.AppPower)
|
|
saveData["appButPower"] = string(operAtionBut)
|
|
saveData["time"] = time.Now().Unix()
|
|
var saveAppPowerInfo modelssystempermission.AuthPower
|
|
saveAppPowerInfo.EiteCont(map[string]interface{}{"`id`": appPowerInfo.Id}, saveData)
|
|
var oldPower modelssystempermission.PowerInfo
|
|
oldPower.DelCont(map[string]interface{}{"`authId`": appPowerInfo.Id})
|
|
var menuPowList AppMenuAry
|
|
menuPowList.List = []AppMenuInfo{}
|
|
menuPowList.AppMenuTreeSubNew(requestData.MenuList, appPowerInfo.Id)
|
|
}
|
|
AppGroupJudje(appType, requestData.PowerType, requestData.PowerId, requestData.GroupList)
|
|
publicmethod.Result(0, requestData, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2026-01-10 11:42:57
|
|
@ 功能: 处理App分组
|
|
*/
|
|
func AppGroupJudje(appType, powerType, powerId string, groupList []AppInfoPower) {
|
|
var groupIdAry []string
|
|
for _, v := range groupList {
|
|
if v.IsTrue {
|
|
groupIdAry = append(groupIdAry, v.Id)
|
|
}
|
|
}
|
|
groupIdAryJson, _ := json.Marshal(groupIdAry)
|
|
var authGroupInfo modelssystempermission.AuthGroupPower
|
|
authGroupInfo.GetCont(map[string]interface{}{"`appType`": appType, "`orgPowerType`": powerType, "`orgOrUserKey`": powerId})
|
|
if authGroupInfo.Id != 0 {
|
|
saveData := publicmethod.MapOut[string]()
|
|
saveData["groupStatus"] = string(groupIdAryJson)
|
|
saveData["`time`"] = time.Now().Unix()
|
|
var newAuthGroupInfo modelssystempermission.AuthGroupPower
|
|
newAuthGroupInfo.EiteCont(map[string]interface{}{"`id`": authGroupInfo.Id}, saveData)
|
|
} else {
|
|
powerIdInt, _ := strconv.ParseInt(powerId, 10, 64)
|
|
var addInfo modelssystempermission.AuthGroupPower
|
|
addInfo.Id = publicmethod.GetUUid(1)
|
|
addInfo.AppType = appType
|
|
addInfo.OrgPowerType = powerType
|
|
addInfo.OrgOrUserKey = powerIdInt
|
|
addInfo.Time = time.Now().Unix()
|
|
addInfo.PowerInfo = "[]"
|
|
addInfo.GroupStatus = string(groupIdAryJson)
|
|
overall.CONSTANT_DB_System_Permission.Create(&addInfo)
|
|
}
|
|
}
|
|
|