Browse Source

仓储鉴权与配权完毕

master
超级管理员 3 years ago
parent
commit
046191112c
  1. 19
      identification/interceptor/identity.go
  2. 45
      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") systemClass := c.Request.Header.Get("system-class")
context, exi := publicmethod.LoginMyCont(c) context, exi := publicmethod.LoginMyCont(c)
if exi != nil { 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() c.Abort()
return return
} }
@ -130,8 +130,21 @@ func VerifyUrl() gin.HandlerFunc {
// 获取请求方法 // 获取请求方法
act := c.Request.Method act := c.Request.Method
// publicmethod.GetPostPower(context.AdminOrg, context.Position, "kpi") menuIdAry, menuUrl, err := publicmethod.GetPostPower(context.AdminOrg, context.Position, "kpi")
fmt.Printf("obj------>%v-----------act------->%v---systemClass------------>%v------------------context-------->%v\n", obj, act, systemClass, context.Role) //此功能暂时不开启
// 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() c.Next()
} }
} }

45
overall/publicmethod/technique.go

@ -694,22 +694,37 @@ func ComputingTime(timeStamp int64, timeType int) (timeDataInt int64) {
@system 系统标识 @system 系统标识
*/ */
func GetPostPower(ordid, postid int64, system string) (menuIdAry, menuUrl []string, err error) { func GetPostPower(ordid, postid int64, system string) (menuIdAry, menuUrl []string, err error) {
var ponitId string redisFileEmpowerKey := fmt.Sprintf("ScanCode:SystemEmpower:Authorize_%v_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, system, postid)
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 redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5)
if err != nil { empowerRedisToken, isTrue := redisClient.HashGetAll(redisFileEmpowerKey)
return if isTrue == false {
} var ponitId string
menuIdAry = strings.Split(ponitId, ",") 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 len(menuIdAry) < 1 { if err != nil {
return return
} }
switch system { menuIdAry = strings.Split(ponitId, ",")
case "cangchu": if len(menuIdAry) < 1 {
menuUrl, err = getStorageSystemEmpower(menuIdAry) return
default: }
//绩效考核系统 switch system {
menuUrl, err = getKpiSystemEmpower(menuIdAry) 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 return
} }

6
overall/publicmethod/type.go

@ -56,3 +56,9 @@ type EnclosureFormat struct {
FilePath string `json:"filepath"` //附件地址 FilePath string `json:"filepath"` //附件地址
FileType int `json:"filetype"` //附件类型 1:图片;2:视频;3:表格;4:word;5:pdf;7:其他文件 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