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