refactor(系统设置): 组织项目及用户组日志优化
This commit is contained in:
parent
85bfe10c69
commit
8a67a0d3fe
|
@ -72,6 +72,7 @@ public class OperationLogModule {
|
|||
public static final String SETTING_ORGANIZATION = "SETTING_ORGANIZATION";
|
||||
public static final String SETTING_ORGANIZATION_MEMBER = "SETTING_ORGANIZATION_MEMBER";
|
||||
public static final String SETTING_ORGANIZATION_SERVICE = "SETTING_ORGANIZATION_SERVICE";
|
||||
public static final String SETTING_ORGANIZATION_USER_ROLE = "SETTING_ORGANIZATION_USER_ROLE";
|
||||
|
||||
//系统设置-组织-项目
|
||||
public static final String SETTING_SYSTEM_ORGANIZATION_PROJECT = "SETTING_SYSTEM_ORGANIZATION_PROJECT";
|
||||
|
|
|
@ -13,6 +13,7 @@ import io.metersphere.sdk.util.Pager;
|
|||
import io.metersphere.sdk.util.SessionUtils;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.domain.UserRole;
|
||||
import io.metersphere.system.dto.UserExtend;
|
||||
import io.metersphere.system.request.OrganizationUserRoleEditRequest;
|
||||
import io.metersphere.system.request.OrganizationUserRoleMemberEditRequest;
|
||||
import io.metersphere.system.request.OrganizationUserRoleMemberRequest;
|
||||
|
@ -94,6 +95,13 @@ public class OrganizationUserRoleController {
|
|||
organizationUserRoleService.updatePermissionSetting(request);
|
||||
}
|
||||
|
||||
@GetMapping("/get-member/option/{organizationId}/{roleId}")
|
||||
@Operation(summary = "获取组织用户组-成员下拉选项")
|
||||
@RequiresPermissions(value = {PermissionConstants.ORGANIZATION_USER_ROLE_READ})
|
||||
public List<UserExtend> getMember(@PathVariable String organizationId, @PathVariable String roleId) {
|
||||
return organizationUserRoleService.getMember(organizationId, roleId);
|
||||
}
|
||||
|
||||
@PostMapping("/list-member")
|
||||
@Operation(summary = "获取组织用户组-成员")
|
||||
@RequiresPermissions(value = {PermissionConstants.ORGANIZATION_USER_ROLE_READ})
|
||||
|
|
|
@ -17,6 +17,7 @@ import io.metersphere.system.request.OrganizationRequest;
|
|||
import io.metersphere.system.request.ProjectRequest;
|
||||
import io.metersphere.system.service.OrganizationService;
|
||||
import io.metersphere.system.service.SystemProjectService;
|
||||
import io.metersphere.system.service.UserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
|
@ -39,6 +40,8 @@ import java.util.Map;
|
|||
@RequestMapping("/system/organization")
|
||||
public class SystemOrganizationController {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private SystemProjectService systemProjectService;
|
||||
@Resource
|
||||
|
@ -111,4 +114,12 @@ public class SystemOrganizationController {
|
|||
public Map<String, Long> getTotal(@RequestParam(value = "organizationId",required = false) String organizationId) {
|
||||
return organizationService.getTotal(organizationId);
|
||||
}
|
||||
|
||||
@GetMapping("/get-option/{sourceId}")
|
||||
@Operation(summary = "系统-组织及项目, 获取成员抽屉下拉用户选项")
|
||||
@RequiresPermissions(value = {PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ})
|
||||
@Parameter(name = "sourceId", description = "组织ID或项目ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
public List<UserExtend> getMemberOption(@PathVariable String sourceId) {
|
||||
return userService.getMemberOption(sourceId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,16 +5,12 @@ import com.github.pagehelper.Page;
|
|||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||
import io.metersphere.sdk.dto.ProjectDTO;
|
||||
import io.metersphere.sdk.dto.ProjectExtendDTO;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.sdk.dto.*;
|
||||
import io.metersphere.sdk.log.annotation.Log;
|
||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.PageUtils;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
import io.metersphere.sdk.util.SessionUtils;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.dto.UserExtend;
|
||||
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
|
||||
import io.metersphere.system.request.ProjectAddMemberRequest;
|
||||
|
@ -147,10 +143,10 @@ public class SystemProjectController {
|
|||
}
|
||||
|
||||
@GetMapping("/user-list")
|
||||
@Operation(summary = "获取用户列表")
|
||||
@Operation(summary = "系统-组织及项目, 获取管理员下拉选项")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ)
|
||||
public List<User> getUserList() {
|
||||
return userService.getUserList();
|
||||
public List<OptionDTO> getUserList() {
|
||||
return userService.getMemberOption();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import io.metersphere.sdk.util.Pager;
|
|||
import io.metersphere.sdk.util.SessionUtils;
|
||||
import io.metersphere.system.domain.Organization;
|
||||
import io.metersphere.system.dto.UserBatchCreateDTO;
|
||||
import io.metersphere.system.dto.UserExtend;
|
||||
import io.metersphere.system.request.OrganizationMemberBatchRequest;
|
||||
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
|
||||
import io.metersphere.system.request.user.UserChangeEnableRequest;
|
||||
|
@ -29,8 +28,6 @@ import io.metersphere.system.utils.TreeNodeParseUtils;
|
|||
import io.metersphere.validation.groups.Created;
|
||||
import io.metersphere.validation.groups.Updated;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
|
@ -118,14 +115,6 @@ public class UserController {
|
|||
return userService.resetPassword(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/get-option/{sourceId}")
|
||||
@Operation(summary = "系统-组织及项目, 获取用户下拉选项")
|
||||
@RequiresPermissions(value = {PermissionConstants.SYSTEM_USER_READ})
|
||||
@Parameter(name = "sourceId", description = "组织ID或项目ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
public List<UserExtend> getMemberOption(@PathVariable String sourceId) {
|
||||
return userService.getMemberOption(sourceId);
|
||||
}
|
||||
|
||||
@GetMapping("/get/global/system/role")
|
||||
@Operation(summary = "查找系统级用户权限")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_USER_ROLE_READ)
|
||||
|
@ -175,7 +164,7 @@ public class UserController {
|
|||
userRoleBatchRelationRequest.setSelectIds(userService.getBatchUserIds(userRoleBatchRelationRequest));
|
||||
OrganizationMemberBatchRequest request = new OrganizationMemberBatchRequest();
|
||||
request.setOrganizationIds(userRoleBatchRelationRequest.getRoleIds());
|
||||
request.setMemberIds(userRoleBatchRelationRequest.getSelectIds());
|
||||
request.setUserIds(userRoleBatchRelationRequest.getSelectIds());
|
||||
organizationService.addMemberBySystem(request, SessionUtils.getUserId());
|
||||
return new TableBatchProcessResponse(userRoleBatchRelationRequest.getSelectIds().size(), userRoleBatchRelationRequest.getSelectIds().size());
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class OrganizationDTO extends Organization {
|
|||
*/
|
||||
@Schema(description = "组织管理员ID集合")
|
||||
@NotEmpty(groups = {Created.class, Updated.class}, message = "{member.id.not_empty}")
|
||||
private List<String> memberIds;
|
||||
private List<String> userIds;
|
||||
|
||||
/**
|
||||
* 创建人是否是管理员
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.system.dto;
|
||||
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
@ -13,15 +14,23 @@ import java.io.Serializable;
|
|||
@EqualsAndHashCode(callSuper = false)
|
||||
public class UserExtend extends User implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 是否管理员(组织, 项目)
|
||||
*/
|
||||
@Schema(description = "是否组织/项目管理员, 是: 展示管理员标识, 否: 不展示管理员标识")
|
||||
private boolean adminFlag;
|
||||
|
||||
/**
|
||||
* 是否成员(组织, 项目)
|
||||
*/
|
||||
@Schema(description = "是否组织/项目成员, 是: 勾选禁用, 否: 勾选启用")
|
||||
private boolean memberFlag;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 是否勾选用户组
|
||||
*/
|
||||
@Schema(description = "是否属于用户组, 是: 勾选禁用, 否: 勾选启用")
|
||||
private boolean checkRoleFlag;
|
||||
}
|
||||
|
|
|
@ -27,5 +27,5 @@ public class OrganizationEditRequest implements Serializable {
|
|||
private String description;
|
||||
|
||||
@Schema(description = "成员ID集合")
|
||||
private List<String> memberIds;
|
||||
private List<String> userIds;
|
||||
}
|
||||
|
|
|
@ -28,5 +28,5 @@ public class OrganizationMemberRequest implements Serializable {
|
|||
*/
|
||||
@Schema(description = "成员ID集合", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "{user.id.not_blank}")
|
||||
private List<String> memberIds;
|
||||
private List<String> userIds;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;
|
|||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class OrganizationRequest extends BasePageRequest {
|
||||
|
||||
@Schema(description = "组织ID")
|
||||
private String organizationId;
|
||||
}
|
||||
|
|
|
@ -48,8 +48,6 @@ public class OrganizationService {
|
|||
@Resource
|
||||
private UserRoleRelationMapper userRoleRelationMapper;
|
||||
@Resource
|
||||
private ExtUserRoleRelationMapper extUserRoleRelationMapper;
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
@Resource
|
||||
private SqlSessionFactory sqlSessionFactory;
|
||||
|
@ -147,27 +145,29 @@ public class OrganizationService {
|
|||
List<LogDTO> logs = new ArrayList<>();
|
||||
OrganizationMemberBatchRequest batchRequest = new OrganizationMemberBatchRequest();
|
||||
batchRequest.setOrganizationIds(List.of(organizationMemberRequest.getOrganizationId()));
|
||||
batchRequest.setMemberIds(organizationMemberRequest.getMemberIds());
|
||||
batchRequest.setUserIds(organizationMemberRequest.getUserIds());
|
||||
addMemberBySystem(batchRequest, createUserId);
|
||||
// 添加日志
|
||||
UserExample example = new UserExample();
|
||||
example.createCriteria().andIdIn(batchRequest.getUserIds());
|
||||
List<User> users = userMapper.selectByExample(example);
|
||||
Organization organization = organizationMapper.selectByPrimaryKey(organizationMemberRequest.getOrganizationId());
|
||||
setLog(organizationMemberRequest.getOrganizationId(), createUserId, OperationLogType.ADD.name(), organization.getName(),
|
||||
ADD_MEMBER_PATH, null, batchRequest.getMemberIds(), logs);
|
||||
setLog(organizationMemberRequest.getOrganizationId(), createUserId, OperationLogType.UPDATE.name(), organization.getName(), ADD_MEMBER_PATH, null, users, logs);
|
||||
operationLogService.batchAdd(logs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织添加成员公共方法(N个组织添加N个成员)
|
||||
*
|
||||
* @param batchRequest 请求参数 [organizationIds 组织集合, memberIds 成员集合]
|
||||
* @param batchRequest 请求参数 [organizationIds 组织集合, userIds 成员集合]
|
||||
* @param createUserId 创建人ID
|
||||
*/
|
||||
public void addMemberBySystem(OrganizationMemberBatchRequest batchRequest, String createUserId) {
|
||||
checkOrgExistByIds(batchRequest.getOrganizationIds());
|
||||
Map<String, User> userMap = checkUserExist(batchRequest.getMemberIds());
|
||||
Map<String, User> userMap = checkUserExist(batchRequest.getUserIds());
|
||||
List<UserRoleRelation> userRoleRelations = new ArrayList<>();
|
||||
batchRequest.getOrganizationIds().forEach(organizationId -> {
|
||||
for (String userId : batchRequest.getMemberIds()) {
|
||||
for (String userId : batchRequest.getUserIds()) {
|
||||
if (userMap.get(userId) == null) {
|
||||
throw new MSException(Translator.get("user.not.exist") + ", id: " + userId);
|
||||
}
|
||||
|
@ -213,8 +213,9 @@ public class OrganizationService {
|
|||
example.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(organizationId);
|
||||
userRoleRelationMapper.deleteByExample(example);
|
||||
// 操作记录
|
||||
User user = userMapper.selectByPrimaryKey(userId);
|
||||
Organization organization = organizationMapper.selectByPrimaryKey(organizationId);
|
||||
setLog(organizationId, userId, OperationLogType.DELETE.name(), organization.getName(), REMOVE_MEMBER_PATH, userId, null, logs);
|
||||
setLog(organizationId, userId, OperationLogType.UPDATE.name(), organization.getName(), REMOVE_MEMBER_PATH, user, null, logs);
|
||||
operationLogService.batchAdd(logs);
|
||||
}
|
||||
|
||||
|
@ -312,7 +313,7 @@ public class OrganizationService {
|
|||
public void addMemberByOrg(OrganizationMemberExtendRequest organizationMemberExtendRequest, String createUserId) {
|
||||
String organizationId = organizationMemberExtendRequest.getOrganizationId();
|
||||
checkOrgExistById(organizationId);
|
||||
Map<String, User> userMap = checkUserExist(organizationMemberExtendRequest.getMemberIds());
|
||||
Map<String, User> userMap = checkUserExist(organizationMemberExtendRequest.getUserIds());
|
||||
Map<String, UserRole> userRoleMap = checkUseRoleExist(organizationMemberExtendRequest.getUserRoleIds(), organizationId);
|
||||
setRelationByMemberAndGroupIds(organizationMemberExtendRequest, createUserId, userMap, userRoleMap, true);
|
||||
}
|
||||
|
@ -322,7 +323,7 @@ public class OrganizationService {
|
|||
UserRoleRelationMapper userRoleRelationMapper = sqlSession.getMapper(UserRoleRelationMapper.class);
|
||||
List<LogDTO> logDTOList = new ArrayList<>();
|
||||
String organizationId = organizationMemberExtendRequest.getOrganizationId();
|
||||
organizationMemberExtendRequest.getMemberIds().forEach(memberId -> {
|
||||
organizationMemberExtendRequest.getUserIds().forEach(memberId -> {
|
||||
if (userMap.get(memberId) == null) {
|
||||
throw new MSException("id:" + memberId + Translator.get("user.not.exist"));
|
||||
}
|
||||
|
@ -373,7 +374,7 @@ public class OrganizationService {
|
|||
public void addMemberRole(OrganizationMemberExtendRequest organizationMemberExtendRequest, String userId) {
|
||||
String organizationId = organizationMemberExtendRequest.getOrganizationId();
|
||||
checkOrgExistById(organizationId);
|
||||
Map<String, User> userMap = checkUserExist(organizationMemberExtendRequest.getMemberIds());
|
||||
Map<String, User> userMap = checkUserExist(organizationMemberExtendRequest.getUserIds());
|
||||
Map<String, UserRole> userRoleMap = checkUseRoleExist(organizationMemberExtendRequest.getUserRoleIds(), organizationId);
|
||||
//在新增组织成员与用户组和组织的关系
|
||||
setRelationByMemberAndGroupIds(organizationMemberExtendRequest, userId, userMap, userRoleMap, false);
|
||||
|
@ -387,7 +388,7 @@ public class OrganizationService {
|
|||
List<LogDTO> logDTOList = new ArrayList<>();
|
||||
List<String> projectIds = orgMemberExtendProjectRequest.getProjectIds();
|
||||
//用户不在当前组织内过掉
|
||||
Map<String, User> userMap = checkUserExist(orgMemberExtendProjectRequest.getMemberIds());
|
||||
Map<String, User> userMap = checkUserExist(orgMemberExtendProjectRequest.getUserIds());
|
||||
List<String> userIds = userMap.values().stream().map(User::getId).toList();
|
||||
userIds.forEach(memberId -> {
|
||||
projectIds.forEach(projectId -> {
|
||||
|
@ -730,12 +731,12 @@ public class OrganizationService {
|
|||
/**
|
||||
* 检查用户是否存在
|
||||
*
|
||||
* @param memberIds 成员ID集合
|
||||
* @param userIds 成员ID集合
|
||||
* @return 用户集合
|
||||
*/
|
||||
private Map<String, User> checkUserExist(List<String> memberIds) {
|
||||
private Map<String, User> checkUserExist(List<String> userIds) {
|
||||
UserExample userExample = new UserExample();
|
||||
userExample.createCriteria().andIdIn(memberIds);
|
||||
userExample.createCriteria().andIdIn(userIds);
|
||||
List<User> users = userMapper.selectByExample(userExample);
|
||||
if (CollectionUtils.isEmpty(users)) {
|
||||
throw new MSException(Translator.get("user.not.exist"));
|
||||
|
@ -800,7 +801,7 @@ public class OrganizationService {
|
|||
organizationId,
|
||||
createUser,
|
||||
type,
|
||||
OperationLogModule.SYSTEM_ORGANIZATION,
|
||||
OperationLogModule.SETTING_SYSTEM_ORGANIZATION,
|
||||
content);
|
||||
dto.setPath(path);
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
|
|
|
@ -7,6 +7,7 @@ import io.metersphere.sdk.log.constants.OperationLogModule;
|
|||
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.domain.UserRole;
|
||||
import io.metersphere.system.domain.UserRoleExample;
|
||||
import io.metersphere.system.mapper.UserRoleMapper;
|
||||
import io.metersphere.system.request.OrganizationUserRoleEditRequest;
|
||||
import io.metersphere.system.request.OrganizationUserRoleMemberEditRequest;
|
||||
|
@ -14,6 +15,10 @@ import jakarta.annotation.Resource;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
/**
|
||||
* @author song-cc-rock
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class OrganizationUserRoleLogService {
|
||||
|
@ -30,13 +35,13 @@ public class OrganizationUserRoleLogService {
|
|||
LogDTO dto = new LogDTO(
|
||||
OperationLogConstants.ORGANIZATION,
|
||||
request.getScopeId(),
|
||||
null,
|
||||
OperationLogConstants.SYSTEM,
|
||||
null,
|
||||
OperationLogType.ADD.name(),
|
||||
OperationLogModule.ORGANIZATION_USER_ROLE,
|
||||
OperationLogModule.SETTING_ORGANIZATION_USER_ROLE,
|
||||
request.getName());
|
||||
|
||||
dto.setOriginalValue(JSON.toJSONBytes(request));
|
||||
dto.setOriginalValue(JSON.toJSONBytes(request.getName()));
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
@ -49,13 +54,17 @@ public class OrganizationUserRoleLogService {
|
|||
LogDTO dto = new LogDTO(
|
||||
OperationLogConstants.ORGANIZATION,
|
||||
request.getScopeId(),
|
||||
request.getId(),
|
||||
OperationLogConstants.SYSTEM,
|
||||
null,
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.ORGANIZATION_USER_ROLE,
|
||||
OperationLogModule.SETTING_ORGANIZATION_USER_ROLE,
|
||||
request.getName());
|
||||
|
||||
dto.setOriginalValue(JSON.toJSONBytes(request));
|
||||
UserRoleExample example = new UserRoleExample();
|
||||
example.createCriteria().andIdEqualTo(request.getId());
|
||||
UserRole userRole = userRoleMapper.selectByExample(example).get(0);
|
||||
dto.setOriginalValue(JSON.toJSONBytes(userRole.getName()));
|
||||
dto.setModifiedValue(JSON.toJSONBytes(request.getName()));
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
@ -69,13 +78,13 @@ public class OrganizationUserRoleLogService {
|
|||
LogDTO dto = new LogDTO(
|
||||
OperationLogConstants.ORGANIZATION,
|
||||
userRole.getScopeId(),
|
||||
id,
|
||||
OperationLogConstants.SYSTEM,
|
||||
null,
|
||||
OperationLogType.DELETE.name(),
|
||||
OperationLogModule.ORGANIZATION_USER_ROLE,
|
||||
OperationLogModule.SETTING_ORGANIZATION_USER_ROLE,
|
||||
userRole.getName());
|
||||
|
||||
dto.setOriginalValue(JSON.toJSONBytes(userRole));
|
||||
dto.setOriginalValue(JSON.toJSONBytes(userRole.getName()));
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
@ -99,7 +108,7 @@ public class OrganizationUserRoleLogService {
|
|||
public LogDTO editMemberLog(OrganizationUserRoleMemberEditRequest request) {
|
||||
LogDTO dto = getLog(request.getUserRoleId());
|
||||
dto.setType(OperationLogType.UPDATE.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(request));
|
||||
dto.setModifiedValue(JSON.toJSONBytes(request));
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
@ -108,10 +117,10 @@ public class OrganizationUserRoleLogService {
|
|||
return new LogDTO(
|
||||
OperationLogConstants.ORGANIZATION,
|
||||
userRole.getScopeId(),
|
||||
roleId,
|
||||
OperationLogConstants.SYSTEM,
|
||||
null,
|
||||
null,
|
||||
OperationLogModule.ORGANIZATION_USER_ROLE,
|
||||
OperationLogModule.SETTING_ORGANIZATION_USER_ROLE,
|
||||
userRole.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,20 +4,26 @@ import io.metersphere.sdk.constants.InternalUserRole;
|
|||
import io.metersphere.sdk.dto.PermissionDefinitionItem;
|
||||
import io.metersphere.sdk.dto.request.PermissionSettingUpdateRequest;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.mapper.BaseUserMapper;
|
||||
import io.metersphere.sdk.service.BaseUserRoleService;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.domain.*;
|
||||
import io.metersphere.system.mapper.*;
|
||||
import io.metersphere.system.dto.UserExtend;
|
||||
import io.metersphere.system.mapper.ExtUserRoleMapper;
|
||||
import io.metersphere.system.mapper.UserMapper;
|
||||
import io.metersphere.system.mapper.UserRoleMapper;
|
||||
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
||||
import io.metersphere.system.request.OrganizationUserRoleMemberEditRequest;
|
||||
import io.metersphere.system.request.OrganizationUserRoleMemberRequest;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static io.metersphere.system.controller.result.SystemResultCode.NO_ORG_USER_ROLE_PERMISSION;
|
||||
|
||||
|
@ -35,6 +41,8 @@ public class OrganizationUserRoleService extends BaseUserRoleService {
|
|||
@Resource
|
||||
UserMapper userMapper;
|
||||
@Resource
|
||||
BaseUserMapper baseUserMapper;
|
||||
@Resource
|
||||
UserRoleMapper userRoleMapper;
|
||||
@Resource
|
||||
ExtUserRoleMapper extUserRoleMapper;
|
||||
|
@ -72,6 +80,35 @@ public class OrganizationUserRoleService extends BaseUserRoleService {
|
|||
super.delete(userRole, InternalUserRole.ORG_MEMBER.getValue(), currentUserId);
|
||||
}
|
||||
|
||||
public List<UserExtend> getMember(String organizationId, String roleId) {
|
||||
List<UserExtend> userExtends = new ArrayList<>();
|
||||
// 查询所有用户
|
||||
List<User> users = baseUserMapper.findAll();
|
||||
Map<String, User> userMap = users.stream().collect(Collectors.toMap(User::getId, user -> user));
|
||||
// 查询组织下所有用户关系
|
||||
UserRoleRelationExample example = new UserRoleRelationExample();
|
||||
example.createCriteria().andSourceIdEqualTo(organizationId);
|
||||
List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(userRoleRelations)) {
|
||||
Map<String, List<String>> userRoleMap = userRoleRelations.stream().collect(Collectors.groupingBy(UserRoleRelation::getUserId,
|
||||
Collectors.mapping(UserRoleRelation::getRoleId, Collectors.toList())));
|
||||
userRoleMap.forEach((k, v) -> {
|
||||
UserExtend userExtend = new UserExtend();
|
||||
User user = userMap.get(k);
|
||||
if (user != null) {
|
||||
BeanUtils.copyBean(userExtend, user);
|
||||
}
|
||||
v.forEach(roleItem -> {
|
||||
if (StringUtils.equals(roleItem, roleId)) {
|
||||
userExtend.setCheckRoleFlag(true);
|
||||
}
|
||||
});
|
||||
userExtends.add(userExtend);
|
||||
});
|
||||
}
|
||||
return userExtends;
|
||||
}
|
||||
|
||||
public List<User> listMember(OrganizationUserRoleMemberRequest request) {
|
||||
return extUserRoleMapper.listOrganizationRoleMember(request);
|
||||
}
|
||||
|
|
|
@ -413,10 +413,28 @@ public class UserService {
|
|||
return userMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组织, 项目系统成员选项
|
||||
*
|
||||
* @param sourceId 组织ID, 项目ID
|
||||
* @return 系统用户选项
|
||||
*/
|
||||
public List<UserExtend> getMemberOption(String sourceId) {
|
||||
return extUserMapper.getMemberOption(sourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统用户选项
|
||||
*
|
||||
* @return 系统用户选项
|
||||
*/
|
||||
public List<OptionDTO> getMemberOption() {
|
||||
UserExample example = new UserExample();
|
||||
example.setOrderByClause("update_time desc");
|
||||
List<User> users = userMapper.selectByExample(example);
|
||||
return users.stream().map(user -> new OptionDTO(user.getId(), user.getName())).toList();
|
||||
}
|
||||
|
||||
public TableBatchProcessResponse resetPassword(TableBatchProcessDTO request, String operator) {
|
||||
request.setSelectIds(this.getBatchUserIds(request));
|
||||
this.checkUserInDb(request.getSelectIds());
|
||||
|
|
|
@ -31,7 +31,6 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
|
@ -57,7 +56,7 @@ public class OrganizationControllerTests extends BaseTest {
|
|||
public void addMemberByOrgSuccess() throws Exception {
|
||||
OrganizationMemberExtendRequest organizationMemberRequest = new OrganizationMemberExtendRequest();
|
||||
organizationMemberRequest.setOrganizationId("sys_default_organization_3");
|
||||
organizationMemberRequest.setMemberIds(Arrays.asList("sys_default_user", "sys_default_user2"));
|
||||
organizationMemberRequest.setUserIds(Arrays.asList("sys_default_user", "sys_default_user2"));
|
||||
organizationMemberRequest.setUserRoleIds(Arrays.asList("sys_default_org_role_id_3", "sys_default_project_role_id_1"));
|
||||
this.requestPost(ORGANIZATION_LIST_ADD_MEMBER, organizationMemberRequest, status().isOk());
|
||||
// 批量添加成员成功后, 验证是否添加成功
|
||||
|
@ -128,7 +127,7 @@ public class OrganizationControllerTests extends BaseTest {
|
|||
public void updateOrgMemberSuccessWithNoSysProjectIds() throws Exception {
|
||||
OrganizationMemberExtendRequest organizationMemberRequest = new OrganizationMemberExtendRequest();
|
||||
organizationMemberRequest.setOrganizationId("sys_default_organization_7");
|
||||
organizationMemberRequest.setMemberIds(Arrays.asList("sys_default_user", "sys_default_user2"));
|
||||
organizationMemberRequest.setUserIds(Arrays.asList("sys_default_user", "sys_default_user2"));
|
||||
organizationMemberRequest.setUserRoleIds(Arrays.asList("sys_default_org_role_id_7", "sys_default_project_role_id_8"));
|
||||
this.requestPost(ORGANIZATION_LIST_ADD_MEMBER, organizationMemberRequest, status().isOk());
|
||||
|
||||
|
@ -181,7 +180,7 @@ public class OrganizationControllerTests extends BaseTest {
|
|||
public void updateOrgMemberToRoleSuccess() throws Exception {
|
||||
OrganizationMemberExtendRequest organizationMemberRequest = new OrganizationMemberExtendRequest();
|
||||
organizationMemberRequest.setOrganizationId("sys_default_organization_3");
|
||||
organizationMemberRequest.setMemberIds(Arrays.asList("sys_default_user", "sys_default_user2"));
|
||||
organizationMemberRequest.setUserIds(Arrays.asList("sys_default_user", "sys_default_user2"));
|
||||
organizationMemberRequest.setUserRoleIds(List.of("sys_default_org_role_id_4"));
|
||||
this.requestPost(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, organizationMemberRequest, status().isOk());
|
||||
// 批量添加成员成功后, 验证是否添加成功
|
||||
|
@ -222,7 +221,7 @@ public class OrganizationControllerTests extends BaseTest {
|
|||
public void addOrgMemberToProjectSuccess() throws Exception {
|
||||
OrgMemberExtendProjectRequest organizationMemberRequest = new OrgMemberExtendProjectRequest();
|
||||
organizationMemberRequest.setOrganizationId("sys_default_organization_3");
|
||||
organizationMemberRequest.setMemberIds(Arrays.asList("sys_default_user", "sys_default_user2"));
|
||||
organizationMemberRequest.setUserIds(Arrays.asList("sys_default_user", "sys_default_user2"));
|
||||
organizationMemberRequest.setProjectIds(Arrays.asList("sys_org_projectId2", "sys_org_projectId3"));
|
||||
this.requestPost(ORGANIZATION_PROJECT_ADD_MEMBER, organizationMemberRequest, status().isOk());
|
||||
// 批量添加成员成功后, 验证是否添加成功
|
||||
|
@ -514,10 +513,10 @@ public class OrganizationControllerTests extends BaseTest {
|
|||
}
|
||||
}
|
||||
|
||||
private void addOrganizationMemberError(String url, String organizationId, List<String> memberIds, List<String> userGroupIds, ResultMatcher resultMatcher) throws Exception {
|
||||
private void addOrganizationMemberError(String url, String organizationId, List<String> userIds, List<String> userGroupIds, ResultMatcher resultMatcher) throws Exception {
|
||||
OrganizationMemberExtendRequest organizationMemberRequest = new OrganizationMemberExtendRequest();
|
||||
organizationMemberRequest.setOrganizationId(organizationId);
|
||||
organizationMemberRequest.setMemberIds(memberIds);
|
||||
organizationMemberRequest.setUserIds(userIds);
|
||||
organizationMemberRequest.setUserRoleIds(userGroupIds);
|
||||
this.requestPost(url, organizationMemberRequest, resultMatcher);
|
||||
}
|
||||
|
@ -532,10 +531,10 @@ public class OrganizationControllerTests extends BaseTest {
|
|||
}
|
||||
|
||||
|
||||
private void addOrUpdateOrganizationProjectMemberError(String url, String organizationId, List<String> memberIds, List<String> projectIds, ResultMatcher resultMatcher) throws Exception {
|
||||
private void addOrUpdateOrganizationProjectMemberError(String url, String organizationId, List<String> userIds, List<String> projectIds, ResultMatcher resultMatcher) throws Exception {
|
||||
OrgMemberExtendProjectRequest organizationMemberRequest = new OrgMemberExtendProjectRequest();
|
||||
organizationMemberRequest.setOrganizationId(organizationId);
|
||||
organizationMemberRequest.setMemberIds(memberIds);
|
||||
organizationMemberRequest.setUserIds(userIds);
|
||||
organizationMemberRequest.setProjectIds(projectIds);
|
||||
this.requestPost(url, organizationMemberRequest, resultMatcher);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import io.metersphere.sdk.constants.PermissionConstants;
|
|||
import io.metersphere.sdk.constants.SessionConstants;
|
||||
import io.metersphere.sdk.controller.handler.ResultHolder;
|
||||
import io.metersphere.sdk.dto.request.PermissionSettingUpdateRequest;
|
||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.service.BaseUserRolePermissionService;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
|
@ -38,7 +37,6 @@ import java.util.stream.Collectors;
|
|||
|
||||
import static io.metersphere.sdk.controller.handler.result.CommonResultCode.INTERNAL_USER_ROLE_PERMISSION;
|
||||
import static io.metersphere.system.controller.result.SystemResultCode.NO_ORG_USER_ROLE_PERMISSION;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
@SpringBootTest
|
||||
|
@ -60,6 +58,7 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
|
|||
public static final String ORGANIZATION_USER_ROLE_DELETE = "/user/role/organization/delete";
|
||||
public static final String ORGANIZATION_USER_ROLE_PERMISSION_SETTING = "/user/role/organization/permission/setting";
|
||||
public static final String ORGANIZATION_USER_ROLE_PERMISSION_UPDATE = "/user/role/organization/permission/update";
|
||||
public static final String ORGANIZATION_USER_ROLE_GET_MEMBER_OPTION = "/user/role/organization/get-member/option";
|
||||
public static final String ORGANIZATION_USER_ROLE_LIST_MEMBER = "/user/role/organization/list-member";
|
||||
public static final String ORGANIZATION_USER_ROLE_ADD_MEMBER = "/user/role/organization/add-member";
|
||||
public static final String ORGANIZATION_USER_ROLE_REMOVE_MEMBER = "/user/role/organization/remove-member";
|
||||
|
@ -100,11 +99,6 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
|
|||
Assertions.assertNotNull(resultHolder);
|
||||
// 返回总条数是否为init_organization_user_role.sql中的数据总数
|
||||
Assertions.assertFalse(JSON.parseArray(JSON.toJSONString(resultHolder.getData())).isEmpty());
|
||||
// 日志校验
|
||||
String addResultStr = addResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
ResultHolder addResultHolder = JSON.parseObject(addResultStr, ResultHolder.class);
|
||||
UserRole userRole = JSON.parseObject(JSON.toJSONString(addResultHolder.getData()), UserRole.class);
|
||||
checkLog(userRole.getId(), OperationLogType.ADD);
|
||||
// 权限校验
|
||||
requestPostPermissionTest(PermissionConstants.ORGANIZATION_USER_ROLE_READ_ADD, ORGANIZATION_USER_ROLE_ADD, request);
|
||||
}
|
||||
|
@ -164,8 +158,6 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
|
|||
// 返回总条数是否包含修改后的数据
|
||||
List<UserRole> userRoles = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), UserRole.class);
|
||||
Assertions.assertTrue(userRoles.stream().anyMatch(userRole -> "default-org-role-x".equals(userRole.getName())));
|
||||
// 日志校验
|
||||
checkLog(request.getId(), OperationLogType.UPDATE);
|
||||
// 权限校验
|
||||
requestPostPermissionTest(PermissionConstants.ORGANIZATION_USER_ROLE_READ_UPDATE, ORGANIZATION_USER_ROLE_UPDATE, request);
|
||||
}
|
||||
|
@ -185,8 +177,6 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
|
|||
@Order(6)
|
||||
public void testOrganizationUserRoleDeleteSuccess() throws Exception {
|
||||
this.requestGet(ORGANIZATION_USER_ROLE_DELETE + "/default-org-role-id-2", status().isOk());
|
||||
// 日志校验
|
||||
checkLog("default-org-role-id-2", OperationLogType.DELETE);
|
||||
// 权限校验
|
||||
requestGetPermissionTest(PermissionConstants.ORGANIZATION_USER_ROLE_READ_DELETE, ORGANIZATION_USER_ROLE_DELETE + "/default-org-role-id-2");
|
||||
}
|
||||
|
@ -230,8 +220,6 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
|
|||
.collect(Collectors.toSet());
|
||||
// 校验请求成功数据
|
||||
Assertions.assertEquals(requestPermissionIds, permissionIds);
|
||||
// 日志校验
|
||||
checkLog(request.getUserRoleId(), OperationLogType.UPDATE);
|
||||
// 权限校验
|
||||
requestPostPermissionTest(PermissionConstants.ORGANIZATION_USER_ROLE_READ_UPDATE, ORGANIZATION_USER_ROLE_PERMISSION_UPDATE, request);
|
||||
}
|
||||
|
@ -314,8 +302,6 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
|
|||
request.setUserRoleId("default-org-role-id-3");
|
||||
request.setUserIds(List.of("admin"));
|
||||
this.requestPost(ORGANIZATION_USER_ROLE_ADD_MEMBER, request, status().isOk());
|
||||
// 日志校验
|
||||
checkLog(request.getUserRoleId(), OperationLogType.UPDATE);
|
||||
// 权限校验
|
||||
request.setOrganizationId(getDefault().getId());
|
||||
requestPostPermissionTest(PermissionConstants.ORGANIZATION_USER_ROLE_READ_UPDATE, ORGANIZATION_USER_ROLE_ADD_MEMBER, request);
|
||||
|
@ -340,6 +326,14 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
|
|||
|
||||
@Test
|
||||
@Order(15)
|
||||
public void testOrganizationUserRoleGetMemberOption() throws Exception {
|
||||
this.responseGet(ORGANIZATION_USER_ROLE_GET_MEMBER_OPTION + "/default-organization-2/default-org-role-id-4");
|
||||
// 组织下无用户
|
||||
this.responseGet(ORGANIZATION_USER_ROLE_GET_MEMBER_OPTION + "/default-organization-3/default-org-role-id-3");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(16)
|
||||
public void testOrganizationUserRoleRemoveMemberSuccess() throws Exception {
|
||||
OrganizationUserRoleMemberEditRequest request = new OrganizationUserRoleMemberEditRequest();
|
||||
request.setOrganizationId("default-organization-2");
|
||||
|
@ -348,15 +342,13 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
|
|||
this.requestPost(ORGANIZATION_USER_ROLE_ADD_MEMBER, request, status().isOk());
|
||||
// 成员组织用户组存在多个, 移除成功
|
||||
this.requestPost(ORGANIZATION_USER_ROLE_REMOVE_MEMBER, request, status().isOk());
|
||||
// 日志校验
|
||||
checkLog(request.getUserRoleId(), OperationLogType.UPDATE);
|
||||
// 权限校验
|
||||
request.setOrganizationId(getDefault().getId());
|
||||
requestPostPermissionTest(PermissionConstants.ORGANIZATION_USER_ROLE_READ_UPDATE, ORGANIZATION_USER_ROLE_REMOVE_MEMBER, request);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(16)
|
||||
@Order(17)
|
||||
public void testOrganizationUserRoleRemoveMemberError() throws Exception {
|
||||
OrganizationUserRoleMemberEditRequest request = new OrganizationUserRoleMemberEditRequest();
|
||||
request.setOrganizationId("default-organization-2");
|
||||
|
@ -379,7 +371,7 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Order(17)
|
||||
@Order(18)
|
||||
public void testOrganizationUserRoleDeleteOnlyMemberSuccess() throws Exception {
|
||||
OrganizationUserRoleMemberEditRequest request = new OrganizationUserRoleMemberEditRequest();
|
||||
request.setOrganizationId("default-organization-2");
|
||||
|
|
|
@ -47,7 +47,7 @@ public class SystemOrganizationControllerTests extends BaseTest{
|
|||
public static final String ORGANIZATION_ADD_MEMBER = "/system/organization/add-member";
|
||||
public static final String ORGANIZATION_REMOVE_MEMBER = "/system/organization/remove-member";
|
||||
public static final String ORGANIZATION_LIST_PROJECT = "/system/organization/list-project";
|
||||
public static final String ORGANIZATION_MEMBER_OPTION = "/system/user/get-option";
|
||||
public static final String ORGANIZATION_MEMBER_OPTION = "/system/organization/get-option";
|
||||
public static final String ORGANIZATION_TOTAL = "/system/organization/total";
|
||||
|
||||
@Test
|
||||
|
@ -217,10 +217,10 @@ public class SystemOrganizationControllerTests extends BaseTest{
|
|||
public void testAddOrganizationMemberSuccess() throws Exception {
|
||||
OrganizationMemberRequest organizationMemberRequest = new OrganizationMemberRequest();
|
||||
organizationMemberRequest.setOrganizationId("default-organization-3");
|
||||
organizationMemberRequest.setMemberIds(List.of("admin", "default-admin"));
|
||||
organizationMemberRequest.setUserIds(List.of("admin", "default-admin"));
|
||||
this.requestPost(ORGANIZATION_ADD_MEMBER, organizationMemberRequest, status().isOk());
|
||||
// 日志校验
|
||||
checkLog(organizationMemberRequest.getOrganizationId(), OperationLogType.ADD);
|
||||
checkLog(organizationMemberRequest.getOrganizationId(), OperationLogType.UPDATE);
|
||||
// 批量添加成员成功后, 验证是否添加成功
|
||||
OrganizationRequest organizationRequest = new OrganizationRequest();
|
||||
organizationRequest.setCurrent(1);
|
||||
|
@ -246,7 +246,7 @@ public class SystemOrganizationControllerTests extends BaseTest{
|
|||
|| StringUtils.contains(userExtend.getEmail(), organizationRequest.getKeyword())
|
||||
|| StringUtils.contains(userExtend.getPhone(), organizationRequest.getKeyword()));
|
||||
// 权限校验
|
||||
organizationMemberRequest.setMemberIds(List.of("admin"));
|
||||
organizationMemberRequest.setUserIds(List.of("admin"));
|
||||
requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_MEMBER_ADD, ORGANIZATION_ADD_MEMBER, organizationMemberRequest);
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ public class SystemOrganizationControllerTests extends BaseTest{
|
|||
public void testAddOrganizationMemberSuccessWithRepeatUser() throws Exception {
|
||||
OrganizationMemberRequest organizationMemberRequest = new OrganizationMemberRequest();
|
||||
organizationMemberRequest.setOrganizationId("default-organization-3");
|
||||
organizationMemberRequest.setMemberIds(List.of("admin"));
|
||||
organizationMemberRequest.setUserIds(List.of("admin"));
|
||||
this.requestPost(ORGANIZATION_ADD_MEMBER, organizationMemberRequest, status().isOk());
|
||||
// 批量添加成员成功后, 验证是否添加成功
|
||||
OrganizationRequest organizationRequest = new OrganizationRequest();
|
||||
|
@ -289,22 +289,22 @@ public class SystemOrganizationControllerTests extends BaseTest{
|
|||
// 成员选择为空
|
||||
OrganizationMemberRequest organizationMemberRequest = new OrganizationMemberRequest();
|
||||
organizationMemberRequest.setOrganizationId("default-organization-3");
|
||||
organizationMemberRequest.setMemberIds(Collections.emptyList());
|
||||
organizationMemberRequest.setUserIds(Collections.emptyList());
|
||||
this.requestPost(ORGANIZATION_ADD_MEMBER, organizationMemberRequest, status().isBadRequest());
|
||||
// 成员都不存在
|
||||
organizationMemberRequest = new OrganizationMemberRequest();
|
||||
organizationMemberRequest.setOrganizationId("default-organization-3");
|
||||
organizationMemberRequest.setMemberIds(Arrays.asList("SccNotExistOne", "SccNotExistTwo"));
|
||||
organizationMemberRequest.setUserIds(Arrays.asList("SccNotExistOne", "SccNotExistTwo"));
|
||||
this.requestPost(ORGANIZATION_ADD_MEMBER, organizationMemberRequest, status().is5xxServerError());
|
||||
// 成员有一个不存在
|
||||
organizationMemberRequest = new OrganizationMemberRequest();
|
||||
organizationMemberRequest.setOrganizationId("default-organization-3");
|
||||
organizationMemberRequest.setMemberIds(Arrays.asList("SccNotExistOne", "default-admin"));
|
||||
organizationMemberRequest.setUserIds(Arrays.asList("SccNotExistOne", "default-admin"));
|
||||
this.requestPost(ORGANIZATION_ADD_MEMBER, organizationMemberRequest, status().is5xxServerError());
|
||||
// 组织不存在
|
||||
organizationMemberRequest = new OrganizationMemberRequest();
|
||||
organizationMemberRequest.setOrganizationId("default-organization-x");
|
||||
organizationMemberRequest.setMemberIds(Arrays.asList("admin", "default-admin"));
|
||||
organizationMemberRequest.setUserIds(Arrays.asList("admin", "default-admin"));
|
||||
this.requestPost(ORGANIZATION_ADD_MEMBER, organizationMemberRequest, status().is5xxServerError());
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ public class SystemOrganizationControllerTests extends BaseTest{
|
|||
public void testRemoveOrganizationMemberSuccess() throws Exception {
|
||||
this.requestGet(ORGANIZATION_REMOVE_MEMBER + "/default-organization-3/admin", status().isOk());
|
||||
// 日志校验
|
||||
checkLog("default-organization-3", OperationLogType.DELETE);
|
||||
checkLog("default-organization-3", OperationLogType.UPDATE);
|
||||
// 权限校验
|
||||
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_MEMBER_DELETE, ORGANIZATION_REMOVE_MEMBER + "/default-organization-3/admin");
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ public class SystemOrganizationControllerTests extends BaseTest{
|
|||
Assertions.assertNotNull(resultHolder);
|
||||
|
||||
// 权限校验
|
||||
requestGetPermissionTest(PermissionConstants.SYSTEM_USER_READ, SystemOrganizationControllerTests.ORGANIZATION_MEMBER_OPTION + "/default-organization-2");
|
||||
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, SystemOrganizationControllerTests.ORGANIZATION_MEMBER_OPTION + "/default-organization-2");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -13,3 +13,5 @@ INSERT INTO user_role_permission (id, role_id, permission_id) VALUE
|
|||
(uuid(), 'default-org-role-id-3', 'ORGANIZATION_USER_ROLE:READ');
|
||||
INSERT INTO user_role_relation (id, user_id, role_id, source_id, create_time, create_user) VALUE
|
||||
(UUID(), 'default-admin-user', 'default-org-role-id-3', 'default-organization-2', UNIX_TIMESTAMP() * 1000, 'admin');
|
||||
INSERT INTO user_role_relation (id, user_id, role_id, source_id, create_time, create_user) VALUE
|
||||
(UUID(), 'default-admin-user-x', 'default-org-role-id-4', 'default-organization-2', UNIX_TIMESTAMP() * 1000, 'admin');
|
Loading…
Reference in New Issue