workDesktop.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. package entity
  2. import (
  3. MC "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/encrypt"
  5. "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
  6. "database/sql"
  7. "encoding/json"
  8. "errors"
  9. "fmt"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. "sort"
  12. "strconv"
  13. "strings"
  14. )
  15. // WorkDesktopMenu 工作桌面菜单信息
  16. type WorkDesktopMenu struct {
  17. MenuTree []*JYMenu //菜单
  18. UserId string //用户id
  19. NewUserId string //base_userid
  20. EntId int64 //企业id
  21. EntUserId int64 //企业用户id
  22. AppId string //appid 剑鱼:10000
  23. IntranetBool bool //是否开启内网访问模式
  24. Platform string //平台来源
  25. WorkStatus int64 //菜单分组
  26. }
  27. // JYMenu 工作桌面菜单内容
  28. type JYMenu struct {
  29. Id int
  30. Name string //菜单名称
  31. Match string //滤镜过滤正则
  32. OrderId int //菜单排序id
  33. ParentId int //父级id
  34. PowerIds string //权限id
  35. CheckCode int //是否必须验证权限才显示菜单
  36. Url string //菜单跳转链接
  37. Icon string //菜单图标
  38. AdditionalInfo Additional //附加弹窗信息
  39. AppType string //菜单模式
  40. OpenType string //打开方式
  41. Status int //是否是可用服务
  42. PermissionCode string //功能代码
  43. CapitalCode string //留资代码
  44. CapitalInfo Additional //留资弹窗
  45. Children []*JYMenu //菜单s
  46. Authority int //权限逻辑备注 默认0:功能权限、资源权限、留资权限必须全部满足;1:功能权限或资源权限或留资权限满足其一就行;
  47. Level int //1:一级菜单;2:二级菜单;3:三级菜单;4:四级菜单
  48. }
  49. type Additional struct {
  50. Title string `json:"title"` //弹窗标题
  51. Content string `json:"content"` //弹窗提示信息
  52. ConfirmUrl string `json:"confirmUrl,optional"` //确认按钮跳转地址
  53. ConfirmText string `json:"confirmText,optional"` //确认按钮
  54. IsShowCancel bool `json:"isShowCancel,optional"` //是否显示取消按钮
  55. AppType string `json:"appType,optional,omitempty"` //跳转方式
  56. OpenType string `json:"openType,optional,omitempty"`
  57. }
  58. // 获取有效菜单数据
  59. func (m *WorkDesktopMenu) GetMenuTreeData() error {
  60. //tidb数据
  61. //query := `SELECT * FROM ` + ConfigJson.WorkTableOut + ` WHERE appid=? AND status=0 ORDER BY id ASC`
  62. //if m.WorkStatus > 0 {
  63. query := fmt.Sprintf(`SELECT * FROM `+ConfigJson.WorkTableOut+` WHERE appid=? AND status=%d ORDER BY id ASC`, m.WorkStatus)
  64. //}
  65. //是否开启内网访问数据权限---对应 api 配置文件
  66. if m.IntranetBool {
  67. query = `SELECT * FROM ` + ConfigJson.WorkTableInside + ` WHERE appid=? AND status>=0 ORDER BY id ASC`
  68. }
  69. menuData := BaseMysql.SelectBySql(query, m.AppId)
  70. if menuData == nil || len(*menuData) == 0 {
  71. return errors.New("查询数据异常")
  72. }
  73. for _, v := range *menuData {
  74. menu := &JYMenu{
  75. Id: MC.IntAll(v["id"]),
  76. Name: MC.ObjToString(v["name"]),
  77. Match: MC.ObjToString(v["match"]),
  78. OrderId: MC.IntAll(v["orderid"]),
  79. ParentId: MC.IntAll(v["parentid"]),
  80. PowerIds: MC.ObjToString(v["powerids"]),
  81. CheckCode: MC.IntAll(v["checkcode"]),
  82. Icon: MC.ObjToString(v["icon"]),
  83. AppType: MC.ObjToString(v["apptype"]),
  84. OpenType: MC.ObjToString(v["opentype"]),
  85. Status: MC.IntAll(v["status"]),
  86. PermissionCode: MC.ObjToString(v["permissioncode"]),
  87. CapitalCode: MC.ObjToString(v["capitalcode"]),
  88. Authority: MC.IntAll(v["authority"]),
  89. }
  90. var OpenType = map[string]string{}
  91. if err := json.Unmarshal([]byte(MC.ObjToString(v["opentype"])), &OpenType); err == nil {
  92. menu.OpenType = OpenType[m.Platform]
  93. }
  94. switch m.Platform {
  95. case "WX":
  96. menu.Url = MC.ObjToString(v["wxurl"])
  97. menu.PowerIds = MC.ObjToString(v["wxpids"])
  98. case "APP":
  99. menu.Url = MC.ObjToString(v["appurl"])
  100. menu.PowerIds = MC.ObjToString(v["apppids"])
  101. default:
  102. menu.Url = MC.ObjToString(v["pcurl"])
  103. }
  104. //菜单(移动端)是否需要显示:PC端菜单不需要在移动端显示;或移动端菜单不需要在PC端显示。
  105. if menu.Url == "-1" {
  106. continue
  107. }
  108. if additionalInfo := MC.ObjToString(v["additionalinfo"]); additionalInfo != "" {
  109. additional := Additional{}
  110. if json.Unmarshal([]byte(additionalInfo), &additional) == nil {
  111. menu.AdditionalInfo = additional
  112. }
  113. }
  114. if capitalinfo := MC.ObjToString(v["capitalinfo"]); capitalinfo != "" {
  115. additional := Additional{}
  116. if json.Unmarshal([]byte(capitalinfo), &additional) == nil {
  117. menu.CapitalInfo = additional
  118. }
  119. }
  120. if menu.Id > 0 {
  121. m.MenuTree = append(m.MenuTree, menu)
  122. }
  123. }
  124. return nil
  125. }
  126. // WorkMenuTree 菜单-格式化-tree
  127. func (m *WorkDesktopMenu) WorkMenuTree(parentId int) (jyMenu []*JYMenu) {
  128. jyMenu = make([]*JYMenu, 0)
  129. for _, mv := range m.MenuTree {
  130. if mv.ParentId == parentId {
  131. mv.Children = m.WorkMenuTree(mv.Id)
  132. sort.SliceStable(mv.Children, func(i, j int) bool {
  133. return mv.Children[i].OrderId < mv.Children[j].OrderId
  134. })
  135. jyMenu = append(jyMenu, mv)
  136. }
  137. }
  138. sort.SliceStable(jyMenu, func(i, j int) bool {
  139. return jyMenu[i].OrderId < jyMenu[j].OrderId
  140. })
  141. return
  142. }
  143. // WorkMenuFormat 菜单 格式化
  144. func (m *WorkDesktopMenu) WorkMenuFormat() ([]*pb.MenuList, error) {
  145. //logx.Info("树的长度:", len(m.MenuTree))
  146. menuList := make([]*pb.MenuList, 0)
  147. for _, mv := range m.MenuTree {
  148. //if mv.Id < 466 {
  149. // continue
  150. //}
  151. //0:默认展示;1:需验证权限,有权限展示;2:需验证权限,无权限也可展示(可用服务无权限不展示)
  152. usable := m.VerifyPermissions(mv.PowerIds)
  153. //checkCode==1 验证权限结果 无权限不显示
  154. if !usable && mv.CheckCode == 1 {
  155. continue
  156. }
  157. //GetResources(m.AppId, m.NewUserId, m.EntId, m.EntUserId)
  158. oneLevel := &pb.MenuList{
  159. Name: mv.Name,
  160. Icon: mv.Icon,
  161. Url: mv.Url,
  162. Id: encrypt.SE.EncodeString(strconv.Itoa(mv.Id)), //功能id加密
  163. Usable: usable, //MC.If(mv.PowerIds != "", usable && mv.CheckCode == 1, true).(bool),
  164. AppType: mv.AppType,
  165. OpenType: mv.OpenType,
  166. Child: []*pb.SecondLevelMenu{},
  167. TipInfo: &pb.TipInfo{
  168. Title: mv.AdditionalInfo.Title,
  169. Content: mv.AdditionalInfo.Content,
  170. ConfirmUrl: mv.AdditionalInfo.ConfirmUrl,
  171. ConfirmText: mv.AdditionalInfo.ConfirmText,
  172. IsShowCancel: mv.AdditionalInfo.IsShowCancel,
  173. AppType: mv.AdditionalInfo.AppType,
  174. OpenType: mv.AdditionalInfo.OpenType,
  175. },
  176. Match: MC.If(mv.Match != "", strings.Split(mv.Match, ","), []string{}).([]string),
  177. }
  178. if len(mv.Children) > 0 {
  179. for _, sv := range mv.Children {
  180. //0:默认展示;1:需验证权限,有权限展示;2:需验证权限,无权限也可展示(可用服务无权限不展示)
  181. usable := m.VerifyPermissions(sv.PowerIds)
  182. //checkCode==1 验证权限结果 无权限不显示
  183. if !usable && sv.CheckCode == 1 {
  184. continue
  185. }
  186. secondLevel := &pb.SecondLevelMenu{
  187. Name: sv.Name,
  188. Icon: sv.Icon,
  189. Url: sv.Url,
  190. Id: encrypt.SE.EncodeString(strconv.Itoa(sv.Id)), //功能id加密
  191. Usable: usable, //MC.If(sv.PowerIds != "", usable && sv.CheckCode == 1, true).(bool),
  192. Child: []*pb.ThreeLevelMenu{},
  193. AppType: sv.AppType,
  194. OpenType: sv.OpenType,
  195. TipInfo: &pb.TipInfo{
  196. Title: sv.AdditionalInfo.Title,
  197. Content: sv.AdditionalInfo.Content,
  198. ConfirmUrl: sv.AdditionalInfo.ConfirmUrl,
  199. ConfirmText: sv.AdditionalInfo.ConfirmText,
  200. IsShowCancel: sv.AdditionalInfo.IsShowCancel,
  201. AppType: sv.AdditionalInfo.AppType,
  202. OpenType: sv.AdditionalInfo.OpenType,
  203. },
  204. Match: MC.If(sv.Match != "", strings.Split(sv.Match, ","), []string{}).([]string),
  205. }
  206. if len(sv.Children) > 0 {
  207. for _, tv := range sv.Children {
  208. //附件下载包、采购单位画像记录、企业画像记录 如果是大会员 排除此三项菜单
  209. //灵活性降低
  210. if (tv.Name == "附件下载包" && m.VerifyPermissions("3")) || (tv.Name == "采购单位画像记录" && m.VerifyPermissions("5")) || (tv.Name == "企业画像记录" && m.VerifyPermissions("4,12,13,19,20,21,23")) {
  211. continue
  212. }
  213. //0:默认展示;1:需验证权限,有权限展示;2:需验证权限,无权限也可展示(可用服务无权限不展示)
  214. usable := m.VerifyPermissions(tv.PowerIds)
  215. //checkCode==1 验证权限结果 无权限不显示
  216. if !usable && tv.CheckCode == 1 {
  217. continue
  218. }
  219. var (
  220. //数据库默认提示弹窗信息
  221. title, content, confirmUrl, confirmText, isShowCancel, appType, openType, feasibility = tv.AdditionalInfo.Title, tv.AdditionalInfo.Content, tv.AdditionalInfo.ConfirmUrl, tv.AdditionalInfo.ConfirmText, tv.AdditionalInfo.IsShowCancel, tv.AdditionalInfo.AppType, tv.AdditionalInfo.OpenType, usable
  222. )
  223. //三级菜单------
  224. if len(tv.Children) == 0 && (tv.CapitalCode != "" || tv.PermissionCode != "") {
  225. //用户是否需要留资
  226. //资源中台获取用户权限--没有权限:title等置空
  227. //ResourceLib.PowerHandle()
  228. title, content, confirmUrl, confirmText, appType, openType, isShowCancel, feasibility = CheckCapitalResources(tv, m, usable, m.VerifyPermissions(tv.PermissionCode))
  229. }
  230. threeLevel := &pb.ThreeLevelMenu{
  231. Name: tv.Name,
  232. Icon: tv.Icon,
  233. Url: tv.Url,
  234. Id: encrypt.SE.EncodeString(strconv.Itoa(tv.Id)), //功能id加密
  235. Usable: feasibility, //MC.If(tv.PowerIds != "", usable && tv.CheckCode == 1, true).(bool),
  236. AppType: tv.AppType,
  237. OpenType: tv.OpenType,
  238. TipInfo: &pb.TipInfo{
  239. Title: title,
  240. Content: content,
  241. ConfirmUrl: confirmUrl,
  242. ConfirmText: confirmText,
  243. IsShowCancel: isShowCancel,
  244. AppType: appType,
  245. OpenType: openType,
  246. },
  247. Match: MC.If(tv.Match != "", strings.Split(tv.Match, ","), []string{}).([]string),
  248. }
  249. if len(tv.Children) > 0 {
  250. L:
  251. for _, fv := range tv.Children {
  252. if fv.Name == "" {
  253. continue
  254. }
  255. if fv.CapitalCode != "" || fv.PermissionCode != "" {
  256. //用户是否需要留资
  257. //资源中台获取用户权限--没有权限:title等置空
  258. //ResourceLib.PowerHandle()
  259. //判断资源中台权限
  260. title, content, confirmUrl, confirmText, appType, openType, isShowCancel, feasibility = CheckCapitalResources(fv, m, usable, m.VerifyPermissions(fv.PermissionCode))
  261. }
  262. threeLevel.Url = MC.If(fv.Url != "", fv.Url, tv.Url).(string)
  263. threeLevel.Icon = MC.If(fv.Icon != "", fv.Icon, tv.Icon).(string)
  264. threeLevel.AppType = fv.AppType
  265. threeLevel.OpenType = fv.OpenType
  266. threeLevel.Usable = feasibility
  267. if title != "" {
  268. threeLevel.TipInfo = &pb.TipInfo{
  269. Title: title,
  270. Content: content,
  271. ConfirmUrl: confirmUrl,
  272. ConfirmText: confirmText,
  273. IsShowCancel: isShowCancel,
  274. AppType: appType,
  275. OpenType: openType,
  276. }
  277. }
  278. threeLevel.Match = MC.If(fv.Match != "", strings.Split(fv.Match, ","), []string{}).([]string)
  279. //四级菜单必须有顺序性,大会员》商机管理》超级订阅》免费用户
  280. name := MC.If(strings.Contains(fv.Name, "-"), strings.Split(fv.Name, "-")[0], "免费").(string)
  281. if len(UserRolePowers[name]) > 0 && m.VerifyPermissions(strings.Join(UserRolePowers[name], ",")) && m.VerifyPermissions(fv.PowerIds) {
  282. break L
  283. }
  284. }
  285. }
  286. //无资源中台权限 菜单不显示
  287. if !feasibility && tv.CheckCode == 1 {
  288. continue
  289. }
  290. if threeLevel != nil {
  291. secondLevel.Child = append(secondLevel.Child, threeLevel)
  292. }
  293. }
  294. }
  295. //二级菜单 有三级子菜单;才会显示
  296. if len(secondLevel.Child) == 0 && sv.CheckCode == 1 {
  297. continue
  298. }
  299. oneLevel.Child = append(oneLevel.Child, secondLevel)
  300. }
  301. }
  302. //一级菜单 有二级子菜单;才会显示
  303. if len(oneLevel.Child) == 0 && mv.CheckCode == 1 {
  304. continue
  305. }
  306. menuList = append(menuList, oneLevel)
  307. }
  308. //清用户内存信息
  309. func(baseUserid string) {
  310. OverallLock.Lock()
  311. defer OverallLock.Unlock()
  312. userInfo := UserInfoMap[baseUserid]
  313. if userInfo != nil {
  314. userInfo.Lock.Lock()
  315. defer userInfo.Lock.Unlock()
  316. userInfo.Permissions = map[string]int{}
  317. userInfo.Capitals = map[string]int{}
  318. }
  319. }(m.NewUserId)
  320. //bytes, _ := json.MarshalIndent(menuList, "", " ")
  321. //fmt.Printf("%s\n", bytes)
  322. return menuList, nil
  323. }
  324. // VerifyPermissions 是否有权限可用此服务
  325. func (m *WorkDesktopMenu) VerifyPermissions(powerIds string) (b bool) {
  326. if powerIds == "" {
  327. return true
  328. }
  329. if len(strings.Split(powerIds, ",")) > 0 {
  330. userPower := m.AutoUserPowerInfo() //m.TimeOut, m.BigMemberOff,
  331. func(powerIds string) {
  332. for _, pv := range strings.Split(powerIds, ",") {
  333. if userPower[pv] > 0 {
  334. b = true
  335. break
  336. }
  337. }
  338. }(powerIds)
  339. }
  340. return
  341. }
  342. // WorkCommonly 常用功能
  343. var (
  344. WorkCommonly = "work_commonly"
  345. //WorkMenu = "work_menu"
  346. )
  347. // CommonlyUpdate 更新常用功能
  348. func CommonlyUpdate(in *pb.WorkDesktopComprehensiveReq) (B bool, M string) {
  349. //事务 1:查; 2: 存;3: 删;
  350. var (
  351. ids []string
  352. mk int
  353. )
  354. for _, mid := range strings.Split(in.MenuIds, ",") {
  355. if mid == "" {
  356. continue
  357. }
  358. mk++
  359. //常用功能数量限制
  360. if ConfigJson.CommonlySize > 0 && mk >= int(ConfigJson.CommonlySize) {
  361. break
  362. }
  363. //id 解密
  364. ids = append(ids, encrypt.SE.DecodeString(mid))
  365. }
  366. logx.Info("------ids:", ids)
  367. //更新此用户设置的常用功能
  368. if B = BaseMysql.ExecTx("常用功能批量更新", func(tx *sql.Tx) bool {
  369. //查询此用户常用功能是否已存在记录
  370. var id = 0
  371. existingData := BaseMysql.SelectBySqlByTx(tx, `SELECT id FROM `+WorkCommonly+` WHERE base_userid = ? AND appid = ? AND field = ? ORDER BY id DESC `, in.NewUserId, in.AppId, in.ActionMode)
  372. if existingData != nil && len(*existingData) > 0 {
  373. id = MC.IntAll((*existingData)[0]["id"])
  374. }
  375. switch {
  376. case id > 0: //更新
  377. if BaseMysql.UpdateOrDeleteBySqlByTx(tx, `UPDATE `+WorkCommonly+` SET value = ? WHERE id = ?`, strings.Join(ids, ","), id) < 0 {
  378. logx.Info("常用功能-更新数据失败")
  379. return false
  380. }
  381. default: //插入
  382. if BaseMysql.InsertBySqlByTx(tx, `INSERT INTO `+WorkCommonly+` (appid,base_userid,platform,field,value) VALUES (?,?,?,?,?)`, in.AppId, in.NewUserId, in.Platform, in.ActionMode, strings.Join(ids, ",")) < 0 {
  383. logx.Info("常用功能-插入数据失败")
  384. return false
  385. }
  386. }
  387. return true
  388. }); !B {
  389. M = "常用功能更新数据失败"
  390. }
  391. return
  392. }
  393. // CommonlyFormat 常用功能 格式化
  394. func (m *WorkDesktopMenu) CommonlyFormat(childMenus map[int][]*JYMenu) ([]*pb.ThreeLevelMenu, []string, bool) {
  395. menuList := make([]*pb.ThreeLevelMenu, 0)
  396. subLevel := map[int]bool{}
  397. delBool := false //更新因超级订阅用户,又购买大会员得用户 导致附件下载包||采购单位画像记录||企业画像记录 不应该展示
  398. var saveIds []string
  399. for _, mv := range m.MenuTree {
  400. //三级菜单已处理,子级四级菜单不再处理
  401. //过滤子级 ++
  402. if subLevel[mv.ParentId] {
  403. continue
  404. }
  405. //三级下架菜单:mv.Status == 1
  406. if mv.Status == 1 {
  407. delBool = true
  408. continue
  409. }
  410. //附件下载包、采购单位画像记录、企业画像记录 如果是大会员 排除此三项菜单
  411. //灵活性降低
  412. if (mv.Name == "附件下载包" && m.VerifyPermissions("3")) || (mv.Name == "采购单位画像记录" && m.VerifyPermissions("5")) || (mv.Name == "企业画像记录" && m.VerifyPermissions("4,12,13,19,20,21,23")) {
  413. delBool = true
  414. continue
  415. }
  416. saveIds = append(saveIds, encrypt.SE.EncodeString(strconv.Itoa(mv.Id)))
  417. subLevel[mv.Id] = true
  418. //0:默认展示;1:需验证权限,有权限展示;2:需验证权限,无权限也可展示(可用服务无权限不展示)
  419. usable := m.VerifyPermissions(mv.PowerIds)
  420. feasibility := usable
  421. //三级菜单------
  422. if len(childMenus[mv.Id]) == 0 && (mv.CapitalCode != "" || mv.PermissionCode != "") {
  423. _, _, _, _, _, _, _, feasibility = CheckCapitalResources(mv, m, usable, m.VerifyPermissions(mv.PermissionCode))
  424. }
  425. oneLevel := &pb.ThreeLevelMenu{
  426. Name: mv.Name,
  427. Icon: mv.Icon,
  428. Url: mv.Url,
  429. Id: encrypt.SE.EncodeString(strconv.Itoa(mv.Id)), //功能id加密
  430. Usable: feasibility, //MC.If(mv.PowerIds != "", usable && mv.CheckCode == 1, true).(bool),
  431. AppType: mv.AppType,
  432. OpenType: mv.OpenType,
  433. TipInfo: &pb.TipInfo{
  434. Title: mv.AdditionalInfo.Title,
  435. Content: mv.AdditionalInfo.Content,
  436. ConfirmUrl: mv.AdditionalInfo.ConfirmUrl,
  437. ConfirmText: mv.AdditionalInfo.ConfirmText,
  438. IsShowCancel: mv.AdditionalInfo.IsShowCancel,
  439. AppType: mv.AppType,
  440. OpenType: mv.OpenType,
  441. },
  442. Match: MC.If(mv.Match != "", strings.Split(mv.Match, ","), []string{}).([]string),
  443. }
  444. //处理子级
  445. if childMenus[mv.Id] != nil && len(childMenus[mv.Id]) > 0 {
  446. childMenu := childMenus[mv.Id]
  447. sort.Slice(childMenu, func(i, j int) bool {
  448. return childMenu[i].OrderId > childMenu[j].OrderId
  449. })
  450. L:
  451. for _, cv := range childMenu {
  452. //cv.Status < 0 四级菜单 生效不再处理;因为常用功能设置保存的都是三级菜单id,如果三级菜单功能下架,只处理三级菜单。
  453. if cv.Name == "" || cv.ParentId != mv.Id || cv.Status < 0 {
  454. continue
  455. }
  456. if cv.CapitalCode != "" || cv.PermissionCode != "" {
  457. _, _, _, _, _, _, _, feasibility = CheckCapitalResources(cv, m, usable, m.VerifyPermissions(cv.PermissionCode))
  458. }
  459. oneLevel.Url = MC.If(cv.Url != "", cv.Url, mv.Url).(string)
  460. oneLevel.Icon = MC.If(cv.Icon != "", cv.Icon, mv.Icon).(string)
  461. oneLevel.AppType = cv.AppType
  462. oneLevel.OpenType = cv.OpenType
  463. oneLevel.Usable = feasibility
  464. if cv.AdditionalInfo.Title != "" {
  465. oneLevel.TipInfo = &pb.TipInfo{
  466. Title: cv.AdditionalInfo.Title,
  467. Content: cv.AdditionalInfo.Content,
  468. ConfirmUrl: cv.AdditionalInfo.ConfirmUrl,
  469. ConfirmText: cv.AdditionalInfo.ConfirmText,
  470. IsShowCancel: cv.AdditionalInfo.IsShowCancel,
  471. AppType: cv.AppType,
  472. OpenType: cv.OpenType,
  473. }
  474. }
  475. oneLevel.Match = MC.If(cv.Match != "", strings.Split(cv.Match, ","), []string{}).([]string)
  476. name := MC.If(strings.Contains(cv.Name, "-"), strings.Split(cv.Name, "-")[0], "免费").(string)
  477. if len(UserRolePowers[name]) > 0 && m.VerifyPermissions(strings.Join(UserRolePowers[name], ",")) {
  478. break L
  479. }
  480. }
  481. }
  482. //跨平台,非本平台功能,给用户提示信息
  483. if oneLevel.Url == "-1" {
  484. oneLevel.TipInfo = &pb.TipInfo{
  485. Title: ConfigJson.DefaultPopup[m.Platform].Title,
  486. Content: ConfigJson.DefaultPopup[m.Platform].Content,
  487. ConfirmUrl: ConfigJson.DefaultPopup[m.Platform].ConfirmUrl,
  488. ConfirmText: ConfigJson.DefaultPopup[m.Platform].ConfirmText,
  489. IsShowCancel: ConfigJson.DefaultPopup[m.Platform].IsShowCancel,
  490. }
  491. if oneLevel.TipInfo.ConfirmUrl == "" {
  492. oneLevel.TipInfo.AppType = ""
  493. oneLevel.TipInfo.OpenType = ""
  494. }
  495. oneLevel.Url = ""
  496. oneLevel.Usable = false
  497. }
  498. //1、当前平台有权限,清空提示信息
  499. //2、提示信息内容为空,清空提示信息
  500. if oneLevel.Usable || oneLevel.TipInfo.Content == "" {
  501. oneLevel.TipInfo = &pb.TipInfo{}
  502. }
  503. menuList = append(menuList, oneLevel)
  504. }
  505. return menuList, saveIds, delBool
  506. }