KPI绩效考核系统
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.

716 lines
24 KiB

package jurisdictionpc
import (
"encoding/json"
"fmt"
"key_performance_indicators/models/modelshr"
3 years ago
"key_performance_indicators/models/modelsschool"
"key_performance_indicators/models/modelsstorage"
"key_performance_indicators/models/modelssystempermission"
"key_performance_indicators/overall"
"key_performance_indicators/overall/publicmethod"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
)
// 编辑权限
func (a *ApiMethod) EditPower(c *gin.Context) {
var receivedValue appPowerStruct
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.OrdId == "" {
publicmethod.Result(1, receivedValue, c, "请指定要配置的行政组织!")
return
}
if receivedValue.PostId == "" {
publicmethod.Result(1, receivedValue, c, "请指定要配置的岗位!")
return
}
if receivedValue.SystemName == "" {
publicmethod.Result(1, err, c, "请提交系统识别符!")
return
}
if len(receivedValue.PointId) < 1 {
publicmethod.Result(1, err, c, "请至少指定一项权限!")
return
}
switch receivedValue.Level {
case 2: //本分部
if len(receivedValue.Organization) < 1 {
receivedValue.Organization = append(receivedValue.Organization, receivedValue.OrdId)
ordIdInt, _ := strconv.ParseInt(receivedValue.OrdId, 10, 64)
_, companyId, _, _, _ := publicmethod.GetOrgStructure(ordIdInt)
var sonOrgId []int64
sonOrgId = publicmethod.GetDepartmentSun(companyId, sonOrgId)
if len(sonOrgId) > 0 {
for oi := 0; oi < len(sonOrgId); oi++ {
sonOrgIdStr := strconv.FormatInt(sonOrgId[oi], 10)
if publicmethod.IsInTrue[string](sonOrgIdStr, receivedValue.Organization) == false {
receivedValue.Organization = append(receivedValue.Organization, sonOrgIdStr)
}
}
}
}
case 3:
var orgAry []string
receivedValue.Organization = orgAry
default:
receivedValue.Level = 1
if len(receivedValue.Organization) < 1 {
var orgAry []string
orgAry = append(orgAry, receivedValue.OrdId)
receivedValue.Organization = orgAry
}
}
var empowerCont modelssystempermission.Empower
err = empowerCont.GetCont(map[string]interface{}{"`ordid`": receivedValue.OrdId, "`post_id`": receivedValue.PostId, "`system`": receivedValue.SystemName}, "`id`")
postIdStr := strings.Join(receivedValue.PointId, ",")
if err == nil {
err = empowerCont.EiteCont(map[string]interface{}{"`id`": empowerCont.Id}, map[string]interface{}{"`state`": 1, "`point_id`": postIdStr, "`time`": time.Now().Unix(), "`level`": receivedValue.Level, "`organization`": strings.Join(receivedValue.Organization, ",")})
} else {
ordIdInt64, _ := strconv.ParseInt(receivedValue.OrdId, 10, 64)
empowerCont.OrdId = ordIdInt64 //行政组织"`
postIdInt64, _ := strconv.ParseInt(receivedValue.PostId, 10, 64)
empowerCont.PostId = postIdInt64 //岗位ID"`
empowerCont.System = receivedValue.SystemName //系统"`
empowerCont.PointId = postIdStr //权限点位"`
empowerCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
empowerCont.Time = time.Now().Unix() //创建时间"`
empowerCont.Level = receivedValue.Level
empowerCont.Organization = strings.Join(receivedValue.Organization, ",")
err = overall.CONSTANT_DB_System_Permission.Create(&empowerCont).Error
}
if err != nil {
publicmethod.Result(104, err, c)
return
}
publicmethod.Result(0, err, c)
// for i := 0; i < len(receivedValue.PointId); i++ {
// var empowerCont modelssystempermission.Empower
// err = empowerCont.GetCont(map[string]interface{}{"`post_id`": receivedValue.PostId, "`system`": receivedValue.SystemName, "`point_id`": receivedValue.PointId[i]})
// if err == nil {
// if empowerCont.State != 1 {
// empowerCont.EiteCont(map[string]interface{}{"`id`": empowerCont.Id}, map[string]interface{}{"`state`": 1, "`time`": time.Now().Unix()})
// }
// } else {
// postIdInt64, _ := strconv.ParseInt(receivedValue.PostId, 10, 64)
// empowerCont.PostId = postIdInt64 //岗位ID"`
// empowerCont.System = receivedValue.SystemName //系统"`
// poinIdInt64, _ := strconv.ParseInt(receivedValue.PointId[i], 10, 64)
// empowerCont.PointId = poinIdInt64 //权限点位"`
// empowerCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
// empowerCont.Time = time.Now().Unix() //创建时间"`
// saveData = append(saveData, empowerCont)
// }
// }
// if len(saveData) > 0 {
// err = overall.CONSTANT_DB_System_Permission.Create(&saveData).Error
// }
// if err != nil {
// publicmethod.Result(104, err, c)
// return
// }
// //清除其他权限
// otherSaveData := publicmethod.MapOut[string]()
// otherSaveData["`state`"] = 2
// otherSaveData["`time`"] = time.Now().Unix()
// overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.Empower{}).Where("`state` = 1 AND `post_id` = ? AND `system` = ?", receivedValue.PostId, receivedValue.SystemName).Not(map[string]interface{}{"point_id": receivedValue.PointId}).Updates(&otherSaveData)
// publicmethod.Result(0, saveData, c)
}
3 years ago
// 相关系统菜单
func (a *ApiMethod) SystemAboutMenu(c *gin.Context) {
var receivedValue GetSystemMenuPower
3 years ago
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.Name == "" {
publicmethod.Result(101, err, c)
return
}
var systemPower modelssystempermission.Appsystem
err = systemPower.GetCont(map[string]interface{}{"`coder`": receivedValue.Name})
3 years ago
if err != nil {
publicmethod.Result(105, err, c)
return
}
if systemPower.State == 2 {
publicmethod.Result(1, err, c, "该系统授权已经禁用!")
return
}
if systemPower.State == 3 {
publicmethod.Result(1, err, c, "该系统授权已经取消合作!")
return
}
var menuThree []publicmethod.PowerThree
// fmt.Printf("ApiUrl------>%v\n", receivedValue)
3 years ago
if systemPower.ApiUrl != "" {
//api入口不为空的情况下采用get访问方式接收数据
htmlByte := publicmethod.CurlGet(systemPower.ApiUrl)
fmt.Printf("%v\n", string(htmlByte))
var jsonAry callBackUrlMenu
jsonErr := json.Unmarshal(htmlByte, &jsonAry)
if jsonErr != nil {
publicmethod.Result(1, jsonErr, c, "数据获取错误!")
return
}
if jsonAry.Code != 0 {
publicmethod.Result(1, jsonErr, c, jsonAry.Msg)
return
}
menuThree = jsonAry.Data
3 years ago
} else {
var pointInt []string
var operatIon []string
var systemEmpowerCont modelssystempermission.Empower
err = systemEmpowerCont.GetCont(map[string]interface{}{"`ordid`": receivedValue.OrdId, "`post_id`": receivedValue.PostId, "`system`": systemPower.Coder}, "`point_id`", `operation`)
if err == nil {
pointInt = strings.Split(systemEmpowerCont.PointId, ",")
operatIon = strings.Split(systemEmpowerCont.Operation, ",")
}
3 years ago
//api入口为空,采用系统内置获取授权菜单
switch systemPower.Coder {
case "cangchu":
menuThree = wmsMenuThree(pointInt, operatIon)
// fmt.Printf("ApiUrl----2-->%v\n", systemPower.ApiUrl)
3 years ago
default:
//获取绩效考核菜单树
menuThree = kpiMenuThree(pointInt, operatIon)
// fmt.Printf("ApiUrl---1--->%v\n", systemPower.ApiUrl)
3 years ago
}
}
publicmethod.Result(0, menuThree, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2022-11-06 16:02:56
@ 功能: kpi菜单树
@ 参数
#purview 以获得的权限
#operatIon 操作点位
@ 返回值
#
*/
func kpiMenuThree(purview, operatIon []string) (menuThree []publicmethod.PowerThree) {
var menuList []modelsschool.SystemMenuSchool
err := overall.CONSTANT_DB_Master.Where("`m_steat` = 1").Order("`m_sort` ASC").Order("`m_id` DESC").Find(&menuList).Error
lenSum := len(menuList)
// fmt.Printf("ApiUrl---3--->%v--->%v\n", err, lenSum)
if err != nil || lenSum < 1 {
3 years ago
return
}
var menuSmaillList []publicmethod.MenuContList
for i := 0; i < lenSum; i++ {
var menSmaiCont publicmethod.MenuContList
idStr := strconv.FormatInt(menuList[i].Id, 10)
menSmaiCont.Id = idStr
menSmaiCont.Name = menuList[i].Title
menSmaiCont.ParentId = strconv.FormatInt(menuList[i].ParentId, 10)
menSmaiCont.PathUrl = menuList[i].ApiUrl
if len(purview) > 0 {
if publicmethod.IsInTrue[string](idStr, purview) == true {
menSmaiCont.IsTrue = true
// fmt.Printf("\n\npurview------>%v------>%v------>%v\n\n", idStr, purview, publicmethod.IsInTrue[string](idStr, purview))
}
}
menuSmaillList = append(menuSmaillList, menSmaiCont)
}
menuThree = publicmethod.GetMenuThreePeiQuan(1, "0", menuSmaillList, operatIon)
return
}
/*
*
@ 作者: 秦东
@ 时间: 2022-11-06 16:02:56
@ 功能: 仓储菜单树
@ 参数
#purview 以获得的权限
#operatIon 操作点位
@ 返回值
#
*/
func wmsMenuThree(purview, operatIon []string) (menuThree []publicmethod.PowerThree) {
var menuList []modelsstorage.AccesstoAddress
err := overall.CONSTANT_DB_Storage.Where("`state` = 1").Find(&menuList).Error
lenSum := len(menuList)
if err != nil || lenSum < 1 {
return
}
var menuSmaillList []publicmethod.MenuContList
for i := 0; i < lenSum; i++ {
var menSmaiCont publicmethod.MenuContList
idStr := strconv.FormatInt(menuList[i].Id, 10)
menSmaiCont.Id = idStr
menSmaiCont.Name = menuList[i].Name
menSmaiCont.ParentId = strconv.FormatInt(int64(menuList[i].Menuparent), 10)
menSmaiCont.PathUrl = menuList[i].Url
// fmt.Printf("ApiUrl---1--->%v--->%v--->%v\n", idStr, purview, publicmethod.IsInTrue[string](idStr, purview))
if len(purview) > 0 {
if publicmethod.IsInTrue[string](idStr, purview) == true {
menSmaiCont.IsTrue = true
}
}
menuSmaillList = append(menuSmaillList, menSmaiCont)
}
menuThree = publicmethod.GetMenuThrees(1, "0", menuSmaillList)
3 years ago
return
}
/*
*
@ 作者: 秦东
@ 时间: 2022-11-07 13:46:06
@ 功能: 编辑权限新版
@ 参数
#
@ 返回值
#
*/
func (a *ApiMethod) EditPowerNew(c *gin.Context) {
var receivedValue editPowerStructNew
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.OrdId == "" || receivedValue.OrdId == "0" {
publicmethod.Result(1, receivedValue, c, "未知行政组织!不可进行配权")
return
}
if receivedValue.PostId == "" || receivedValue.PostId == "0" {
publicmethod.Result(1, receivedValue, c, "未知岗位!不可进行配权")
return
}
if receivedValue.SystemName == "" {
publicmethod.Result(1, receivedValue, c, "未知配权系统!不可进行配权")
return
}
if receivedValue.Level == 0 {
receivedValue.Level = 2
}
var orgIdList []int64
switch receivedValue.Level {
case 2: //本部门
orgIdInt, _ := strconv.ParseInt(receivedValue.OrdId, 10, 64)
_, _, departmentId, _, _ := publicmethod.GetOrgStructure(orgIdInt)
orgIdList = publicmethod.GetDepartmentSun(departmentId, orgIdList)
case 3: //本分部
orgIdInt, _ := strconv.ParseInt(receivedValue.OrdId, 10, 64)
_, companyId, _, _, _ := publicmethod.GetOrgStructure(orgIdInt)
orgIdList = publicmethod.GetDepartmentSun(companyId, orgIdList)
case 4: //指定行政组织
case 5: //所有
overall.CONSTANT_DB_HR.Model(&modelshr.AdministrativeOrganization{}).Select("`id`").Where("`state` = 1").Find(&orgIdList)
default: //本岗位
orgIdInt, _ := strconv.ParseInt(receivedValue.OrdId, 10, 64)
orgIdList = append(orgIdList, orgIdInt)
}
var orgIdListStr string //行政组织
if len(orgIdList) > 0 {
var orgIdListStrAry []string //
for _, ovl := range orgIdList {
idStr := strconv.FormatInt(ovl, 10)
if publicmethod.IsInTrue[string](idStr, orgIdListStrAry) == false {
orgIdListStrAry = append(orgIdListStrAry, idStr)
}
}
orgIdListStr = strings.Join(orgIdListStrAry, ",")
}
var menuList []string //权限点位
var menuOperationList []string //操作点位
addTime := time.Now().Unix()
var empowerCont modelssystempermission.Empower
err = empowerCont.GetCont(map[string]interface{}{"`ordid`": receivedValue.OrdId, "`post_id`": receivedValue.PostId, "`system`": receivedValue.SystemName}, "`id`")
if len(receivedValue.PowerList) < 1 {
if err == nil {
err = empowerCont.EiteCont(map[string]interface{}{"`id`": empowerCont.Id}, map[string]interface{}{"`point_id`": "", "`operation`": "", "`level`": receivedValue.Level, "`time`": addTime, "`state`": 1, "`organization`": orgIdListStr})
if err != nil {
publicmethod.Result(1, err, c, "权限配置失败")
return
}
} else {
orgIdInt, _ := strconv.ParseInt(receivedValue.OrdId, 10, 64)
empowerCont.OrdId = orgIdInt //行政组织"`
postIdInt, _ := strconv.ParseInt(receivedValue.PostId, 10, 64)
empowerCont.PostId = postIdInt //岗位ID"`
empowerCont.System = receivedValue.SystemName //系统"`
empowerCont.PointId = strings.Join(menuList, ",") //权限点位"`
empowerCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
empowerCont.Time = addTime //创建时间"`
empowerCont.Level = receivedValue.Level //授权范围等级(1:本部门;2:本分部;3:所有)"`
empowerCont.Organization = orgIdListStr //行政组织"`
empowerCont.Operation = strings.Join(menuOperationList, ",") //操作点位
err = overall.CONSTANT_DB_System_Permission.Create(&empowerCont).Error
if err != nil {
publicmethod.Result(1, err, c, "权限配置失败")
return
}
}
} else {
var munePowerList empowerSync
for _, v := range receivedValue.PowerList {
// if v.Id == "1" {
syncSeting.Add(1)
go munePowerList.GetAllSunCont(v)
// }
}
syncSeting.Wait()
menuIdList, menuOperIdList := munePowerList.readDataLock()
// fmt.Printf("\n\n%v-------结果-------->%v\n", menuIdList, menuOperIdList)
// publicmethod.Result(0, receivedValue.PowerList, c)
// return
// outData := publicmethod.MapOut[string]()
// outData["menuIdList"] = menuIdList
// outData["menuOperIdList"] = menuOperIdList
// publicmethod.Result(0, outData, c)
menuIdListStr := strings.Join(menuIdList, ",")
menuOperIdListStr := strings.Join(menuOperIdList, ",")
if err == nil {
err = empowerCont.EiteCont(map[string]interface{}{"`id`": empowerCont.Id}, map[string]interface{}{"`point_id`": menuIdListStr, "`operation`": menuOperIdListStr, "`level`": receivedValue.Level, "`time`": addTime, "`state`": 1, "`organization`": orgIdListStr})
if err != nil {
publicmethod.Result(1, err, c, "权限配置失败")
return
}
} else {
orgIdInt, _ := strconv.ParseInt(receivedValue.OrdId, 10, 64)
empowerCont.OrdId = orgIdInt //行政组织"`
postIdInt, _ := strconv.ParseInt(receivedValue.PostId, 10, 64)
empowerCont.PostId = postIdInt //岗位ID"`
empowerCont.System = receivedValue.SystemName //系统"`
empowerCont.PointId = menuIdListStr //权限点位"`
empowerCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
empowerCont.Time = addTime //创建时间"`
empowerCont.Level = receivedValue.Level //授权范围等级(1:本部门;2:本分部;3:所有)"`
empowerCont.Organization = orgIdListStr //行政组织"`
empowerCont.Operation = menuOperIdListStr //操作点位
err = overall.CONSTANT_DB_System_Permission.Create(&empowerCont).Error
if err != nil {
publicmethod.Result(1, err, c, "权限配置失败")
return
}
}
}
publicmethod.Result(0, receivedValue, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2022-11-07 15:34:48
@ 功能: 获取菜单所有操作
@ 参数
#
@ 返回值
#
*/
func (e *empowerSync) GetAllSunCont(menuList publicmethod.PowerThree) {
e.mutext.Lock()
defer e.mutext.Unlock()
if menuList.IsTrue == true {
if publicmethod.IsInTrue[string](menuList.Id, e.menuList) == false {
e.menuList = append(e.menuList, menuList.Id)
}
}
if len(menuList.MenuOperation) > 0 {
for _, v := range menuList.MenuOperation {
if v.IsTrue == true {
if publicmethod.IsInTrue[string](v.Id, e.menuOperationList) == false {
e.menuOperationList = append(e.menuOperationList, v.Id)
}
}
}
}
if len(menuList.Child) > 0 {
var menuId []string
var menuOperId []string
menuIdList, menuOperIdList := DiGuiMenuList(menuList.Child, menuId, menuOperId)
// // fmt.Printf("\n\nmenuIdList------%v----->%v\n\n", menuList.Id, menuList.Child)
// fmt.Printf("\n\nmenuOperIdList----%v------->%v------->%v\n\n", menuList.Id, menuIdList, menuOperIdList)
if len(menuIdList) > 0 {
for _, mv := range menuIdList {
if publicmethod.IsInTrue[string](mv, e.menuList) == false {
e.menuList = append(e.menuList, mv)
}
}
}
if len(menuOperIdList) > 0 {
for _, mvo := range menuOperIdList {
// fmt.Printf("menuOper--Fuji->%v---->%v\n", menuList.Id, mvo)
// e.menuOperationList = append(e.menuOperationList, mvo)
if publicmethod.IsInTrue[string](mvo, e.menuOperationList) == false {
e.menuOperationList = append(e.menuOperationList, mvo)
}
}
}
}
syncSeting.Done()
}
/*
*
@ 作者: 秦东
@ 时间: 2022-11-07 16:15:58
@ 功能: 递归菜单选择操作
@ 参数
#
@ 返回值
#
*/
func DiGuiMenuList(menuList []publicmethod.PowerThree, menuId, menuOperId []string) (menuIdList, menuOperIdList []string) {
// fmt.Printf("\n\nmenuIdList----222222--%v----->%v----->%v\n\n", menuId, menuOperId, menuList)
for _, v := range menuList {
// fmt.Printf("\n\nmenuIdList----33333--%v----->%v----->%v\n\n", menuId, menuOperId, v.IsTrue)
if v.IsTrue == true {
fmt.Printf("\n\nmenuIdList----444--%v----->%v----->%v\n\n", menuId, menuOperId, v.Id)
menuIdList = append(menuIdList, v.Id)
for _, menuCont := range menuId {
if publicmethod.IsInTrue[string](menuCont, menuIdList) == false {
menuIdList = append(menuIdList, menuCont)
}
}
}
if len(v.MenuOperation) > 0 {
for _, vm := range v.MenuOperation {
if vm.IsTrue == true {
menuOperIdList = append(menuOperIdList, vm.Id)
for _, menuContOper := range menuOperId {
if publicmethod.IsInTrue[string](menuContOper, menuOperIdList) == false {
menuOperIdList = append(menuOperIdList, menuContOper)
}
}
}
}
}
if len(v.Child) > 0 {
// fmt.Printf("menuOper--zijian->%v---->%v\n", v.Id, v.Id)
menuIdList, menuOperIdList = DiGuiMenuList(v.Child, menuIdList, menuOperIdList)
}
}
// fmt.Printf("menuOper--jieshuzhi->%v---->%v\n", menuIdList, menuOperIdList)
return
}
/*
*
@ 作者: 秦东
@ 时间: 2022-11-09 13:28:39
@ 功能: 角色配权菜单
@ 参数
#
@ 返回值
#
*/
func (a *ApiMethod) SystemRoleAboutMenu(c *gin.Context) {
var receivedValue GetSystemRoleMenuPower
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.Name == "" {
publicmethod.Result(101, err, c)
return
}
var systemPower modelssystempermission.Appsystem
err = systemPower.GetCont(map[string]interface{}{"`coder`": receivedValue.Name})
if err != nil {
publicmethod.Result(105, err, c)
return
}
if systemPower.State == 2 {
publicmethod.Result(1, err, c, "该系统授权已经禁用!")
return
}
if systemPower.State == 3 {
publicmethod.Result(1, err, c, "该系统授权已经取消合作!")
return
}
var menuThree []publicmethod.PowerThree
// fmt.Printf("ApiUrl------>%v\n", receivedValue)
if systemPower.ApiUrl != "" {
//api入口不为空的情况下采用get访问方式接收数据
htmlByte := publicmethod.CurlGet(systemPower.ApiUrl)
fmt.Printf("%v\n", string(htmlByte))
var jsonAry callBackUrlMenu
jsonErr := json.Unmarshal(htmlByte, &jsonAry)
if jsonErr != nil {
publicmethod.Result(1, jsonErr, c, "数据获取错误!")
return
}
if jsonAry.Code != 0 {
publicmethod.Result(1, jsonErr, c, jsonAry.Msg)
return
}
menuThree = jsonAry.Data
} else {
var pointInt []string
var operatIon []string
var systemEmpowerCont modelssystempermission.RoleEmpower
err = systemEmpowerCont.GetCont(map[string]interface{}{"`role_id`": receivedValue.RoleId, "`system`": systemPower.Coder}, "`point_id`", `operation`)
if err == nil {
pointInt = strings.Split(systemEmpowerCont.PointId, ",")
operatIon = strings.Split(systemEmpowerCont.Operation, ",")
}
//api入口为空,采用系统内置获取授权菜单
switch systemPower.Coder {
case "cangchu":
menuThree = wmsMenuThree(pointInt, operatIon)
// fmt.Printf("ApiUrl----2-->%v\n", systemPower.ApiUrl)
default:
//获取绩效考核菜单树
menuThree = kpiMenuThree(pointInt, operatIon)
// fmt.Printf("ApiUrl---1--->%v\n", systemPower.ApiUrl)
}
}
publicmethod.Result(0, menuThree, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2022-11-07 13:46:06
@ 功能: 编辑权限新版(角色)
@ 参数
#
@ 返回值
#
*/
func (a *ApiMethod) EditRolePowerNew(c *gin.Context) {
var receivedValue editRolePowerStructNew
err := c.ShouldBindJSON(&receivedValue)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if receivedValue.RoleId == "" || receivedValue.RoleId == "0" {
publicmethod.Result(1, receivedValue, c, "未知角色!不可进行配权")
return
}
if receivedValue.SystemName == "" {
publicmethod.Result(1, receivedValue, c, "未知配权系统!不可进行配权")
return
}
if receivedValue.Level == 0 {
receivedValue.Level = 2
}
var menuList []string //权限点位
var menuOperationList []string //操作点位
addTime := time.Now().Unix()
var empowerCont modelssystempermission.RoleEmpower
err = empowerCont.GetCont(map[string]interface{}{"`role_id`": receivedValue.RoleId, "`system`": receivedValue.SystemName}, "`id`")
if len(receivedValue.PowerList) < 1 {
if err == nil {
err = empowerCont.EiteCont(map[string]interface{}{"`id`": empowerCont.Id}, map[string]interface{}{"`point_id`": "", "`operation`": "", "`level`": receivedValue.Level, "`time`": addTime, "`state`": 1})
if err != nil {
publicmethod.Result(1, err, c, "权限配置失败")
return
}
} else {
roleIdInt, _ := strconv.ParseInt(receivedValue.RoleId, 10, 64)
empowerCont.RoleId = roleIdInt //行政组织"`
empowerCont.System = receivedValue.SystemName //系统"`
empowerCont.PointId = strings.Join(menuList, ",") //权限点位"`
empowerCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
empowerCont.Time = addTime //创建时间"`
empowerCont.Level = receivedValue.Level //授权范围等级(1:本部门;2:本分部;3:所有)"`
empowerCont.Operation = strings.Join(menuOperationList, ",") //操作点位
err = overall.CONSTANT_DB_System_Permission.Create(&empowerCont).Error
if err != nil {
publicmethod.Result(1, err, c, "权限配置失败")
return
}
}
} else {
var munePowerList empowerSync
for _, v := range receivedValue.PowerList {
// if v.Id == "1" {
syncSeting.Add(1)
go munePowerList.GetAllSunCont(v)
// }
}
syncSeting.Wait()
menuIdList, menuOperIdList := munePowerList.readDataLock()
// fmt.Printf("\n\n%v-------结果-------->%v\n", menuIdList, menuOperIdList)
// publicmethod.Result(0, receivedValue.PowerList, c)
// return
// outData := publicmethod.MapOut[string]()
// outData["menuIdList"] = menuIdList
// outData["menuOperIdList"] = menuOperIdList
// publicmethod.Result(0, outData, c)
menuIdListStr := strings.Join(menuIdList, ",")
menuOperIdListStr := strings.Join(menuOperIdList, ",")
if err == nil {
err = empowerCont.EiteCont(map[string]interface{}{"`id`": empowerCont.Id}, map[string]interface{}{"`point_id`": menuIdListStr, "`operation`": menuOperIdListStr, "`level`": receivedValue.Level, "`time`": addTime, "`state`": 1})
if err != nil {
publicmethod.Result(1, err, c, "权限配置失败")
return
}
} else {
roleIdInt, _ := strconv.ParseInt(receivedValue.RoleId, 10, 64)
empowerCont.RoleId = roleIdInt //行政组织"`
empowerCont.System = receivedValue.SystemName //系统"`
empowerCont.PointId = menuIdListStr //权限点位"`
empowerCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
empowerCont.Time = addTime //创建时间"`
empowerCont.Level = receivedValue.Level //授权范围等级(1:本部门;2:本分部;3:所有)"`
empowerCont.Operation = menuOperIdListStr //操作点位
err = overall.CONSTANT_DB_System_Permission.Create(&empowerCont).Error
if err != nil {
publicmethod.Result(1, err, c, "权限配置失败")
return
}
}
}
publicmethod.Result(0, receivedValue, c)
}