Browse Source

仓储鉴权与配权完毕

master
超级管理员 3 years ago
parent
commit
046191112c
  1. 19
      identification/interceptor/identity.go
  2. 15
      overall/publicmethod/technique.go
  3. 6
      overall/publicmethod/type.go

19
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()
}
}

15
overall/publicmethod/technique.go

@ -694,6 +694,10 @@ func ComputingTime(timeStamp int64, timeType int) (timeDataInt int64) {
@system 系统标识
*/
func GetPostPower(ordid, postid int64, system string) (menuIdAry, menuUrl []string, err error) {
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 {
@ -710,6 +714,17 @@ func GetPostPower(ordid, postid int64, system string) (menuIdAry, menuUrl []stri
//绩效考核系统
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
}

6
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"`
}

Loading…
Cancel
Save