diff --git a/identification/interceptor/identity.go b/identification/interceptor/identity.go index 6327a83..bfe4a0b 100644 --- a/identification/interceptor/identity.go +++ b/identification/interceptor/identity.go @@ -121,7 +121,7 @@ func VerifyUrl() gin.HandlerFunc { systemClass := c.Request.Header.Get("system-class") context, exi := publicmethod.LoginMyCont(c) if exi != nil { - response.FailWithDetailed(gin.H{"reload": false, "code": 303, "data": exi}, exi.Error(), c) + response.FailWithDetailed(gin.H{"reload": false, "code": 401}, "对不起!你没有访问此功能的权限!", c) c.Abort() return } @@ -130,8 +130,21 @@ func VerifyUrl() gin.HandlerFunc { // 获取请求方法 act := c.Request.Method - // publicmethod.GetPostPower(context.AdminOrg, context.Position, "kpi") - fmt.Printf("obj------>%v-----------act------->%v---systemClass------------>%v------------------context-------->%v\n", obj, act, systemClass, context.Role) + menuIdAry, menuUrl, err := publicmethod.GetPostPower(context.AdminOrg, context.Position, "kpi") + //此功能暂时不开启 + // if err != nil || len(menuUrl) < 1 || len(menuIdAry) < 1 { + // response.FailWithDetailed(gin.H{"reload": false, "code": 402}, "对不起!你没有访问此功能的权限!", c) + // c.Abort() + // return + // } + fmt.Printf("obj------>%v-----------act------->%v---systemClass------------>%v------------------context-------->%v-------->menuIdAry-------->%v-------->menuUrl-------->%v-------->err-------->%v\n", obj, act, systemClass, context.Role, menuIdAry, menuUrl, err) + //此功能暂时不开启 + // if publicmethod.IsInTrue[string](obj, menuUrl) == false { + // response.FailWithDetailed(gin.H{"reload": false, "code": 403}, "对不起!你没有访问此功能的权限!", c) + // c.Abort() + // return + // } + c.Next() } } diff --git a/overall/publicmethod/technique.go b/overall/publicmethod/technique.go index 945c542..2e0634c 100644 --- a/overall/publicmethod/technique.go +++ b/overall/publicmethod/technique.go @@ -694,22 +694,37 @@ func ComputingTime(timeStamp int64, timeType int) (timeDataInt int64) { @system 系统标识 */ func GetPostPower(ordid, postid int64, system string) (menuIdAry, menuUrl []string, err error) { - var ponitId string - err = overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.Empower{}).Select("`point_id`").Where("`state` = 1 AND `post_id` = ? AND `system` = ?", postid, system).Find(&ponitId).Error - if err != nil { - return - } - menuIdAry = strings.Split(ponitId, ",") - if len(menuIdAry) < 1 { - return - } - switch system { - case "cangchu": - menuUrl, err = getStorageSystemEmpower(menuIdAry) - default: - //绩效考核系统 - menuUrl, err = getKpiSystemEmpower(menuIdAry) + redisFileEmpowerKey := fmt.Sprintf("ScanCode:SystemEmpower:Authorize_%v_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, system, postid) + redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) + empowerRedisToken, isTrue := redisClient.HashGetAll(redisFileEmpowerKey) + if isTrue == false { + var ponitId string + err = overall.CONSTANT_DB_System_Permission.Model(&modelssystempermission.Empower{}).Select("`point_id`").Where("`state` = 1 AND `post_id` = ? AND `system` = ?", postid, system).Find(&ponitId).Error + if err != nil { + return + } + menuIdAry = strings.Split(ponitId, ",") + if len(menuIdAry) < 1 { + return + } + switch system { + case "cangchu": + menuUrl, err = getStorageSystemEmpower(menuIdAry) + default: + //绩效考核系统 + menuUrl, err = getKpiSystemEmpower(menuIdAry) + } + writeRedisData := MapOut[string]() + writeRedisData["menuid"] = strings.Join(menuIdAry, ",") + writeRedisData["menuurl"] = strings.Join(menuUrl, "|_^_|") + redisClient.SetRedisTime(10800) + redisClient.HashMsetAdd(redisFileEmpowerKey, writeRedisData) + } else { + // fmt.Printf("empowerRedisToken--->%v\n", empowerRedisToken) + menuIdAry = strings.Split(empowerRedisToken["menuid"], ",") + menuUrl = strings.Split(empowerRedisToken["menuurl"], "|_^_|") } + return } diff --git a/overall/publicmethod/type.go b/overall/publicmethod/type.go index 43a060a..12b5ca1 100644 --- a/overall/publicmethod/type.go +++ b/overall/publicmethod/type.go @@ -56,3 +56,9 @@ type EnclosureFormat struct { FilePath string `json:"filepath"` //附件地址 FileType int `json:"filetype"` //附件类型 1:图片;2:视频;3:表格;4:word;5:pdf;7:其他文件 } + +//授权输出 +type empowerOut struct { + MenuIdAry []string `json:"menuid"` + MenuUrl []string `json:"menuurl"` +}