找回密码
 注册成为天翎用户
查看: 757|回复: 1

[已解决] 角色视图权限问题

[复制链接]
问题收集小助手 发表于 2021-3-5 17:51:48 | 显示全部楼层 |阅读模式
本帖最后由 lingling17 于 2021-3-10 23:16 编辑

【myApps/OBPM版本号】:v4.4- sp 22
【浏览器类型】:Chrome/其他
【联系方式-QQ】:
【联系电话】:
【问题描述】:角色里面,我没有给他这个视图的权限,但是这个角色还可以进去,怎么回事?
smart 发表于 2021-3-8 16:41:01 | 显示全部楼层
脚本逻辑出错导致,参考示例
  1. /**
  2. *判断指定的用户在指定部门是否具有指定的角色
  3. *roleCode:角色编号   department:部门id
  4. *userId:用户ID
  5. */
  6. function isTheUserOwenTheDeptRolesByCode(userId, roleCode, department) {
  7.     var doc = getCurrentDocument();
  8.     var flag = false;
  9.     var process = new Packages.cn.myapps.designtime.role.service.RoleServiceImpl();
  10.     var role = process.findByRoleNo(roleCode, doc.getApplicationid());
  11.     var roleId = role.getId();
  12.     var sql = "select  '" + getDomainid() + "'AS DOMAINID , userid as item_userid from " + DATASOURENAME + ".t_user_department_role_set where departmentid='" + department + "' and roleid='" + roleId + "' and userid='" + userId + "' ";
  13.     var count = countBySQL(sql);
  14.     if (count > 0) {
  15.         flag = true;
  16.     }
  17.     return flag;
  18. };

  19. /**
  20. *根据角色编码判断当前用户是否具有下列角色(可以传多个角色编码)
  21. *roleCode:角色编码        传多个角色编码用";"隔开
  22. */
  23. function isOwenTheRolesByRoleCodes(roleCode) {
  24.     var applicationid = getApplication();
  25.     var flag = false;
  26.     var process = new Packages.cn.myapps.runtime.role.service.RoleServiceImpl();
  27.     if (roleCode != null && !"".equals(roleCode)) {
  28.         if (roleCode.indexOf(";") >= 0) {
  29.             var roleCodes = roleCode.split(";");
  30.             if (roleCodes != null && roleCodes.length > 0) {
  31.                 for (var i = 0; i < roleCodes.length; i++) {
  32.                     var roleCodeI = roleCodes[i];
  33.                     var role1 = process.findByRoleNo(roleCodeI, applicationid);
  34.                     if (role1 != null) {
  35.                         var crRoleId = role1.getId();
  36.                         if (crRoleId != null && !"".equals(crRoleId)) {
  37.                             var roles = getWebUser().getRoles();
  38.                             for (var it = roles.iterator(); roles != null && it.hasNext(); ) {
  39.                                 var role = it.next();
  40.                                 var roleId = role.getId();
  41.                                 if (crRoleId.equals(roleId)) {
  42.                                     flag = true;
  43.                                     break;
  44.                                 }
  45.                             }
  46.                         }
  47.                     }
  48.                 }
  49.             }
  50.         } else {
  51.             var role1 = process.findByRoleNo(roleCode, applicationid);
  52.             if (role1 != null) {
  53.                 var crRoleId = role1.getId();
  54.                 if (crRoleId != null && !"".equals(crRoleId)) {
  55.                     var roles = getWebUser().getRoles();
  56.                     for (var it = roles.iterator(); roles != null && it.hasNext(); ) {
  57.                         var role = it.next();
  58.                         var roleId = role.getId();

  59.                         if (crRoleId.equals(roleId)) {
  60.                             flag = true;
  61.                             break;
  62.                         }
  63.                     }
  64.                 }
  65.             }
  66.         }
  67.     }
  68.     return flag;
  69. };

复制代码
回复

使用道具 举报

本版积分规则

手机版|天翎MyApps技术社区 ( 粤ICP备11093750号 )

GMT+8, 2026-8-14 18:36

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表