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