天翎MyApps技术社区 - 低代码平台 | 流程管理系统 | BPM软件

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

[常见问题] 如何判断指定的用户在指定部门是否具有指定的角色

[复制链接]
lingling17 发表于 2020-12-28 20:33:45 | 显示全部楼层 |阅读模式
【myApps/OBPM版本号】:4.4stable sp21
【浏览器类型】:Chrome
【技术QQ群】:182378297
【问题描述】:如何判断指定的用户在指定部门是否具有指定的角色
  roleCode:角色编号   department:部门id
userId:用户ID

【解决方案】:
function isTheUserOwenTheDeptRolesByCode(userId, roleCode, department) {
    var doc = getCurrentDocument();
    var flag = false;
    var process = new Packages.cn.myapps.designtime.role.service.RoleServiceImpl();
    var role = process.findByRoleNo(roleCode, doc.getApplicationid());
    var roleId = role.getId();
    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 + "' ";
    var count = countBySQL(sql);
    if (count > 0) {
        flag = true;
    }
    return flag;
};

本版积分规则

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

GMT+8, 2026-8-12 06:45

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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