修改成多角色
This commit is contained in:
parent
eda4273efa
commit
eb70d0dd55
@ -144,8 +144,8 @@ public class SystemUser implements Serializable {
|
||||
private java.lang.String personMail;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "角色ID")
|
||||
private java.lang.Long roleId;
|
||||
@ApiModelProperty(value = "角色ID(多个,分割)")
|
||||
private java.lang.String roleId;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "岗位名称")
|
||||
|
||||
@ -22,7 +22,7 @@ public interface BaseRoleMapper extends BaseMapper<BaseRole> {
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
BaseRole selectRoleByUserId(@Param("userId") Long userId);
|
||||
List<BaseRole> selectRoleByUserId(@Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 根据项目sn删除角色权限关联数据
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
order by a.parent_id,a.priority
|
||||
</select>
|
||||
<select id="getProjectUserActionList" resultType="com.zhgd.jeecg.common.mybatis.EntityMap">
|
||||
SELECT t3.*,a1.authority_id,t3.action_name name
|
||||
SELECT distinct t3.*,a1.authority_id,t3.action_name name
|
||||
FROM base_role_user t INNER JOIN base_role t1 ON t.role_id=t1.role_id
|
||||
INNER JOIN base_authority_role t2 ON t.role_id=t2.role_id
|
||||
INNER JOIN base_authority a1 ON a1.authority_id=t2.authority_id
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
order by a.parent_id,a.priority
|
||||
</select>
|
||||
<select id="getProjectUserMenuList" resultType="com.zhgd.jeecg.common.mybatis.EntityMap">
|
||||
SELECT t3.*,a1.authority_id,t3.menu_name name
|
||||
SELECT distinct t3.*,a1.authority_id,t3.menu_name name
|
||||
FROM base_role_user t INNER JOIN base_role t1 ON t.role_id=t1.role_id
|
||||
INNER JOIN base_authority_role t2 ON t.role_id=t2.role_id
|
||||
INNER JOIN base_authority a1 ON a1.authority_id=t2.authority_id
|
||||
|
||||
@ -1,72 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper">
|
||||
<sql id="whereChildren">
|
||||
and t.sn = #{param.projectSn}
|
||||
and t.account_type = 6
|
||||
</sql>
|
||||
<sql id="where">
|
||||
<if test="param.isSupervisingRoleName == '1'.toString()">
|
||||
and c.role_name = '监理'
|
||||
</if>
|
||||
<if test="param.userId != null and param.userId != ''">
|
||||
and t.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.id != null and param.id != ''">
|
||||
and t.user_id = #{param.id}
|
||||
</if>
|
||||
<if test="param.workerName != null and param.workerName != ''">
|
||||
and d.worker_name like CONCAT(CONCAT('%', #{param.workerName}), '%')
|
||||
</if>
|
||||
<if test="param.workerId != null and param.workerId != ''">
|
||||
and d.id = #{param.workerId}
|
||||
</if>
|
||||
<if test="param.enterpriseIdList != null and param.enterpriseIdList.size() > 0">
|
||||
and d.enterprise_id in
|
||||
<foreach collection="param.enterpriseIdList" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="param.enterpriseTypeId != null and param.enterpriseTypeId != ''">
|
||||
and pe.enterprise_type_id = #{param.enterpriseTypeId}
|
||||
</if>
|
||||
<if test="param.xzProjectOrgId != null and param.xzProjectOrgId != ''">
|
||||
and xpo.id = #{param.xzProjectOrgId}
|
||||
</if>
|
||||
</sql>
|
||||
<sql id="selectTable">
|
||||
SELECT t.worker_id as id,
|
||||
if(t.account_type=6,d.worker_name,t.real_name) as real_name,
|
||||
if(t.account_type=6,d.sex,t.sex) as sex,
|
||||
if(t.account_type=6,d.phone_number,t.user_tel) as user_tel,
|
||||
CASE WHEN t.account_type=6 THEN d.person_mail WHEN t.account_type=10 or t.account_type=11 THEN xr.email ELSE
|
||||
t.person_mail END as person_mail,
|
||||
t.*,
|
||||
c.role_name,
|
||||
d.worker_name,
|
||||
b.role_id,
|
||||
po.dept_name as projectOrgName,
|
||||
d.enterprise_id,
|
||||
d.person_mail,
|
||||
ei.enterprise_name
|
||||
from system_user t
|
||||
LEFT JOIN base_role_user b ON t.user_id = b.user_id
|
||||
LEFT JOIN base_role c ON c.role_id = b.role_id
|
||||
LEFT JOIN worker_info d ON t.worker_id = d.id
|
||||
LEFT JOIN xz_project_org po on po.id=t.xz_project_org_id
|
||||
LEFT JOIN enterprise_info ei on ei.id=d.enterprise_id
|
||||
LEFT JOIN project_enterprise pe on pe.enterprise_id=ei.id and pe.project_sn=t.sn
|
||||
left join xz_project_org xpo on xpo.id=t.xz_project_org_id
|
||||
left join xz_registry xr on xr.account = t.account and xr.approval_process = 2
|
||||
<if test="param.qualityRegionId != null and param.qualityRegionId != '' and param.qualityRegionBindType == '1'.toString()">
|
||||
JOIN quality_region_to_user qrtu on ei.id = qrtu.enterprise_id and t.user_id=qrtu.user_id and
|
||||
qrtu.quality_region_id = #{param.qualityRegionId}
|
||||
</if>
|
||||
<if test="param.qualityRegionId != null and param.qualityRegionId != '' and param.qualityRegionBindType == '2'.toString()">
|
||||
JOIN quality_region_to_enterprise qrte on ei.id = qrte.enterprise_id and
|
||||
qrte.quality_region_id = #{param.qualityRegionId}
|
||||
</if>
|
||||
</sql>
|
||||
<select id="getSystemUsersBySn" resultType="com.zhgd.xmgl.modules.basicdata.entity.SystemUser" parameterType="map">
|
||||
SELECT a.*, jb.job_name
|
||||
from system_user a
|
||||
@ -93,14 +27,72 @@
|
||||
</select>
|
||||
<select id="getProjectChilderSystemUserList" resultType="com.zhgd.xmgl.modules.basicdata.entity.SystemUser"
|
||||
parameterType="map">
|
||||
<include refid="selectTable">
|
||||
</include>
|
||||
SELECT t.worker_id as id,
|
||||
if(t.account_type=6,d.worker_name,t.real_name) as real_name,
|
||||
if(t.account_type=6,d.sex,t.sex) as sex,
|
||||
if(t.account_type=6,d.phone_number,t.user_tel) as user_tel,
|
||||
CASE WHEN t.account_type=6 THEN d.person_mail WHEN t.account_type=10 or t.account_type=11 THEN xr.email ELSE
|
||||
t.person_mail END as person_mail,
|
||||
t.*,
|
||||
group_concat(distinct c.role_name) as role_name,
|
||||
group_concat(distinct b.role_id) as role_id,
|
||||
d.worker_name,
|
||||
po.dept_name as projectOrgName,
|
||||
d.enterprise_id,
|
||||
d.person_mail,
|
||||
ei.enterprise_name
|
||||
from system_user t
|
||||
LEFT JOIN base_role_user b ON t.user_id = b.user_id
|
||||
LEFT JOIN base_role c ON c.role_id = b.role_id
|
||||
LEFT JOIN worker_info d ON t.worker_id = d.id
|
||||
LEFT JOIN xz_project_org po on po.id=t.xz_project_org_id
|
||||
LEFT JOIN enterprise_info ei on ei.id=d.enterprise_id
|
||||
LEFT JOIN project_enterprise pe on pe.enterprise_id=ei.id and pe.project_sn=t.sn
|
||||
left join xz_project_org xpo on xpo.id=t.xz_project_org_id
|
||||
left join xz_registry xr on xr.account = t.account and xr.approval_process = 2
|
||||
<if test="param.qualityRegionId != null and param.qualityRegionId != '' and param.qualityRegionBindType == '1'.toString()">
|
||||
JOIN quality_region_to_user qrtu on ei.id = qrtu.enterprise_id and t.user_id=qrtu.user_id and
|
||||
qrtu.quality_region_id = #{param.qualityRegionId}
|
||||
</if>
|
||||
<if test="param.qualityRegionId != null and param.qualityRegionId != '' and param.qualityRegionBindType == '2'.toString()">
|
||||
JOIN quality_region_to_enterprise qrte on ei.id = qrte.enterprise_id and
|
||||
qrte.quality_region_id = #{param.qualityRegionId}
|
||||
</if>
|
||||
<where>
|
||||
<include refid="whereChildren">
|
||||
</include>
|
||||
<include refid="where">
|
||||
</include>
|
||||
and t.sn = #{param.projectSn}
|
||||
and t.account_type = 6
|
||||
<if test="param.isSupervisingRoleName == '1'.toString()">
|
||||
and c.role_name = '监理'
|
||||
</if>
|
||||
<if test="param.userId != null and param.userId != ''">
|
||||
and t.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.id != null and param.id != ''">
|
||||
and t.user_id = #{param.id}
|
||||
</if>
|
||||
<if test="param.workerName != null and param.workerName != ''">
|
||||
and d.worker_name like CONCAT(CONCAT('%', #{param.workerName}), '%')
|
||||
</if>
|
||||
<if test="param.workerId != null and param.workerId != ''">
|
||||
and d.id = #{param.workerId}
|
||||
</if>
|
||||
<if test="param.enterpriseIdList != null and param.enterpriseIdList.size() > 0">
|
||||
and d.enterprise_id in
|
||||
<foreach collection="param.enterpriseIdList" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="param.enterpriseTypeId != null and param.enterpriseTypeId != ''">
|
||||
and pe.enterprise_type_id = #{param.enterpriseTypeId}
|
||||
</if>
|
||||
<if test="param.xzProjectOrgId != null and param.xzProjectOrgId != ''">
|
||||
and xpo.id = #{param.xzProjectOrgId}
|
||||
</if>
|
||||
<if test="param.isSafetyAndMonitoringRoleName == '1'.toString() ">
|
||||
and c.role_name = '安全环保监察中心'
|
||||
</if>
|
||||
</where>
|
||||
group by t.user_id
|
||||
</select>
|
||||
<select id="findByUsername" resultType="com.zhgd.xmgl.modules.basicdata.entity.SystemUser" parameterType="string">
|
||||
select *
|
||||
@ -204,7 +196,7 @@
|
||||
</select>
|
||||
|
||||
<select id="selectDetailByUserIds" resultType="com.zhgd.xmgl.modules.basicdata.entity.SystemUser">
|
||||
select u.user_id, u.real_name, u.avatar, p.dept_name projectOrgName, r.role_name from system_user u
|
||||
select u.user_id, u.real_name, u.avatar, p.dept_name projectOrgName, group_concat(distinct r.role_name) as role_name from system_user u
|
||||
left join xz_project_org p on u.xz_project_org_id = p.id
|
||||
left join base_role_user ur on u.user_id = ur.user_id
|
||||
left join base_role r on r.role_id = ur.role_id
|
||||
@ -214,6 +206,7 @@
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
group by u.user_id
|
||||
</select>
|
||||
|
||||
<resultMap id="zjwjUserPage" type="com.zhgd.xmgl.modules.basicdata.entity.SystemUser" autoMapping="true">
|
||||
@ -274,8 +267,8 @@
|
||||
di.project_sn,
|
||||
di.enterprise_id,
|
||||
wi.id AS wi_id,
|
||||
br.role_id,
|
||||
br.role_name
|
||||
group_concat(distinct br.role_id) as role_id,
|
||||
group_concat(distinct br.role_name) as role_name
|
||||
FROM system_user AS su
|
||||
INNER JOIN worker_info AS wi ON wi.id = su.worker_id
|
||||
INNER JOIN department_info AS di ON di.id = wi.department_id
|
||||
@ -285,6 +278,7 @@
|
||||
<if test="s.departmentId != null">
|
||||
AND di.id = #{s.departmentId}
|
||||
</if>
|
||||
group by su.user_id
|
||||
</select>
|
||||
|
||||
<select id="getOrgSnListByUserId" resultType="java.lang.String">
|
||||
@ -311,12 +305,30 @@
|
||||
</select>
|
||||
|
||||
<select id="queryById" resultMap="zjwjUserPage">
|
||||
<include refid="selectTable">
|
||||
</include>
|
||||
<where>
|
||||
<include refid="where">
|
||||
</include>
|
||||
</where>
|
||||
SELECT t.worker_id as id,
|
||||
if(t.account_type=6,d.worker_name,t.real_name) as real_name,
|
||||
if(t.account_type=6,d.sex,t.sex) as sex,
|
||||
if(t.account_type=6,d.phone_number,t.user_tel) as user_tel,
|
||||
CASE WHEN t.account_type=6 THEN d.person_mail WHEN t.account_type=10 or t.account_type=11 THEN xr.email ELSE
|
||||
t.person_mail END as person_mail,
|
||||
t.*,
|
||||
group_concat(distinct c.role_name) as role_name,
|
||||
group_concat(distinct b.role_id) as role_id,
|
||||
d.worker_name,
|
||||
po.dept_name as projectOrgName,
|
||||
d.enterprise_id,
|
||||
d.person_mail
|
||||
from system_user t
|
||||
LEFT JOIN base_role_user b ON t.user_id = b.user_id
|
||||
LEFT JOIN base_role c ON c.role_id = b.role_id
|
||||
LEFT JOIN worker_info d ON t.worker_id = d.id
|
||||
LEFT JOIN xz_project_org po on po.id=t.xz_project_org_id
|
||||
LEFT JOIN enterprise_info ei on ei.id=d.enterprise_id
|
||||
LEFT JOIN project_enterprise pe on pe.enterprise_id=ei.id and pe.project_sn=t.sn
|
||||
left join xz_project_org xpo on xpo.id=t.xz_project_org_id
|
||||
left join xz_registry xr on xr.account = t.account and xr.approval_process = 2
|
||||
where t.user_id = #{param.id}
|
||||
group by t.user_id
|
||||
</select>
|
||||
|
||||
<update id="updateRealNameFromWorker">
|
||||
|
||||
@ -264,9 +264,9 @@ public class FlowOrgRepositoryServiceImpl implements OrgRepositoryService {
|
||||
public UserVo getUserDetail(String userId) {
|
||||
SystemUser user = systemUserMapper.selectById(userId);
|
||||
List<DeptDo> depts = getDeptsByUser(userId);
|
||||
BaseRole roles = systemRoleMapper.selectRoleByUserId(user.getUserId());
|
||||
List<BaseRole> roles = systemRoleMapper.selectRoleByUserId(user.getUserId());
|
||||
List<String> roleList = new ArrayList<>();
|
||||
roleList.add(roles.getRoleName());
|
||||
roleList.addAll(roles.stream().map(BaseRole::getRoleName).collect(Collectors.toList()));
|
||||
return UserVo.builder()
|
||||
.userId(userId)
|
||||
.username(user.getRealName())
|
||||
|
||||
@ -448,11 +448,12 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
}
|
||||
if (Objects.equals(systemUser.getAccountType(), SystemUserAccountTypeEnum.PROJECT_SUB_ACCOUNT.getValue())) {
|
||||
//项目子账号要判断是否能查看设备中台
|
||||
BaseRole baseRole = baseRoleMapper.selectRoleByUserId(systemUser.getUserId());
|
||||
if (baseRole == null) {
|
||||
List<BaseRole> baseRoles = baseRoleMapper.selectRoleByUserId(systemUser.getUserId());
|
||||
if (CollUtil.isEmpty(baseRoles)) {
|
||||
result.put("seeEquipment", 1);
|
||||
} else {
|
||||
result.put("seeEquipment", Integer.valueOf(baseRole.getSeeEquipment()));
|
||||
boolean see = baseRoles.stream().anyMatch(baseRole -> Objects.equals(baseRole.getSeeEquipment(), 0));
|
||||
result.put("seeEquipment", see ? 0 : 1);
|
||||
}
|
||||
} else {
|
||||
result.put("seeEquipment", 0);
|
||||
@ -750,12 +751,12 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
}
|
||||
if (Objects.equals(systemUser.getAccountType(), SystemUserAccountTypeEnum.PROJECT_SUB_ACCOUNT.getValue())) {
|
||||
//项目子账号要判断是否能查看设备中台
|
||||
BaseRole baseRole = baseRoleMapper.selectRoleByUserId(systemUser.getUserId());
|
||||
if (baseRole == null) {
|
||||
List<BaseRole> baseRoles = baseRoleMapper.selectRoleByUserId(systemUser.getUserId());
|
||||
if (CollUtil.isEmpty(baseRoles)) {
|
||||
result.put("seeEquipment", 1);
|
||||
} else {
|
||||
result.put("seeEquipment", baseRole.getSeeEquipment());
|
||||
}
|
||||
boolean see = baseRoles.stream().anyMatch(baseRole -> Objects.equals(baseRole.getSeeEquipment(), 0));
|
||||
result.put("seeEquipment", see ? 0 : 1); }
|
||||
} else {
|
||||
result.put("seeEquipment", 0);
|
||||
}
|
||||
@ -959,10 +960,18 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
}
|
||||
}
|
||||
systemUserMapper.insert(systemUser);
|
||||
BaseRoleUser baseRoleUser = new BaseRoleUser();
|
||||
baseRoleUser.setRoleId(systemUser.getRoleId());
|
||||
baseRoleUser.setUserId(systemUser.getUserId());
|
||||
baseRoleUserMapper.insert(baseRoleUser);
|
||||
addBaseRoleUsers(systemUser);
|
||||
}
|
||||
|
||||
private void addBaseRoleUsers(SystemUser systemUser) {
|
||||
String roleId = systemUser.getRoleId();
|
||||
List<String> roleIds = StrUtil.split(roleId, ",");
|
||||
for (String id : roleIds) {
|
||||
BaseRoleUser baseRoleUser = new BaseRoleUser();
|
||||
baseRoleUser.setRoleId(Long.valueOf(id));
|
||||
baseRoleUser.setUserId(systemUser.getUserId());
|
||||
baseRoleUserMapper.insert(baseRoleUser);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1023,16 +1032,8 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
||||
systemUserMapper.updateById(systemUser);
|
||||
QueryWrapper<BaseRoleUser> queryWrapper1 = new QueryWrapper<>();
|
||||
queryWrapper1.lambda().eq(BaseRoleUser::getUserId, systemUser.getUserId());
|
||||
BaseRoleUser baseRoleUser = baseRoleUserMapper.selectOne(queryWrapper1);
|
||||
if (baseRoleUser != null) {
|
||||
baseRoleUser.setRoleId(systemUser.getRoleId());
|
||||
baseRoleUserMapper.updateById(baseRoleUser);
|
||||
} else {
|
||||
BaseRoleUser tempbaseRoleUser = new BaseRoleUser();
|
||||
tempbaseRoleUser.setRoleId(systemUser.getRoleId());
|
||||
tempbaseRoleUser.setUserId(systemUser.getUserId());
|
||||
baseRoleUserMapper.insert(tempbaseRoleUser);
|
||||
}
|
||||
baseRoleUserMapper.delete(queryWrapper1);
|
||||
addBaseRoleUsers(systemUser);
|
||||
}
|
||||
|
||||
public Map<String, Object> getUserAuthority(Long userId, Integer accountType, String sn, String headquartersSn, Integer styleType) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user