|
@@ -53,6 +53,7 @@ type JYMenu struct {
|
|
|
Children []*JYMenu //菜单s
|
|
|
Authority int //权限逻辑备注 默认0:功能权限、资源权限、留资权限必须全部满足;1:功能权限或资源权限或留资权限满足其一就行;
|
|
|
Level int //1:一级菜单;2:二级菜单;3:三级菜单;4:四级菜单
|
|
|
+ Exclude string //不需要显示菜单权限集合
|
|
|
}
|
|
|
|
|
|
type Additional struct {
|
|
@@ -102,6 +103,7 @@ func (m *WorkDesktopMenu) GetMenuTreeData() error {
|
|
|
PermissionCode: MC.ObjToString(v["permissioncode"]),
|
|
|
CapitalCode: MC.ObjToString(v["capitalcode"]),
|
|
|
Authority: MC.IntAll(v["authority"]),
|
|
|
+ Exclude: MC.ObjToString(v["exclude"]),
|
|
|
}
|
|
|
var OpenType = map[string]string{}
|
|
|
if err := json.Unmarshal([]byte(MC.ObjToString(v["opentype"])), &OpenType); err == nil {
|
|
@@ -169,9 +171,13 @@ func (m *WorkDesktopMenu) WorkMenuFormat() ([]*pb.MenuList, error) {
|
|
|
// continue
|
|
|
//}
|
|
|
//0:默认展示;1:需验证权限,有权限展示;2:需验证权限,无权限也可展示(可用服务无权限不展示)
|
|
|
- usable := m.VerifyPermissions(mv.PowerIds)
|
|
|
+ pBool := m.VerifyPermissions(mv.PowerIds, mv.Exclude)
|
|
|
//checkCode==1 验证权限结果 无权限不显示
|
|
|
- if !usable && mv.CheckCode == 1 {
|
|
|
+ if !pBool.HasBool && mv.CheckCode == 1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ //有权限 验证是否需要展示--->excludeBool
|
|
|
+ if pBool.ExcludeBool {
|
|
|
continue
|
|
|
}
|
|
|
//GetResources(m.AppId, m.NewUserId, m.EntId, m.EntUserId)
|
|
@@ -180,7 +186,7 @@ func (m *WorkDesktopMenu) WorkMenuFormat() ([]*pb.MenuList, error) {
|
|
|
Icon: mv.Icon,
|
|
|
Url: mv.Url,
|
|
|
Id: encrypt.SE.EncodeString(strconv.Itoa(mv.Id)), //功能id加密
|
|
|
- Usable: usable, //MC.If(mv.PowerIds != "", usable && mv.CheckCode == 1, true).(bool),
|
|
|
+ Usable: pBool.HasBool, //MC.If(mv.PowerIds != "", usable && mv.CheckCode == 1, true).(bool),
|
|
|
AppType: mv.AppType,
|
|
|
OpenType: mv.OpenType,
|
|
|
Child: []*pb.SecondLevelMenu{},
|
|
@@ -198,9 +204,13 @@ func (m *WorkDesktopMenu) WorkMenuFormat() ([]*pb.MenuList, error) {
|
|
|
if len(mv.Children) > 0 {
|
|
|
for _, sv := range mv.Children {
|
|
|
//0:默认展示;1:需验证权限,有权限展示;2:需验证权限,无权限也可展示(可用服务无权限不展示)
|
|
|
- usable := m.VerifyPermissions(sv.PowerIds)
|
|
|
+ pBool := m.VerifyPermissions(sv.PowerIds, sv.Exclude)
|
|
|
//checkCode==1 验证权限结果 无权限不显示
|
|
|
- if !usable && sv.CheckCode == 1 {
|
|
|
+ if !pBool.HasBool && sv.CheckCode == 1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ //有权限 验证是否需要展示--->excludeBool
|
|
|
+ if pBool.ExcludeBool {
|
|
|
continue
|
|
|
}
|
|
|
secondLevel := &pb.SecondLevelMenu{
|
|
@@ -208,7 +218,7 @@ func (m *WorkDesktopMenu) WorkMenuFormat() ([]*pb.MenuList, error) {
|
|
|
Icon: sv.Icon,
|
|
|
Url: sv.Url,
|
|
|
Id: encrypt.SE.EncodeString(strconv.Itoa(sv.Id)), //功能id加密
|
|
|
- Usable: usable, //MC.If(sv.PowerIds != "", usable && sv.CheckCode == 1, true).(bool),
|
|
|
+ Usable: pBool.HasBool, //MC.If(sv.PowerIds != "", usable && sv.CheckCode == 1, true).(bool),
|
|
|
Child: []*pb.ThreeLevelMenu{},
|
|
|
AppType: sv.AppType,
|
|
|
OpenType: sv.OpenType,
|
|
@@ -227,26 +237,29 @@ func (m *WorkDesktopMenu) WorkMenuFormat() ([]*pb.MenuList, error) {
|
|
|
for _, tv := range sv.Children {
|
|
|
//附件下载包、采购单位画像记录、企业画像记录 如果是大会员 排除此三项菜单
|
|
|
//灵活性降低
|
|
|
- if (strings.Contains(tv.Name, "附件下载包") && m.VerifyPermissions("3")) || (tv.Name == "采购单位画像记录" && m.VerifyPermissions("5")) || (tv.Name == "企业画像记录" && m.VerifyPermissions("4,12,13,19,20,21,23")) {
|
|
|
+ if (strings.Contains(tv.Name, "附件下载包") && m.VerifyPermissions("3", "").HasBool) || (tv.Name == "采购单位画像记录" && m.VerifyPermissions("5", "").HasBool) || (tv.Name == "企业画像记录" && m.VerifyPermissions("4,12,13,19,20,21,23", "").HasBool) {
|
|
|
continue
|
|
|
}
|
|
|
//0:默认展示;1:需验证权限,有权限展示;2:需验证权限,无权限也可展示(可用服务无权限不展示)
|
|
|
- usable := m.VerifyPermissions(tv.PowerIds)
|
|
|
+ pBool := m.VerifyPermissions(tv.PowerIds, tv.Exclude)
|
|
|
//checkCode==1 验证权限结果 无权限不显示
|
|
|
- if !usable && tv.CheckCode == 1 {
|
|
|
+ if !pBool.HasBool && tv.CheckCode == 1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ //有权限 验证是否需要展示--->excludeBool
|
|
|
+ if pBool.ExcludeBool {
|
|
|
continue
|
|
|
}
|
|
|
var (
|
|
|
//数据库默认提示弹窗信息
|
|
|
- title, content, confirmUrl, confirmText, isShowCancel, appType, openType, feasibility = tv.AdditionalInfo[m.Platform].Title, tv.AdditionalInfo[m.Platform].Content, tv.AdditionalInfo[m.Platform].ConfirmUrl, tv.AdditionalInfo[m.Platform].ConfirmText, tv.AdditionalInfo[m.Platform].IsShowCancel, tv.AdditionalInfo[m.Platform].AppType, tv.AdditionalInfo[m.Platform].OpenType, usable
|
|
|
+ title, content, confirmUrl, confirmText, isShowCancel, appType, openType, feasibility = tv.AdditionalInfo[m.Platform].Title, tv.AdditionalInfo[m.Platform].Content, tv.AdditionalInfo[m.Platform].ConfirmUrl, tv.AdditionalInfo[m.Platform].ConfirmText, tv.AdditionalInfo[m.Platform].IsShowCancel, tv.AdditionalInfo[m.Platform].AppType, tv.AdditionalInfo[m.Platform].OpenType, pBool.HasBool
|
|
|
)
|
|
|
-
|
|
|
//三级菜单------
|
|
|
if len(tv.Children) == 0 && (tv.CapitalCode != "" || tv.PermissionCode != "") {
|
|
|
//用户是否需要留资
|
|
|
//资源中台获取用户权限--没有权限:title等置空
|
|
|
//ResourceLib.PowerHandle()
|
|
|
- title, content, confirmUrl, confirmText, appType, openType, isShowCancel, feasibility = CheckCapitalResources(tv, m, usable, m.VerifyPermissions(tv.PermissionCode))
|
|
|
+ title, content, confirmUrl, confirmText, appType, openType, isShowCancel, feasibility = CheckCapitalResources(tv, m, pBool.HasBool, m.VerifyPermissions(tv.PermissionCode, "").HasBool)
|
|
|
}
|
|
|
//弹框地址处理
|
|
|
threeLevel := &pb.ThreeLevelMenu{
|
|
@@ -279,7 +292,7 @@ func (m *WorkDesktopMenu) WorkMenuFormat() ([]*pb.MenuList, error) {
|
|
|
//资源中台获取用户权限--没有权限:title等置空
|
|
|
//ResourceLib.PowerHandle()
|
|
|
//判断资源中台权限
|
|
|
- title, content, confirmUrl, confirmText, appType, openType, isShowCancel, feasibility = CheckCapitalResources(fv, m, usable, m.VerifyPermissions(fv.PermissionCode))
|
|
|
+ title, content, confirmUrl, confirmText, appType, openType, isShowCancel, feasibility = CheckCapitalResources(fv, m, pBool.HasBool, m.VerifyPermissions(fv.PermissionCode, "").HasBool)
|
|
|
}
|
|
|
threeLevel.Url = MC.If(fv.Url != "", fv.Url, tv.Url).(string)
|
|
|
threeLevel.Icon = MC.If(fv.Icon != "", fv.Icon, tv.Icon).(string)
|
|
@@ -300,7 +313,7 @@ func (m *WorkDesktopMenu) WorkMenuFormat() ([]*pb.MenuList, error) {
|
|
|
threeLevel.Match = MC.If(fv.Match != "", strings.Split(fv.Match, ","), []string{}).([]string)
|
|
|
//四级菜单必须有顺序性,大会员》商机管理》超级订阅》免费用户
|
|
|
name := MC.If(strings.Contains(fv.Name, "-"), strings.Split(fv.Name, "-")[0], "免费").(string)
|
|
|
- if len(UserRolePowers[name]) > 0 && m.VerifyPermissions(strings.Join(UserRolePowers[name], ",")) && m.VerifyPermissions(fv.PowerIds) {
|
|
|
+ if len(UserRolePowers[name]) > 0 && m.VerifyPermissions(strings.Join(UserRolePowers[name], ","), "").HasBool && m.VerifyPermissions(fv.PowerIds, "").HasBool {
|
|
|
break L
|
|
|
}
|
|
|
}
|
|
@@ -344,21 +357,35 @@ func (m *WorkDesktopMenu) WorkMenuFormat() ([]*pb.MenuList, error) {
|
|
|
return menuList, nil
|
|
|
}
|
|
|
|
|
|
+type PowersBool struct {
|
|
|
+ HasBool bool
|
|
|
+ ExcludeBool bool
|
|
|
+}
|
|
|
+
|
|
|
// VerifyPermissions 是否有权限可用此服务
|
|
|
-func (m *WorkDesktopMenu) VerifyPermissions(powerIds string) (b bool) {
|
|
|
+func (m *WorkDesktopMenu) VerifyPermissions(powerIds string, excludeCodes string) (pb *PowersBool) {
|
|
|
+ pb = &PowersBool{}
|
|
|
if powerIds == "" {
|
|
|
- return true
|
|
|
+ pb.HasBool = true
|
|
|
}
|
|
|
- if len(strings.Split(powerIds, ",")) > 0 {
|
|
|
+ if powerIds != "" || excludeCodes != "" {
|
|
|
userPower := m.AutoUserPowerInfo() //m.TimeOut, m.BigMemberOff,
|
|
|
- func(powerIds string) {
|
|
|
+ if len(strings.Split(powerIds, ",")) > 0 {
|
|
|
for _, pv := range strings.Split(powerIds, ",") {
|
|
|
if userPower[pv] > 0 {
|
|
|
- b = true
|
|
|
+ pb.HasBool = true
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
- }(powerIds)
|
|
|
+ }
|
|
|
+ if len(strings.Split(excludeCodes, ",")) > 0 {
|
|
|
+ for _, pv := range strings.Split(excludeCodes, ",") {
|
|
|
+ if userPower[pv] > 0 {
|
|
|
+ pb.ExcludeBool = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -444,19 +471,23 @@ func (m *WorkDesktopMenu) CommonlyFormat(childMenus map[int][]*JYMenu) ([]*pb.Th
|
|
|
}
|
|
|
//附件下载包、采购单位画像记录、企业画像记录 如果是大会员 排除此三项菜单
|
|
|
//灵活性降低
|
|
|
- if (mv.Name == "附件下载包" && m.VerifyPermissions("3")) || (mv.Name == "采购单位画像记录" && m.VerifyPermissions("5")) || (mv.Name == "企业画像记录" && m.VerifyPermissions("4,12,13,19,20,21,23")) {
|
|
|
+ if (mv.Name == "附件下载包" && m.VerifyPermissions("3", "").HasBool) || (mv.Name == "采购单位画像记录" && m.VerifyPermissions("5", "").HasBool) || (mv.Name == "企业画像记录" && m.VerifyPermissions("4,12,13,19,20,21,23", "").HasBool) {
|
|
|
delBool = true
|
|
|
continue
|
|
|
}
|
|
|
- saveIds = append(saveIds, encrypt.SE.EncodeString(strconv.Itoa(mv.Id)))
|
|
|
- subLevel[mv.Id] = true
|
|
|
//0:默认展示;1:需验证权限,有权限展示;2:需验证权限,无权限也可展示(可用服务无权限不展示)
|
|
|
- usable := m.VerifyPermissions(mv.PowerIds)
|
|
|
- feasibility := usable
|
|
|
+ pBool := m.VerifyPermissions(mv.PowerIds, mv.Exclude)
|
|
|
+ if pBool.ExcludeBool {
|
|
|
+ delBool = true
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ feasibility := pBool.HasBool
|
|
|
//三级菜单------
|
|
|
if len(childMenus[mv.Id]) == 0 && (mv.CapitalCode != "" || mv.PermissionCode != "") {
|
|
|
- _, _, _, _, _, _, _, feasibility = CheckCapitalResources(mv, m, usable, m.VerifyPermissions(mv.PermissionCode))
|
|
|
+ _, _, _, _, _, _, _, feasibility = CheckCapitalResources(mv, m, pBool.HasBool, m.VerifyPermissions(mv.PermissionCode, "").HasBool)
|
|
|
}
|
|
|
+ saveIds = append(saveIds, encrypt.SE.EncodeString(strconv.Itoa(mv.Id)))
|
|
|
+ subLevel[mv.Id] = true
|
|
|
oneLevel := &pb.ThreeLevelMenu{
|
|
|
Name: mv.Name,
|
|
|
Icon: mv.Icon,
|
|
@@ -489,7 +520,7 @@ func (m *WorkDesktopMenu) CommonlyFormat(childMenus map[int][]*JYMenu) ([]*pb.Th
|
|
|
continue
|
|
|
}
|
|
|
if cv.CapitalCode != "" || cv.PermissionCode != "" {
|
|
|
- _, _, _, _, _, _, _, feasibility = CheckCapitalResources(cv, m, usable, m.VerifyPermissions(cv.PermissionCode))
|
|
|
+ _, _, _, _, _, _, _, feasibility = CheckCapitalResources(cv, m, pBool.HasBool, m.VerifyPermissions(cv.PermissionCode, "").HasBool)
|
|
|
}
|
|
|
oneLevel.Url = MC.If(cv.Url != "", cv.Url, mv.Url).(string)
|
|
|
oneLevel.Icon = MC.If(cv.Icon != "", cv.Icon, mv.Icon).(string)
|
|
@@ -509,7 +540,7 @@ func (m *WorkDesktopMenu) CommonlyFormat(childMenus map[int][]*JYMenu) ([]*pb.Th
|
|
|
}
|
|
|
oneLevel.Match = MC.If(cv.Match != "", strings.Split(cv.Match, ","), []string{}).([]string)
|
|
|
name := MC.If(strings.Contains(cv.Name, "-"), strings.Split(cv.Name, "-")[0], "免费").(string)
|
|
|
- if len(UserRolePowers[name]) > 0 && m.VerifyPermissions(strings.Join(UserRolePowers[name], ",")) {
|
|
|
+ if len(UserRolePowers[name]) > 0 && m.VerifyPermissions(strings.Join(UserRolePowers[name], ","), "").HasBool {
|
|
|
break L
|
|
|
}
|
|
|
}
|