fix: change permission to or
This commit is contained in:
parent
4cf99a31bc
commit
4c11277304
|
@ -18,6 +18,7 @@ import io.swagger.v3.oas.annotations.Parameters;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.apache.shiro.authz.annotation.Logical;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
@ -39,7 +40,7 @@ public class OrganizationController {
|
||||||
|
|
||||||
@PostMapping("/member/list")
|
@PostMapping("/member/list")
|
||||||
@Operation(summary = "组织级别获取组织成员")
|
@Operation(summary = "组织级别获取组织成员")
|
||||||
@RequiresPermissions(value = {PermissionConstants.ORGANIZATION_MEMBER_READ, PermissionConstants.SYSTEM_USER_READ})
|
@RequiresPermissions(value = {PermissionConstants.ORGANIZATION_MEMBER_READ, PermissionConstants.SYSTEM_USER_READ}, logical = Logical.OR)
|
||||||
public Pager<List<OrgUserExtend>> getMemberList(@Validated @RequestBody OrganizationRequest organizationRequest) {
|
public Pager<List<OrgUserExtend>> getMemberList(@Validated @RequestBody OrganizationRequest organizationRequest) {
|
||||||
Page<Object> page = PageHelper.startPage(organizationRequest.getCurrent(), organizationRequest.getPageSize());
|
Page<Object> page = PageHelper.startPage(organizationRequest.getCurrent(), organizationRequest.getPageSize());
|
||||||
return PageUtils.setPageInfo(page, organizationService.getMemberListByOrg(organizationRequest));
|
return PageUtils.setPageInfo(page, organizationService.getMemberListByOrg(organizationRequest));
|
||||||
|
@ -61,7 +62,7 @@ public class OrganizationController {
|
||||||
|
|
||||||
@PostMapping("/update-member")
|
@PostMapping("/update-member")
|
||||||
@Operation(summary = "更新用户")
|
@Operation(summary = "更新用户")
|
||||||
@RequiresPermissions(value = {PermissionConstants.ORGANIZATION_MEMBER_UPDATE, PermissionConstants.PROJECT_USER_READ_ADD, PermissionConstants.PROJECT_USER_READ_DELETE})
|
@RequiresPermissions(value = {PermissionConstants.ORGANIZATION_MEMBER_UPDATE, PermissionConstants.PROJECT_USER_READ_ADD, PermissionConstants.PROJECT_USER_READ_DELETE}, logical = Logical.OR)
|
||||||
public void updateMember(@Validated @RequestBody OrganizationMemberUpdateRequest organizationMemberExtendRequest) {
|
public void updateMember(@Validated @RequestBody OrganizationMemberUpdateRequest organizationMemberExtendRequest) {
|
||||||
organizationService.updateMember(organizationMemberExtendRequest, SessionUtils.getUserId());
|
organizationService.updateMember(organizationMemberExtendRequest, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页获取系统下组织列表
|
* 分页获取系统下组织列表
|
||||||
|
*
|
||||||
* @param organizationRequest 请求参数
|
* @param organizationRequest 请求参数
|
||||||
* @return 组织集合
|
* @return 组织集合
|
||||||
*/
|
*/
|
||||||
|
@ -82,6 +83,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取系统下组织下拉选项
|
* 获取系统下组织下拉选项
|
||||||
|
*
|
||||||
* @return 组织下拉选项集合
|
* @return 组织下拉选项集合
|
||||||
*/
|
*/
|
||||||
public List<OptionDTO> listAll() {
|
public List<OptionDTO> listAll() {
|
||||||
|
@ -91,6 +93,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页获取组织成员列表
|
* 分页获取组织成员列表
|
||||||
|
*
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
* @return 组织成员集合
|
* @return 组织成员集合
|
||||||
*/
|
*/
|
||||||
|
@ -136,6 +139,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统-组织-添加成员
|
* 系统-组织-添加成员
|
||||||
|
*
|
||||||
* @param organizationMemberRequest 请求参数
|
* @param organizationMemberRequest 请求参数
|
||||||
* @param createUserId 创建人ID
|
* @param createUserId 创建人ID
|
||||||
*/
|
*/
|
||||||
|
@ -154,6 +158,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组织添加成员公共方法(N个组织添加N个成员)
|
* 组织添加成员公共方法(N个组织添加N个成员)
|
||||||
|
*
|
||||||
* @param batchRequest 请求参数 [organizationIds 组织集合, memberIds 成员集合]
|
* @param batchRequest 请求参数 [organizationIds 组织集合, memberIds 成员集合]
|
||||||
* @param createUserId 创建人ID
|
* @param createUserId 创建人ID
|
||||||
*/
|
*/
|
||||||
|
@ -189,6 +194,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除组织成员
|
* 删除组织成员
|
||||||
|
*
|
||||||
* @param organizationId 组织ID
|
* @param organizationId 组织ID
|
||||||
* @param userId 成员ID
|
* @param userId 成员ID
|
||||||
*/
|
*/
|
||||||
|
@ -214,6 +220,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取系统默认组织
|
* 获取系统默认组织
|
||||||
|
*
|
||||||
* @return 组织信息
|
* @return 组织信息
|
||||||
*/
|
*/
|
||||||
public OrganizationDTO getDefault() {
|
public OrganizationDTO getDefault() {
|
||||||
|
@ -228,6 +235,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组织级别获取组织成员
|
* 组织级别获取组织成员
|
||||||
|
*
|
||||||
* @param organizationRequest 请求参数
|
* @param organizationRequest 请求参数
|
||||||
* @return 组织成员集合
|
* @return 组织成员集合
|
||||||
*/
|
*/
|
||||||
|
@ -254,22 +262,24 @@ public class OrganizationService {
|
||||||
Map<String, List<IdNameStructureDTO>> userIdprojectIdMap = new HashMap<>();
|
Map<String, List<IdNameStructureDTO>> userIdprojectIdMap = new HashMap<>();
|
||||||
Map<String, Set<String>> userIdRoleIdMap = new HashMap<>();
|
Map<String, Set<String>> userIdRoleIdMap = new HashMap<>();
|
||||||
for (UserRoleRelation userRoleRelationsByUser : userRoleRelationsByUsers) {
|
for (UserRoleRelation userRoleRelationsByUser : userRoleRelationsByUsers) {
|
||||||
String projectId = userRoleRelationsByUser.getSourceId();
|
String sourceId = userRoleRelationsByUser.getSourceId();
|
||||||
String roleId = userRoleRelationsByUser.getRoleId();
|
String roleId = userRoleRelationsByUser.getRoleId();
|
||||||
String userId = userRoleRelationsByUser.getUserId();
|
String userId = userRoleRelationsByUser.getUserId();
|
||||||
List<IdNameStructureDTO> pIdNameList = userIdprojectIdMap.get(userId);
|
List<IdNameStructureDTO> pIdNameList = userIdprojectIdMap.get(userId);
|
||||||
if (CollectionUtils.isEmpty(pIdNameList)) {
|
if (CollectionUtils.isEmpty(pIdNameList)) {
|
||||||
pIdNameList = new ArrayList<>();
|
pIdNameList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
String projectName = projectIdNameMap.get(projectId);
|
String projectName = projectIdNameMap.get(sourceId);
|
||||||
if (StringUtils.isNotBlank(projectName)) {
|
if (StringUtils.isNotBlank(projectName)) {
|
||||||
IdNameStructureDTO idNameStructureDTO = new IdNameStructureDTO();
|
IdNameStructureDTO idNameStructureDTO = new IdNameStructureDTO();
|
||||||
idNameStructureDTO.setId(projectId);
|
idNameStructureDTO.setId(sourceId);
|
||||||
idNameStructureDTO.setName(projectName);
|
idNameStructureDTO.setName(projectName);
|
||||||
pIdNameList.add(idNameStructureDTO);
|
pIdNameList.add(idNameStructureDTO);
|
||||||
}
|
}
|
||||||
userIdprojectIdMap.put(userId, pIdNameList);
|
userIdprojectIdMap.put(userId, pIdNameList);
|
||||||
|
|
||||||
|
//只显示组织级别的用户组
|
||||||
|
if (StringUtils.equals(sourceId, organizationId)) {
|
||||||
Set<String> roleIds = userIdRoleIdMap.get(userId);
|
Set<String> roleIds = userIdRoleIdMap.get(userId);
|
||||||
if (CollectionUtils.isEmpty(roleIds)) {
|
if (CollectionUtils.isEmpty(roleIds)) {
|
||||||
roleIds = new HashSet<>();
|
roleIds = new HashSet<>();
|
||||||
|
@ -277,6 +287,7 @@ public class OrganizationService {
|
||||||
roleIds.add(roleId);
|
roleIds.add(roleId);
|
||||||
userIdRoleIdMap.put(userId, roleIds);
|
userIdRoleIdMap.put(userId, roleIds);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (OrgUserExtend orgUserExtend : orgUserExtends) {
|
for (OrgUserExtend orgUserExtend : orgUserExtends) {
|
||||||
List<IdNameStructureDTO> projectList = userIdprojectIdMap.get(orgUserExtend.getId());
|
List<IdNameStructureDTO> projectList = userIdprojectIdMap.get(orgUserExtend.getId());
|
||||||
if (CollectionUtils.isNotEmpty(projectList)) {
|
if (CollectionUtils.isNotEmpty(projectList)) {
|
||||||
|
@ -354,6 +365,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加组织成员至用户组
|
* 添加组织成员至用户组
|
||||||
|
*
|
||||||
* @param organizationMemberExtendRequest 请求参数
|
* @param organizationMemberExtendRequest 请求参数
|
||||||
* @param userId 创建人ID
|
* @param userId 创建人ID
|
||||||
*/
|
*/
|
||||||
|
@ -380,7 +392,7 @@ public class OrganizationService {
|
||||||
projectIds.forEach(projectId -> {
|
projectIds.forEach(projectId -> {
|
||||||
//过滤已存在的关系
|
//过滤已存在的关系
|
||||||
UserRoleRelationExample example = new UserRoleRelationExample();
|
UserRoleRelationExample example = new UserRoleRelationExample();
|
||||||
example.createCriteria().andSourceIdEqualTo(projectId).andUserIdEqualTo(memberId).andRoleIdEqualTo(InternalUserRole.PROJECT_MEMBER.getValue());
|
example.createCriteria().andSourceIdEqualTo(projectId).andUserIdEqualTo(memberId);
|
||||||
List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectByExample(example);
|
List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectByExample(example);
|
||||||
if (CollectionUtils.isEmpty(userRoleRelations)) {
|
if (CollectionUtils.isEmpty(userRoleRelations)) {
|
||||||
UserRoleRelation userRoleRelation = buildUserRoleRelation(userId, memberId, projectId, InternalUserRole.PROJECT_MEMBER.getValue());
|
UserRoleRelation userRoleRelation = buildUserRoleRelation(userId, memberId, projectId, InternalUserRole.PROJECT_MEMBER.getValue());
|
||||||
|
@ -407,6 +419,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除组织用户日志
|
* 删除组织用户日志
|
||||||
|
*
|
||||||
* @return 日志内容
|
* @return 日志内容
|
||||||
*/
|
*/
|
||||||
public List<LogDTO> batchDelLog(String organizationId, String userId) {
|
public List<LogDTO> batchDelLog(String organizationId, String userId) {
|
||||||
|
@ -468,6 +481,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新用户
|
* 更新用户
|
||||||
|
*
|
||||||
* @param organizationMemberUpdateRequest 请求参数
|
* @param organizationMemberUpdateRequest 请求参数
|
||||||
* @param createUserId 创建人ID
|
* @param createUserId 创建人ID
|
||||||
*/
|
*/
|
||||||
|
@ -593,6 +607,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前组织下的所有项目
|
* 获取当前组织下的所有项目
|
||||||
|
*
|
||||||
* @param organizationId 组织ID
|
* @param organizationId 组织ID
|
||||||
* @return 项目列表
|
* @return 项目列表
|
||||||
*/
|
*/
|
||||||
|
@ -614,6 +629,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前组织下的所有自定义用户组以及组织级别的用户组
|
* 获取当前组织下的所有自定义用户组以及组织级别的用户组
|
||||||
|
*
|
||||||
* @param organizationId 组织ID
|
* @param organizationId 组织ID
|
||||||
* @return 用户组列表
|
* @return 用户组列表
|
||||||
*/
|
*/
|
||||||
|
@ -640,6 +656,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取不在当前组织的所有用户
|
* 获取不在当前组织的所有用户
|
||||||
|
*
|
||||||
* @param organizationId 组织ID
|
* @param organizationId 组织ID
|
||||||
* @return 用户列表
|
* @return 用户列表
|
||||||
*/
|
*/
|
||||||
|
@ -667,6 +684,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查组织是否存在
|
* 检查组织是否存在
|
||||||
|
*
|
||||||
* @param organizationIds 组织ID集合
|
* @param organizationIds 组织ID集合
|
||||||
*/
|
*/
|
||||||
private void checkOrgExistByIds(List<String> organizationIds) {
|
private void checkOrgExistByIds(List<String> organizationIds) {
|
||||||
|
@ -679,6 +697,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查组织是否存在
|
* 检查组织是否存在
|
||||||
|
*
|
||||||
* @param organizationId 组织ID
|
* @param organizationId 组织ID
|
||||||
*/
|
*/
|
||||||
private void checkOrgExistById(String organizationId) {
|
private void checkOrgExistById(String organizationId) {
|
||||||
|
@ -690,6 +709,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查组织级别的用户组是否存在
|
* 检查组织级别的用户组是否存在
|
||||||
|
*
|
||||||
* @param userRoleIds 用户组ID集合
|
* @param userRoleIds 用户组ID集合
|
||||||
* @param organizationId 组织ID
|
* @param organizationId 组织ID
|
||||||
* @return 用户组集合
|
* @return 用户组集合
|
||||||
|
@ -708,6 +728,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查用户是否存在
|
* 检查用户是否存在
|
||||||
|
*
|
||||||
* @param memberIds 成员ID集合
|
* @param memberIds 成员ID集合
|
||||||
* @return 用户集合
|
* @return 用户集合
|
||||||
*/
|
*/
|
||||||
|
@ -723,6 +744,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查项目是否存在
|
* 检查项目是否存在
|
||||||
|
*
|
||||||
* @param projectIds 项目ID集合
|
* @param projectIds 项目ID集合
|
||||||
* @param organizationId 组织ID
|
* @param organizationId 组织ID
|
||||||
* @return 项目集合
|
* @return 项目集合
|
||||||
|
@ -739,6 +761,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理组织管理员信息
|
* 处理组织管理员信息
|
||||||
|
*
|
||||||
* @param organizationDTOS 组织集合
|
* @param organizationDTOS 组织集合
|
||||||
* @return 组织列表
|
* @return 组织列表
|
||||||
*/
|
*/
|
||||||
|
@ -755,6 +778,7 @@ public class OrganizationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置操作日志
|
* 设置操作日志
|
||||||
|
*
|
||||||
* @param organizationId 组织ID
|
* @param organizationId 组织ID
|
||||||
* @param createUser 创建人
|
* @param createUser 创建人
|
||||||
* @param type 操作类型
|
* @param type 操作类型
|
||||||
|
|
|
@ -226,7 +226,7 @@ public class OrganizationControllerTests extends BaseTest {
|
||||||
organizationMemberRequest.setProjectIds(Arrays.asList("sys_org_projectId2", "sys_org_projectId3"));
|
organizationMemberRequest.setProjectIds(Arrays.asList("sys_org_projectId2", "sys_org_projectId3"));
|
||||||
this.requestPost(ORGANIZATION_PROJECT_ADD_MEMBER, organizationMemberRequest, status().isOk());
|
this.requestPost(ORGANIZATION_PROJECT_ADD_MEMBER, organizationMemberRequest, status().isOk());
|
||||||
// 批量添加成员成功后, 验证是否添加成功
|
// 批量添加成员成功后, 验证是否添加成功
|
||||||
listByKeyWord("testUserOne", "sys_default_organization_3", true, InternalUserRole.PROJECT_MEMBER.getValue(), "sys_org_projectId2", false, null, null);
|
listByKeyWord("testUserOne", "sys_default_organization_3", false, InternalUserRole.PROJECT_MEMBER.getValue(), "sys_org_projectId2", false, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -491,8 +491,6 @@ public class OrganizationControllerTests extends BaseTest {
|
||||||
Assertions.assertNotNull(orgUserExtend.getUserRoleIdNameMap());
|
Assertions.assertNotNull(orgUserExtend.getUserRoleIdNameMap());
|
||||||
List<String> userRoleIds = orgUserExtend.getUserRoleIdNameMap().stream().map(IdNameStructureDTO::getId).toList();
|
List<String> userRoleIds = orgUserExtend.getUserRoleIdNameMap().stream().map(IdNameStructureDTO::getId).toList();
|
||||||
Assertions.assertTrue(userRoleIds.contains(userRoleId));
|
Assertions.assertTrue(userRoleIds.contains(userRoleId));
|
||||||
List<String> userRoleNames = orgUserExtend.getUserRoleIdNameMap().stream().map(IdNameStructureDTO::getName).toList();
|
|
||||||
Assertions.assertTrue(userRoleNames.contains(userRoleId) || userRoleNames.contains("项目成员"));
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(projectId)) {
|
if (StringUtils.isNotBlank(projectId)) {
|
||||||
Assertions.assertNotNull(orgUserExtend.getProjectIdNameMap());
|
Assertions.assertNotNull(orgUserExtend.getProjectIdNameMap());
|
||||||
|
|
Loading…
Reference in New Issue