|
@ -647,56 +647,104 @@ public class ProRoleService implements IProRoleService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public ProjectVo.RoleInfo saveMemberByRole(Long currentUserId, RoleDto.SaveMember saveMember) { |
|
|
public ProjectVo.RoleInfo saveMemberByRole(Long currentUserId, RoleDto.SaveMember saveMember) { |
|
|
//检查成员是否为空
|
|
|
ProRole role = proRoleDao.selectByPrimaryKey(saveMember.getRoleId()); |
|
|
ProMember member = proMemberDao.selectByPrimaryKey(saveMember.getMemberId()); |
|
|
if (ObjectUtil.isNull(role)) { |
|
|
if (ObjectUtil.isNull(member)) { |
|
|
throw new BaseException(CodeEnum.ROLE_NOT_FOUND); |
|
|
throw new BaseException(CodeEnum.NOT_MEMBER); |
|
|
|
|
|
} |
|
|
} |
|
|
//检查角色是否为PM 是的话则需要更高权限
|
|
|
//检查角色是否为PM 是的话则需要更高权限
|
|
|
boolean isPm = isPmByRoleId(saveMember.getRoleId()); |
|
|
boolean isPm = isPmByRoleId(saveMember.getRoleId()); |
|
|
//检查当前用户的权限是否可以修改
|
|
|
//检查当前用户的权限是否可以修改
|
|
|
int power = selectPowerByRoleName(currentUserId, member.getProjectId()); |
|
|
int power = selectPowerByRoleName(currentUserId, role.getProjectId()); |
|
|
if ((isPm && power < WebConstant.ROLE_POWER.ADMIN_POWER.value) || (!isPm && power < WebConstant.ROLE_POWER.OPERATION_POWER.value)) { |
|
|
if ((isPm && power < WebConstant.ROLE_POWER.ADMIN_POWER.value) || (!isPm && power < WebConstant.ROLE_POWER.OPERATION_POWER.value)) { |
|
|
throw new BaseException(CodeEnum.NOT_POWER); |
|
|
throw new BaseException(CodeEnum.NOT_POWER); |
|
|
} |
|
|
} |
|
|
//添加成员与角色关联信息
|
|
|
if(CollectionUtil.isNotEmpty(saveMember.getMemberId())){ |
|
|
ProMemberRole proMemberRole = new MemberRoleDto(); |
|
|
//删除以前关联的成员
|
|
|
proMemberRole.setId(snowflake.nextId()); |
|
|
ProMemberRoleExample memberRoleExample = new ProMemberRoleExample(); |
|
|
proMemberRole.setRoleId(saveMember.getRoleId()); |
|
|
memberRoleExample.createCriteria().andRoleIdEqualTo(saveMember.getRoleId()); |
|
|
proMemberRole.setMemberId(member.getId()); |
|
|
List<ProMemberRole> memberRoleList = memberRoleDao.selectByExample(memberRoleExample); |
|
|
memberRoleDao.insertSelective(proMemberRole); |
|
|
if(CollectionUtil.isNotEmpty(memberRoleList)){ |
|
|
|
|
|
memberRoleList.forEach(proMemberRole -> { |
|
|
|
|
|
proMemberRole.setRecStatus((byte) 2); |
|
|
|
|
|
memberRoleDao.updateByPrimaryKeySelective(proMemberRole); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
//添加当前新关联的成员
|
|
|
|
|
|
saveMember.getMemberId().forEach(memberId -> { |
|
|
|
|
|
//添加成员与角色关联信息
|
|
|
|
|
|
ProMemberRole proMemberRole = new MemberRoleDto(); |
|
|
|
|
|
proMemberRole.setId(snowflake.nextId()); |
|
|
|
|
|
proMemberRole.setRoleId(saveMember.getRoleId()); |
|
|
|
|
|
proMemberRole.setMemberId(memberId); |
|
|
|
|
|
memberRoleDao.insertSelective(proMemberRole); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //检查成员是否为空
|
|
|
|
|
|
// ProMember member = proMemberDao.selectByPrimaryKey(saveMember.getMemberId());
|
|
|
|
|
|
// if (ObjectUtil.isNull(member)) {
|
|
|
|
|
|
// throw new BaseException(CodeEnum.NOT_MEMBER);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// //添加成员与角色关联信息
|
|
|
|
|
|
// ProMemberRole proMemberRole = new MemberRoleDto();
|
|
|
|
|
|
// proMemberRole.setId(snowflake.nextId());
|
|
|
|
|
|
// proMemberRole.setRoleId(saveMember.getRoleId());
|
|
|
|
|
|
// proMemberRole.setMemberId(member.getId());
|
|
|
|
|
|
// memberRoleDao.insertSelective(proMemberRole);
|
|
|
return getRoleInfoByRoleId(saveMember.getRoleId()); |
|
|
return getRoleInfoByRoleId(saveMember.getRoleId()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void deleteMemberByRole(Long currentUserId, RoleDto.SaveMember saveMember) { |
|
|
public void deleteMemberByRole(Long currentUserId, RoleDto.SaveMember saveMember) { |
|
|
//检查参数是否正确
|
|
|
ProRole role = proRoleDao.selectByPrimaryKey(saveMember.getRoleId()); |
|
|
ProMember member = proMemberDao.selectByPrimaryKey(saveMember.getMemberId()); |
|
|
if (ObjectUtil.isNull(role)) { |
|
|
if (ObjectUtil.isNull(member)) { |
|
|
throw new BaseException(CodeEnum.ROLE_NOT_FOUND); |
|
|
throw new BaseException(CodeEnum.NOT_MEMBER); |
|
|
|
|
|
} |
|
|
} |
|
|
//检查被操作的角色是否是项目PM
|
|
|
//检查被操作的角色是否是项目PM
|
|
|
boolean isPm = isPmByRoleId(saveMember.getRoleId()); |
|
|
boolean isPm = isPmByRoleId(saveMember.getRoleId()); |
|
|
//检查当前用户的权限是否可以修改
|
|
|
//检查当前用户的权限是否可以修改
|
|
|
int power = selectPowerByRoleName(currentUserId, member.getProjectId()); |
|
|
int power = selectPowerByRoleName(currentUserId, role.getProjectId()); |
|
|
if ((isPm && power < WebConstant.ROLE_POWER.ADMIN_POWER.value) || (!isPm && power < WebConstant.ROLE_POWER.OPERATION_POWER.value)) { |
|
|
if ((isPm && power < WebConstant.ROLE_POWER.ADMIN_POWER.value) || (!isPm && power < WebConstant.ROLE_POWER.OPERATION_POWER.value)) { |
|
|
throw new BaseException(CodeEnum.NOT_POWER); |
|
|
throw new BaseException(CodeEnum.NOT_POWER); |
|
|
} |
|
|
} |
|
|
//删除角色与成员的关联信息
|
|
|
if(CollectionUtil.isNotEmpty(saveMember.getMemberId())){ |
|
|
ProMemberRoleExample memberRoleExample = new ProMemberRoleExample(); |
|
|
saveMember.getMemberId().forEach(memberId -> { |
|
|
memberRoleExample.createCriteria().andRoleIdEqualTo(saveMember.getRoleId()).andMemberIdEqualTo(member.getId()); |
|
|
//删除角色与成员的关联信息
|
|
|
List<ProMemberRole> memberRoleList = memberRoleDao.selectByExample(memberRoleExample); |
|
|
ProMemberRoleExample memberRoleExample = new ProMemberRoleExample(); |
|
|
if (CollectionUtil.isEmpty(memberRoleList)) { |
|
|
memberRoleExample.createCriteria().andRoleIdEqualTo(saveMember.getRoleId()).andMemberIdEqualTo(memberId); |
|
|
throw new BaseException(CodeEnum.NOT_MEMBER); |
|
|
List<ProMemberRole> memberRoleList = memberRoleDao.selectByExample(memberRoleExample); |
|
|
} |
|
|
if (CollectionUtil.isEmpty(memberRoleList)) { |
|
|
for (ProMemberRole memberRole : memberRoleList) { |
|
|
throw new BaseException(CodeEnum.NOT_MEMBER); |
|
|
memberRole.setRecStatus((byte) 2); |
|
|
} |
|
|
memberRoleDao.updateByPrimaryKeySelective(memberRole); |
|
|
for (ProMemberRole memberRole : memberRoleList) { |
|
|
|
|
|
memberRole.setRecStatus((byte) 2); |
|
|
|
|
|
memberRoleDao.updateByPrimaryKeySelective(memberRole); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// //检查参数是否正确
|
|
|
|
|
|
// ProMember member = proMemberDao.selectByPrimaryKey(saveMember.getMemberId());
|
|
|
|
|
|
// if (ObjectUtil.isNull(member)) {
|
|
|
|
|
|
// throw new BaseException(CodeEnum.NOT_MEMBER);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// //删除角色与成员的关联信息
|
|
|
|
|
|
// ProMemberRoleExample memberRoleExample = new ProMemberRoleExample();
|
|
|
|
|
|
// memberRoleExample.createCriteria().andRoleIdEqualTo(saveMember.getRoleId()).andMemberIdEqualTo(member.getId());
|
|
|
|
|
|
// List<ProMemberRole> memberRoleList = memberRoleDao.selectByExample(memberRoleExample);
|
|
|
|
|
|
// if (CollectionUtil.isEmpty(memberRoleList)) {
|
|
|
|
|
|
// throw new BaseException(CodeEnum.NOT_MEMBER);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// for (ProMemberRole memberRole : memberRoleList) {
|
|
|
|
|
|
// memberRole.setRecStatus((byte) 2);
|
|
|
|
|
|
// memberRoleDao.updateByPrimaryKeySelective(memberRole);
|
|
|
|
|
|
// }
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
// public TaskVo.ProTaskInfo queryByProjectVirtualRole(RoleDto.ProjectId projectId) {
|
|
|
|
|
|
public List<TaskVo.NormalTask> queryByProjectVirtualRole(RoleDto.ProjectId projectId) { |
|
|
public List<TaskVo.NormalTask> queryByProjectVirtualRole(RoleDto.ProjectId projectId) { |
|
|
TaskVo.ProTaskInfo proTaskInfo = new TaskVo.ProTaskInfo(); |
|
|
TaskVo.ProTaskInfo proTaskInfo = new TaskVo.ProTaskInfo(); |
|
|
List<TaskVo.NormalTask> taskList = new ArrayList<>(); |
|
|
List<TaskVo.NormalTask> taskList = new ArrayList<>(); |
|
@ -850,13 +898,15 @@ public class ProRoleService implements IProRoleService { |
|
|
//获取经理得id
|
|
|
//获取经理得id
|
|
|
ProRoleExample proRoleExample=new ProRoleExample(); |
|
|
ProRoleExample proRoleExample=new ProRoleExample(); |
|
|
proRoleExample.createCriteria().andRecStatusEqualTo((byte)0).andNameEqualTo(WebConstant.ROLE_NAME.PM.value).andParentIdEqualTo(0L).andProjectIdEqualTo(param.getParam().getProjectId()); |
|
|
proRoleExample.createCriteria().andRecStatusEqualTo((byte)0).andNameEqualTo(WebConstant.ROLE_NAME.PM.value).andParentIdEqualTo(0L).andProjectIdEqualTo(param.getParam().getProjectId()); |
|
|
//一级角色项目经理
|
|
|
// //一级角色项目经理
|
|
|
List<Long> jili=proRoleMapper.selectByExample(proRoleExample).stream().map(action->action.getId()).collect(Collectors.toList()); |
|
|
// List<Long> jili=proRoleMapper.selectByExample(proRoleExample).stream().map(action->action.getId()).collect(Collectors.toList());
|
|
|
//二级角色项目经理
|
|
|
// //二级角色项目经理
|
|
|
ProRoleExample proRoleExample1=new ProRoleExample(); |
|
|
// ProRoleExample proRoleExample1=new ProRoleExample();
|
|
|
proRoleExample1.createCriteria().andRecStatusEqualTo((byte)0).andParentIdIn(jili); |
|
|
// proRoleExample1.createCriteria().andRecStatusEqualTo((byte)0).andParentIdIn(jili);
|
|
|
List<ProRole> proRoles = proRoleMapper.selectByExample(proRoleExample1); |
|
|
// List<ProRole> proRoles = proRoleMapper.selectByExample(proRoleExample1);
|
|
|
List<Long> jili1=proRoles.stream().map(action->action.getId()).collect(Collectors.toList()); |
|
|
// List<Long> jili1=proRoles.stream().map(action->action.getId()).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
List<Long> jili1 = proRoleDao.getPmByByProjectId(param.getParam().getProjectId()); |
|
|
|
|
|
|
|
|
if(param.getParam().getIsShow()){ |
|
|
if(param.getParam().getIsShow()){ |
|
|
//展示的 增加的 不需要考虑是否为经理
|
|
|
//展示的 增加的 不需要考虑是否为经理
|
|
@ -866,7 +916,6 @@ public class ProRoleService implements IProRoleService { |
|
|
if((proMemberRoleShows.size()+param.getParam().getRoleIds().size())>10){ |
|
|
if((proMemberRoleShows.size()+param.getParam().getRoleIds().size())>10){ |
|
|
throw new BaseException(CodeEnum.CHAOGUOSHI); |
|
|
throw new BaseException(CodeEnum.CHAOGUOSHI); |
|
|
}else { |
|
|
}else { |
|
|
|
|
|
|
|
|
if(param.getParam().getRoleIds().size()>0){ |
|
|
if(param.getParam().getRoleIds().size()>0){ |
|
|
//查一下目前最大得排序是多少
|
|
|
//查一下目前最大得排序是多少
|
|
|
Integer[] seq=new Integer[]{proMemberRoleShows.stream().mapToInt(action->action.getSequence()).max().getAsInt()}; |
|
|
Integer[] seq=new Integer[]{proMemberRoleShows.stream().mapToInt(action->action.getSequence()).max().getAsInt()}; |
|
|