chore: rename uuid to id generator

This commit is contained in:
CaptainB 2023-10-20 14:05:19 +08:00 committed by 刘瑞斌
parent 453522432b
commit f39fc156c4
45 changed files with 136 additions and 139 deletions

View File

@ -4,7 +4,7 @@ import io.metersphere.api.dto.jmeter.processors.MSJSR223Processor;
import io.metersphere.api.dto.jmeter.sampler.MSDebugSampler;
import io.metersphere.api.util.ApiDataUtils;
import io.metersphere.plugin.api.dto.TestElementDTO;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import org.junit.jupiter.api.*;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
@ -22,7 +22,7 @@ public class PluginSubTypeTests {
public void pluginSubTypeTest() throws Exception {
MSDebugSampler debugSampler = new MSDebugSampler();
debugSampler.setName("测试DebugSampler");
debugSampler.setUuid(UUID.randomUUID().toString());
debugSampler.setUuid(IDGenerator.nextStr());
LinkedList<TestElementDTO> hashTree = new LinkedList<>();
hashTree.add(debugSampler);
MSJSR223Processor msjsr223Processor = new MSJSR223Processor();

View File

@ -7,7 +7,7 @@ import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.LogUtils;
import io.metersphere.sdk.util.MsFileUtils;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.util.FileUtil;
import org.springframework.stereotype.Service;
@ -29,7 +29,7 @@ public class CommandService {
if (!fileDir.exists()) {
fileDir.mkdirs();
}
File file = new File(dir + UUID.randomUUID().toString() + "_" + bodyFile.getOriginalFilename());
File file = new File(dir + IDGenerator.nextStr() + "_" + bodyFile.getOriginalFilename());
try (InputStream in = bodyFile.getInputStream(); OutputStream out = new FileOutputStream(file)) {
file.createNewFile();
FileUtil.copyStream(in, out);

View File

@ -14,7 +14,7 @@ import io.metersphere.sdk.dto.OptionDTO;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.notice.constants.NoticeConstants;
import io.metersphere.system.service.CreateProjectResourceService;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -44,7 +44,7 @@ public class CreateRobotResourceService implements CreateProjectResourceService
public void createResources(String projectId) {
List<ProjectRobot> list = new ArrayList<>();
ProjectRobot projectRobot = new ProjectRobot();
String inSiteId = UUID.randomUUID().toString();
String inSiteId = IDGenerator.nextStr();
projectRobot.setId(inSiteId);
projectRobot.setProjectId(projectId);
projectRobot.setName("robot_in_site");
@ -58,7 +58,7 @@ public class CreateRobotResourceService implements CreateProjectResourceService
projectRobot.setDescription("robot_in_site_description");
list.add(projectRobot);
ProjectRobot projectRobotMail = new ProjectRobot();
projectRobotMail.setId(UUID.randomUUID().toString());
projectRobotMail.setId(IDGenerator.nextStr());
projectRobotMail.setProjectId(projectId);
projectRobotMail.setName("robot_mail");
projectRobotMail.setPlatform(ProjectRobotPlatform.MAIL.toString());
@ -108,7 +108,7 @@ public class CreateRobotResourceService implements CreateProjectResourceService
continue;
}
for (OptionDTO receiver : receivers) {
String id = UUID.randomUUID().toString();
String id = IDGenerator.nextStr();
MessageTask messageTask = new MessageTask();
messageTask.setId(id);
messageTask.setEvent(event);

View File

@ -7,7 +7,7 @@ import io.metersphere.sdk.constants.InternalUserRole;
import io.metersphere.sdk.constants.ProjectApplicationType;
import io.metersphere.sdk.util.LogUtils;
import io.metersphere.system.service.CreateProjectResourceService;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
@ -31,7 +31,7 @@ public class CreateVersionResourceService implements CreateProjectResourceServic
public void createResources(String projectId) {
// 初始化版本V1.0, 初始化版本配置项
ProjectVersion defaultVersion = new ProjectVersion();
defaultVersion.setId(UUID.randomUUID().toString());
defaultVersion.setId(IDGenerator.nextStr());
defaultVersion.setProjectId(projectId);
defaultVersion.setName(DEFAULT_VERSION);
defaultVersion.setStatus(DEFAULT_VERSION_STATUS);

View File

@ -28,7 +28,7 @@ import io.metersphere.system.log.constants.OperationLogModule;
import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.log.service.OperationLogService;
import io.metersphere.system.service.JdbcDriverPluginService;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -101,7 +101,7 @@ public class EnvironmentService {
public EnvironmentRequest add(EnvironmentRequest request, String userId, List<MultipartFile> sslFiles) {
Environment environment = new Environment();
environment.setId(UUID.randomUUID().toString());
environment.setId(IDGenerator.nextStr());
environment.setCreateUser(userId);
environment.setName(request.getName());
environment.setProjectId(request.getProjectId());
@ -220,7 +220,7 @@ public class EnvironmentService {
Project project = projectMapper.selectByPrimaryKey(currentProjectId);
environmentRequests.forEach(environmentRequest -> {
Environment environment = new Environment();
environment.setId(UUID.randomUUID().toString());
environment.setId(IDGenerator.nextStr());
environment.setCreateUser(userId);
environment.setName(environmentRequest.getName());
environment.setProjectId(currentProjectId);

View File

@ -15,7 +15,7 @@ import io.metersphere.sdk.constants.StorageType;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.file.FileRequest;
import io.metersphere.sdk.util.*;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -82,7 +82,7 @@ public class FileMetadataService {
//检查处理后的用户名合法性
this.checkFileName(null, fileMetadata.getName(), request.getProjectId());
fileMetadata.setId(UUID.randomUUID().toString());
fileMetadata.setId(IDGenerator.nextStr());
fileMetadata.setStorage(StorageType.MINIO.name());
fileMetadata.setProjectId(request.getProjectId());
fileMetadata.setModuleId(request.getModuleId());
@ -139,7 +139,7 @@ public class FileMetadataService {
long operationTime = System.currentTimeMillis();
FileMetadata fileMetadata = new FileMetadata();
fileMetadata.setId(UUID.randomUUID().toString());
fileMetadata.setId(IDGenerator.nextStr());
fileMetadata.setStorage(oldFile.getStorage());
fileMetadata.setProjectId(oldFile.getProjectId());
fileMetadata.setModuleId(oldFile.getModuleId());

View File

@ -13,8 +13,7 @@ import io.metersphere.sdk.dto.request.NodeMoveRequest;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.service.CleanupProjectResourceService;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.utils.SessionUtils;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -72,7 +71,7 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje
public String add(FileModuleCreateRequest request, String operator) {
FileModule fileModule = new FileModule();
fileModule.setId(UUID.randomUUID().toString());
fileModule.setId(IDGenerator.nextStr());
fileModule.setName(request.getName());
fileModule.setParentId(request.getParentId());
fileModule.setProjectId(request.getProjectId());

View File

@ -10,7 +10,7 @@ import io.metersphere.sdk.mapper.ProjectParametersMapper;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import jakarta.transaction.Transactional;
import org.apache.commons.collections.CollectionUtils;
@ -33,7 +33,7 @@ public class GlobalParamsService {
projectParameters.setProjectId(globalParamsRequest.getProjectId());
checkExist(globalParamsRequest.getProjectId());
checkProjectExist(globalParamsRequest.getProjectId());
projectParameters.setId(UUID.randomUUID().toString());
projectParameters.setId(IDGenerator.nextStr());
projectParameters.setCreateUser(userId);
projectParameters.setUpdateUser(userId);
projectParameters.setCreateTime(System.currentTimeMillis());

View File

@ -21,7 +21,7 @@ import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.mapper.UserRoleRelationMapper;
import io.metersphere.system.notice.constants.NoticeConstants;
import io.metersphere.system.notice.utils.MessageTemplateUtils;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -216,7 +216,7 @@ public class NoticeMessageTaskService {
boolean useDefaultSubject = messageTaskRequest.getUseDefaultSubject() == null || messageTaskRequest.getUseDefaultSubject();
boolean useDefaultTemplate = messageTaskRequest.getUseDefaultTemplate() == null || messageTaskRequest.getUseDefaultTemplate();
String insertId = UUID.randomUUID().toString();
String insertId = IDGenerator.nextStr();
messageTask.setId(insertId);
messageTask.setTaskType(messageTaskRequest.getTaskType());
messageTask.setEvent(messageTaskRequest.getEvent());

View File

@ -25,7 +25,7 @@ import io.metersphere.system.log.service.OperationLogService;
import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.mapper.UserRoleMapper;
import io.metersphere.system.mapper.UserRoleRelationMapper;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -184,7 +184,7 @@ public class ProjectMemberService {
return;
}
UserRoleRelation relation = new UserRoleRelation();
relation.setId(UUID.randomUUID().toString());
relation.setId(IDGenerator.nextStr());
relation.setUserId(request.getUserId());
relation.setRoleId(roleId);
relation.setSourceId(request.getProjectId());
@ -278,7 +278,7 @@ public class ProjectMemberService {
return;
}
UserRoleRelation relation = new UserRoleRelation();
relation.setId(UUID.randomUUID().toString());
relation.setId(IDGenerator.nextStr());
relation.setUserId(userId);
relation.setRoleId(roleId);
relation.setSourceId(request.getProjectId());

View File

@ -10,7 +10,7 @@ import io.metersphere.project.mapper.ProjectRobotMapper;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -34,7 +34,7 @@ public class ProjectRobotService {
private MessageTaskBlobMapper messageTaskBlobMapper;
public void add(ProjectRobot projectRobot) {
projectRobot.setId(UUID.randomUUID().toString());
projectRobot.setId(IDGenerator.nextStr());
projectRobot.setEnable(projectRobot.getEnable());
checkDingTalk(projectRobot);
robotMapper.insert(projectRobot);

View File

@ -19,7 +19,7 @@ import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.mapper.UserRoleMapper;
import io.metersphere.system.mapper.UserRoleRelationMapper;
import io.metersphere.system.service.BaseUserRoleService;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
@ -108,7 +108,7 @@ public class ProjectUserRoleService extends BaseUserRoleService {
request.getUserIds().forEach(userId -> {
checkMemberParam(userId, request.getUserRoleId());
UserRoleRelation relation = new UserRoleRelation();
relation.setId(UUID.randomUUID().toString());
relation.setId(IDGenerator.nextStr());
relation.setUserId(userId);
relation.setRoleId(request.getUserRoleId());
relation.setSourceId(request.getProjectId());

View File

@ -14,7 +14,7 @@ import io.metersphere.sdk.util.JSON;
import io.metersphere.system.base.BaseTest;
import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.system.notice.constants.NoticeConstants;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -627,7 +627,7 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
continue;
}
for (OptionDTO receiver : receivers) {
String id = UUID.randomUUID().toString();
String id = IDGenerator.nextStr();
MessageTask messageTask = new MessageTask();
messageTask.setId(id);
messageTask.setEvent(event);

View File

@ -19,7 +19,7 @@ import io.metersphere.sdk.util.JSON;
import io.metersphere.system.base.BaseTest;
import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.system.notice.constants.NoticeConstants;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -541,7 +541,7 @@ public class ProjectRobotControllerTests extends BaseTest {
continue;
}
for (OptionDTO receiver : receivers) {
String id = UUID.randomUUID().toString();
String id = IDGenerator.nextStr();
MessageTask messageTask = new MessageTask();
messageTask.setId(id);
messageTask.setEvent(event);

View File

@ -19,7 +19,7 @@ import io.metersphere.sdk.util.Pager;
import io.metersphere.system.base.BaseTest;
import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
@ -67,7 +67,7 @@ public class FileManagementControllerTests extends BaseTest {
public void initTestData() {
if (project == null) {
Project initProject = new Project();
initProject.setId(UUID.randomUUID().toString());
initProject.setId(IDGenerator.nextStr());
initProject.setNum(null);
initProject.setOrganizationId("100001");
initProject.setName("建国创建的项目");
@ -264,7 +264,7 @@ public class FileManagementControllerTests extends BaseTest {
request = new FileModuleCreateRequest();
request.setProjectId(project.getId());
request.setName("ParentIsUUID");
request.setParentId(UUID.randomUUID().toString());
request.setParentId(IDGenerator.nextStr());
this.requestPost(FileManagementRequestUtils.URL_MODULE_ADD, request).andExpect(status().is5xxServerError());
//添加重复的a1节点
@ -282,7 +282,7 @@ public class FileManagementControllerTests extends BaseTest {
//子节点的项目ID和父节点的不匹配
request = new FileModuleCreateRequest();
request.setProjectId(UUID.randomUUID().toString());
request.setProjectId(IDGenerator.nextStr());
request.setName("RandomUUID");
request.setParentId(a1Node.getId());
this.requestPost(FileManagementRequestUtils.URL_MODULE_ADD, request).andExpect(status().is5xxServerError());
@ -333,8 +333,8 @@ public class FileManagementControllerTests extends BaseTest {
//id不存在
updateRequest = new FileModuleUpdateRequest();
updateRequest.setId(UUID.randomUUID().toString());
updateRequest.setName(UUID.randomUUID().toString());
updateRequest.setId(IDGenerator.nextStr());
updateRequest.setName(IDGenerator.nextStr());
this.requestPost(FileManagementRequestUtils.URL_MODULE_UPDATE, updateRequest).andExpect(status().is5xxServerError());
//名称重复 a1-a1改为a1-b1
@ -416,7 +416,7 @@ public class FileManagementControllerTests extends BaseTest {
this.requestMultipart(FileManagementRequestUtils.URL_FILE_UPLOAD, paramMap).andExpect(status().isBadRequest());
//模块不存在
fileUploadRequest.setModuleId(UUID.randomUUID().toString());
fileUploadRequest.setModuleId(IDGenerator.nextStr());
paramMap = new LinkedMultiValueMap<>();
paramMap.add("file", file);
paramMap.add("request", JSON.toJSONString(fileUploadRequest));
@ -486,7 +486,7 @@ public class FileManagementControllerTests extends BaseTest {
this.requestMultipart(FileManagementRequestUtils.URL_FILE_RE_UPLOAD, paramMap).andExpect(status().isBadRequest());
//旧文件不存在
fileReUploadRequest.setFileId(UUID.randomUUID().toString());
fileReUploadRequest.setFileId(IDGenerator.nextStr());
paramMap = new LinkedMultiValueMap<>();
paramMap.add("file", file);
paramMap.add("request", JSON.toJSONString(fileReUploadRequest));
@ -514,7 +514,7 @@ public class FileManagementControllerTests extends BaseTest {
@Order(16)
public void fileDownloadTestError() throws Exception {
//下载不存在的文件
mockMvc.perform(getRequestBuilder(FileManagementRequestUtils.URL_FILE_DOWNLOAD, UUID.randomUUID()))
mockMvc.perform(getRequestBuilder(FileManagementRequestUtils.URL_FILE_DOWNLOAD, IDGenerator.randomUUID()))
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(status().is5xxServerError());
}
@ -575,7 +575,7 @@ public class FileManagementControllerTests extends BaseTest {
this.setPageSize(10);
this.setProjectId(project.getId());
this.setModuleIds(new ArrayList<>() {{
this.add(UUID.randomUUID().toString());
this.add(IDGenerator.nextStr());
}});
}};
this.filePageRequestAndCheck(request, false);
@ -658,7 +658,7 @@ public class FileManagementControllerTests extends BaseTest {
batchProcessDTO.setSelectAll(false);
batchProcessDTO.setProjectId(project.getId());
batchProcessDTO.setSelectIds(new ArrayList<>() {{
this.add(UUID.randomUUID().toString());
this.add(IDGenerator.nextStr());
}});
mockMvc.perform(getPostRequestBuilder(FileManagementRequestUtils.URL_FILE_BATCH_DOWNLOAD, batchProcessDTO))
@ -694,7 +694,7 @@ public class FileManagementControllerTests extends BaseTest {
fileBatchProcessDTO.setSelectAll(true);
fileBatchProcessDTO.setProjectId(project.getId());
fileBatchProcessDTO.setExcludeIds(new ArrayList<>() {{
this.add(UUID.randomUUID().toString());
this.add(IDGenerator.nextStr());
}});
this.requestPostWithOk(FileManagementRequestUtils.URL_FILE_DELETE, fileBatchProcessDTO);
FileMetadataExample example = new FileMetadataExample();
@ -762,7 +762,7 @@ public class FileManagementControllerTests extends BaseTest {
this.requestPost(FileManagementRequestUtils.URL_FILE_UPDATE, updateRequest).andExpect(status().isBadRequest());
//文件不存在
updateRequest.setId(UUID.randomUUID().toString());
updateRequest.setId(IDGenerator.nextStr());
this.requestPost(FileManagementRequestUtils.URL_FILE_UPDATE, updateRequest).andExpect(status().is5xxServerError());
//模块不存在
@ -775,7 +775,7 @@ public class FileManagementControllerTests extends BaseTest {
break;
}
updateRequest.setId(updateFileId);
updateRequest.setModuleId(UUID.randomUUID().toString());
updateRequest.setModuleId(IDGenerator.nextStr());
this.requestPost(FileManagementRequestUtils.URL_FILE_UPDATE, updateRequest).andExpect(status().is5xxServerError());
}
@ -1042,7 +1042,7 @@ public class FileManagementControllerTests extends BaseTest {
checkLog(a1a1Node.getId(), OperationLogType.DELETE, FileManagementRequestUtils.URL_MODULE_DELETE);
//删除不存在的节点
this.requestGetWithOk(String.format(FileManagementRequestUtils.URL_MODULE_DELETE, UUID.randomUUID()));
this.requestGetWithOk(String.format(FileManagementRequestUtils.URL_MODULE_DELETE, IDGenerator.randomUUID()));
// 测试删除根节点
this.requestGetWithOk(String.format(FileManagementRequestUtils.URL_MODULE_DELETE, ModuleConstants.DEFAULT_NODE_ID));

View File

@ -14,7 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
@Transactional(rollbackFor = Exception.class)
public class ScheduleService {
@ -25,7 +25,7 @@ public class ScheduleService {
private ScheduleManager scheduleManager;
public void addSchedule(Schedule schedule) {
schedule.setId(UUID.randomUUID().toString());
schedule.setId(IDGenerator.nextStr());
schedule.setCreateTime(System.currentTimeMillis());
schedule.setUpdateTime(System.currentTimeMillis());
scheduleMapper.insert(schedule);

View File

@ -2,7 +2,7 @@ package io.metersphere.system.service;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.AuthSource;
@ -46,7 +46,7 @@ public class AuthSourceService {
source.setType(authSource.getType());
source.setCreateTime(createTime);
source.setUpdateTime(createTime);
source.setId(UUID.randomUUID().toString());
source.setId(IDGenerator.nextStr());
return source;
}

View File

@ -13,7 +13,7 @@ import io.metersphere.system.domain.CustomField;
import io.metersphere.system.domain.CustomFieldExample;
import io.metersphere.system.domain.CustomFieldOption;
import io.metersphere.system.mapper.CustomFieldMapper;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.system.utils.ServiceUtils;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
@ -124,7 +124,7 @@ public class BaseCustomFieldService {
*/
public CustomField baseAdd(CustomField customField, List<CustomFieldOption> options) {
checkAddExist(customField);
customField.setId(UUID.randomUUID().toString());
customField.setId(IDGenerator.nextStr());
customField.setCreateTime(System.currentTimeMillis());
customField.setUpdateTime(System.currentTimeMillis());
customFieldMapper.insert(customField);
@ -247,7 +247,7 @@ public class BaseCustomFieldService {
}
public CustomField initDefaultCustomField(CustomField customField) {
customField.setId(UUID.randomUUID().toString());
customField.setId(IDGenerator.nextStr());
customField.setInternal(true);
customField.setCreateTime(System.currentTimeMillis());
customField.setUpdateTime(System.currentTimeMillis());

View File

@ -5,7 +5,7 @@ import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.system.domain.StatusFlow;
import io.metersphere.system.domain.StatusFlowExample;
import io.metersphere.system.mapper.StatusFlowMapper;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
@ -48,7 +48,7 @@ public class BaseStatusFlowService {
List<StatusFlow> statusFlows = statusFlowRequests.stream().map(request -> {
StatusFlow statusFlow = new StatusFlow();
BeanUtils.copyBean(statusFlow, request);
statusFlow.setId(UUID.nextStr());
statusFlow.setId(IDGenerator.nextStr());
return statusFlow;
}).toList();
statusFlowMapper.batchInsert(statusFlows);
@ -91,7 +91,7 @@ public class BaseStatusFlowService {
return;
}
statusFlows.forEach(statusFlow -> {
statusFlow.setId(UUID.nextStr());
statusFlow.setId(IDGenerator.nextStr());
});
statusFlowMapper.batchInsert(statusFlows);
}

View File

@ -13,7 +13,7 @@ import io.metersphere.system.domain.StatusFlow;
import io.metersphere.system.domain.StatusItem;
import io.metersphere.system.dto.StatusFlowSettingDTO;
import io.metersphere.system.mapper.StatusDefinitionMapper;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
@ -169,7 +169,7 @@ public class BaseStatusFlowSettingService {
List<String> statusFlowTargets = defaultBugStatusItem.getStatusFlowTargets();
for (String statusFlowTarget : statusFlowTargets) {
StatusFlow statusFlow = new StatusFlow();
statusFlow.setId(UUID.randomUUID().toString());
statusFlow.setId(IDGenerator.nextStr());
statusFlow.setFromId(fromStatusId);
statusFlow.setToId(statusNameMap.get(statusFlowTarget));
statusFlows.add(statusFlow);

View File

@ -6,7 +6,7 @@ import io.metersphere.system.domain.StatusItem;
import io.metersphere.system.domain.StatusItemExample;
import io.metersphere.system.mapper.ExtStatusItemMapper;
import io.metersphere.system.mapper.StatusItemMapper;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.system.utils.ServiceUtils;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
@ -77,7 +77,7 @@ public class BaseStatusItemService {
}
public StatusItem baseAdd(StatusItem statusItem) {
statusItem.setId(UUID.nextStr());
statusItem.setId(IDGenerator.nextStr());
statusItemMapper.insert(statusItem);
return statusItem;
}
@ -92,7 +92,7 @@ public class BaseStatusItemService {
if (CollectionUtils.isEmpty(statusItems)) {
return List.of();
}
statusItems.forEach(statusItem -> statusItem.setId(UUID.nextStr()));
statusItems.forEach(statusItem -> statusItem.setId(IDGenerator.nextStr()));
statusItemMapper.batchInsert(statusItems);
return statusItems;
}

View File

@ -14,7 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@ -52,7 +52,7 @@ public class BaseTemplateCustomFieldService {
AtomicReference<Integer> pos = new AtomicReference<>(0);
List<TemplateCustomField> templateCustomFields = customFieldRequests.stream().map(field -> {
TemplateCustomField templateCustomField = new TemplateCustomField();
templateCustomField.setId(UUID.randomUUID().toString());
templateCustomField.setId(IDGenerator.nextStr());
BeanUtils.copyBean(templateCustomField, field);
templateCustomField.setTemplateId(id);
templateCustomField.setPos(pos.getAndSet(pos.get() + 1));

View File

@ -23,7 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import java.util.stream.Collectors;
import static io.metersphere.system.controller.handler.result.CommonResultCode.*;
@ -118,7 +118,7 @@ public class BaseTemplateService {
public Template baseAdd(Template template, List<TemplateCustomFieldRequest> customFields) {
checkAddExist(template);
template.setId(UUID.randomUUID().toString());
template.setId(IDGenerator.nextStr());
template.setCreateTime(System.currentTimeMillis());
template.setUpdateTime(System.currentTimeMillis());
templateMapper.insert(template);
@ -320,7 +320,7 @@ public class BaseTemplateService {
public Template initDefaultTemplate(String scopeId, String name, TemplateScopeType scopeType, TemplateScene scene) {
Template template = new Template();
template.setId(UUID.randomUUID().toString());
template.setId(IDGenerator.nextStr());
template.setName(name);
template.setInternal(true);
template.setUpdateTime(System.currentTimeMillis());

View File

@ -10,7 +10,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Set;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import java.util.stream.Collectors;
/**
@ -68,7 +68,7 @@ public class BaseUserRolePermissionService {
if (BooleanUtils.isTrue(permission.getEnable())) {
String permissionId = permission.getId();
UserRolePermission groupPermission = new UserRolePermission();
groupPermission.setId(UUID.randomUUID().toString());
groupPermission.setId(IDGenerator.nextStr());
groupPermission.setRoleId(groupId);
groupPermission.setPermissionId(permissionId);
userRolePermissionMapper.insert(groupPermission);

View File

@ -14,7 +14,7 @@ import io.metersphere.system.domain.UserRoleExample;
import io.metersphere.system.domain.UserRoleRelation;
import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.mapper.UserRoleMapper;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.system.utils.ServiceUtils;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
@ -133,7 +133,7 @@ public class BaseUserRoleService {
}
protected UserRole add(UserRole userRole) {
userRole.setId(UUID.randomUUID().toString());
userRole.setId(IDGenerator.nextStr());
userRole.setCreateTime(System.currentTimeMillis());
userRole.setUpdateTime(System.currentTimeMillis());
userRoleMapper.insert(userRole);
@ -243,7 +243,7 @@ public class BaseUserRoleService {
// 如果当前用户组只有一个用户并且就是要删除的用户组则添加组织成员等默认用户组
if (relations.size() == 1 && StringUtils.equals(relations.get(0).getRoleId(), roleId)) {
UserRoleRelation relation = new UserRoleRelation();
relation.setId(UUID.randomUUID().toString());
relation.setId(IDGenerator.nextStr());
relation.setUserId(relations.get(0).getUserId());
relation.setSourceId(relations.get(0).getSourceId());
relation.setRoleId(defaultRoleId);

View File

@ -26,7 +26,7 @@ import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.log.service.OperationLogService;
import io.metersphere.system.mapper.*;
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -103,7 +103,7 @@ public class CommonProjectService {
Project project = new Project();
ProjectDTO projectDTO = new ProjectDTO();
project.setId(UUID.randomUUID().toString());
project.setId(IDGenerator.nextStr());
project.setName(addProjectDTO.getName());
project.setOrganizationId(addProjectDTO.getOrganizationId());
checkProjectExistByName(project);
@ -168,7 +168,7 @@ public class CommonProjectService {
userId.forEach(id -> {
if (!orgUserIds.contains(id)) {
UserRoleRelation memberRole = new UserRoleRelation();
memberRole.setId(UUID.randomUUID().toString());
memberRole.setId(IDGenerator.nextStr());
memberRole.setUserId(id);
memberRole.setRoleId(InternalUserRole.ORG_MEMBER.getValue());
memberRole.setSourceId(orgId);
@ -396,7 +396,7 @@ public class CommonProjectService {
.andSourceIdEqualTo(projectId).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
if (userRoleRelationMapper.selectByExample(userRoleRelationExample).size() == 0) {
UserRoleRelation adminRole = new UserRoleRelation();
adminRole.setId(UUID.randomUUID().toString());
adminRole.setId(IDGenerator.nextStr());
adminRole.setUserId(userId);
adminRole.setRoleId(InternalUserRole.PROJECT_ADMIN.getValue());
adminRole.setSourceId(projectId);
@ -452,7 +452,7 @@ public class CommonProjectService {
.andSourceIdEqualTo(projectId);
if (userRoleRelationMapper.selectByExample(userRoleRelationExample).size() == 0) {
UserRoleRelation memberRole = new UserRoleRelation();
memberRole.setId(UUID.randomUUID().toString());
memberRole.setId(IDGenerator.nextStr());
memberRole.setUserId(userId);
memberRole.setRoleId(InternalUserRole.PROJECT_MEMBER.getValue());
memberRole.setSourceId(projectId);

View File

@ -6,7 +6,7 @@ import io.metersphere.sdk.dto.UserExcludeOptionDTO;
import io.metersphere.sdk.dto.UserRoleRelationUserDTO;
import io.metersphere.sdk.dto.request.GlobalUserRoleRelationUpdateRequest;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.UserRole;
@ -80,7 +80,7 @@ public class GlobalUserRoleRelationService extends BaseUserRoleRelationService {
userRoleRelation.setSourceId(UserRoleScope.SYSTEM);
checkExist(userRoleRelation);
userRoleRelation.setCreateTime(System.currentTimeMillis());
userRoleRelation.setId(UUID.randomUUID().toString());
userRoleRelation.setId(IDGenerator.nextStr());
userRoleRelation.setOrganizationId(UserRoleScope.SYSTEM);
userRoleRelations.add(userRoleRelation);
});
@ -118,7 +118,7 @@ public class GlobalUserRoleRelationService extends BaseUserRoleRelationService {
userRoleRelation.setCreateUser(operator);
userRoleRelation.setCreateTime(createTime);
userRoleRelation.setSourceId(UserRoleScope.SYSTEM);
userRoleRelation.setId(UUID.randomUUID().toString());
userRoleRelation.setId(IDGenerator.nextStr());
userRoleRelation.setOrganizationId(UserRoleScope.SYSTEM);
saveList.add(userRoleRelation);
}

View File

@ -19,7 +19,7 @@ import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.log.service.OperationLogService;
import io.metersphere.system.mapper.*;
import io.metersphere.system.request.*;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.system.utils.ServiceUtils;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
@ -195,7 +195,7 @@ public class OrganizationService {
continue;
}
UserRoleRelation userRoleRelation = new UserRoleRelation();
userRoleRelation.setId(UUID.randomUUID().toString());
userRoleRelation.setId(IDGenerator.nextStr());
userRoleRelation.setUserId(userId);
userRoleRelation.setSourceId(organizationId);
userRoleRelation.setRoleId(InternalUserRole.ORG_MEMBER.getValue());
@ -616,7 +616,7 @@ public class OrganizationService {
private UserRoleRelation buildUserRoleRelation(String createUserId, String memberId, String sourceId, String roleId, String organizationId) {
UserRoleRelation userRoleRelation = new UserRoleRelation();
userRoleRelation.setId(UUID.randomUUID().toString());
userRoleRelation.setId(IDGenerator.nextStr());
userRoleRelation.setUserId(memberId);
userRoleRelation.setOrganizationId(organizationId);
userRoleRelation.setSourceId(sourceId);

View File

@ -11,7 +11,7 @@ import io.metersphere.system.domain.*;
import io.metersphere.system.mapper.*;
import io.metersphere.system.request.OrganizationUserRoleMemberEditRequest;
import io.metersphere.system.request.OrganizationUserRoleMemberRequest;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -83,7 +83,7 @@ public class OrganizationUserRoleService extends BaseUserRoleService {
request.getUserIds().forEach(userId -> {
checkMemberParam(userId, request.getUserRoleId());
UserRoleRelation relation = new UserRoleRelation();
relation.setId(UUID.randomUUID().toString());
relation.setId(IDGenerator.nextStr());
relation.setUserId(userId);
relation.setRoleId(request.getUserRoleId());
relation.setSourceId(request.getOrganizationId());

View File

@ -2,7 +2,7 @@ package io.metersphere.system.service;
import io.metersphere.sdk.dto.OptionDTO;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.domain.PluginScript;
import io.metersphere.system.domain.PluginScriptExample;
@ -46,7 +46,7 @@ public class PluginScriptService {
ids.add(scriptInfo.getId());
pluginScript.setPluginId(pluginId);
pluginScript.setScriptId(
StringUtils.isBlank(scriptInfo.getId()) ? UUID.randomUUID().toString() : scriptInfo.getId()
StringUtils.isBlank(scriptInfo.getId()) ? IDGenerator.nextStr() : scriptInfo.getId()
);
pluginScript.setName(scriptInfo.getName());
pluginScript.setScript(script.getBytes());

View File

@ -3,7 +3,7 @@ package io.metersphere.system.service;
import io.metersphere.plugin.platform.spi.AbstractPlatformPlugin;
import io.metersphere.plugin.platform.spi.Platform;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.utils.ServiceUtils;
@ -84,7 +84,7 @@ public class ServiceIntegrationService {
basePluginService.checkPluginEnableAndPermission(request.getPluginId(), request.getOrganizationId());
ServiceIntegration serviceIntegration = new ServiceIntegration();
BeanUtils.copyBean(serviceIntegration, request);
serviceIntegration.setId(UUID.randomUUID().toString());
serviceIntegration.setId(IDGenerator.nextStr());
serviceIntegration.setConfiguration(JSON.toJSONBytes(request.getConfiguration()));
checkAddExist(serviceIntegration);
serviceIntegrationMapper.insert(serviceIntegration);

View File

@ -18,7 +18,7 @@ import io.metersphere.system.mapper.OrganizationMapper;
import io.metersphere.system.mapper.TestResourcePoolBlobMapper;
import io.metersphere.system.mapper.TestResourcePoolMapper;
import io.metersphere.system.mapper.TestResourcePoolOrganizationMapper;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -51,7 +51,7 @@ public class TestResourcePoolService {
public TestResourcePool addTestResourcePool(TestResourcePoolDTO testResourcePool) {
String id = UUID.randomUUID().toString();
String id = IDGenerator.nextStr();
checkTestResourcePool(testResourcePool);
@ -92,7 +92,7 @@ public class TestResourcePoolService {
testResourcePool.setAllOrg(false);
testResourceDTO.getOrgIds().forEach(orgId -> {
TestResourcePoolOrganization testResourcePoolOrganization = new TestResourcePoolOrganization();
testResourcePoolOrganization.setId(UUID.randomUUID().toString());
testResourcePoolOrganization.setId(IDGenerator.nextStr());
testResourcePoolOrganization.setOrgId(orgId);
testResourcePoolOrganization.setTestResourcePoolId(id);
poolOrganizationMapper.insert(testResourcePoolOrganization);

View File

@ -1,6 +1,6 @@
package io.metersphere.system.service;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.UserInvite;
@ -37,7 +37,7 @@ public class UserInviteService {
userInvite.setRoles(JSON.toJSONString(userRoleIds));
userInvite.setInviteUser(inviteUser);
userInvite.setInviteTime(inviteTime);
userInvite.setId(UUID.randomUUID().toString());
userInvite.setId(IDGenerator.nextStr());
inviteList.add(userInvite);
}
userInviteMapper.batchInsert(inviteList);

View File

@ -13,7 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
@Service
@Transactional(rollbackFor = Exception.class)
@ -45,7 +45,7 @@ public class UserKeyService {
}
UserKey userKeys = new UserKey();
userKeys.setId(UUID.randomUUID().toString());
userKeys.setId(IDGenerator.nextStr());
userKeys.setCreateUser(userId);
userKeys.setEnable(true);
userKeys.setAccessKey(RandomStringUtils.randomAlphanumeric(16));

View File

@ -7,7 +7,7 @@ import io.metersphere.sdk.dto.LogDTO;
import io.metersphere.system.log.constants.OperationLogModule;
import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.log.service.OperationLogService;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.domain.*;
import io.metersphere.system.mapper.ExtUserRoleRelationMapper;
@ -87,7 +87,7 @@ public class UserRoleRelationService {
for (String userRoleId : userRoleIdList) {
for (User user : userList) {
UserRoleRelation userRoleRelation = new UserRoleRelation();
userRoleRelation.setId(UUID.randomUUID().toString());
userRoleRelation.setId(IDGenerator.nextStr());
userRoleRelation.setUserId(user.getId());
userRoleRelation.setRoleId(userRoleId);
userRoleRelation.setSourceId(UserRoleScope.SYSTEM);
@ -117,7 +117,7 @@ public class UserRoleRelationService {
//添加用户组织关系
for (String userRoleId : userRoleIdList) {
UserRoleRelation userRoleRelation = new UserRoleRelation();
userRoleRelation.setId(UUID.randomUUID().toString());
userRoleRelation.setId(IDGenerator.nextStr());
userRoleRelation.setUserId(user.getId());
userRoleRelation.setRoleId(userRoleId);
userRoleRelation.setSourceId(UserRoleScope.SYSTEM);
@ -187,7 +187,7 @@ public class UserRoleRelationService {
for (String roleId : roleList) {
if (!userSavedRoleIdList.contains(roleId)) {
UserRoleRelation userRoleRelation = new UserRoleRelation();
userRoleRelation.setId(UUID.randomUUID().toString());
userRoleRelation.setId(IDGenerator.nextStr());
userRoleRelation.setUserId(user.getId());
userRoleRelation.setRoleId(roleId);
userRoleRelation.setSourceId(UserRoleScope.SYSTEM);

View File

@ -25,7 +25,7 @@ import io.metersphere.system.request.user.UserChangeEnableRequest;
import io.metersphere.system.request.user.UserEditRequest;
import io.metersphere.system.response.user.UserImportResponse;
import io.metersphere.system.response.user.UserTableResponse;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.system.utils.UserImportEventListener;
import jakarta.annotation.Resource;
import jakarta.mail.internet.InternetAddress;
@ -114,7 +114,7 @@ public class UserService {
List<User> saveUserList = new ArrayList<>();
//添加用户
for (UserCreateInfo userInfo : userCreateDTO.getUserInfoList()) {
userInfo.setId(UUID.randomUUID().toString());
userInfo.setId(IDGenerator.nextStr());
User user = new User();
BeanUtils.copyBean(user, userInfo);
user.setCreateUser(operator);
@ -471,7 +471,7 @@ public class UserService {
//创建用户
long createTime = System.currentTimeMillis();
User user = new User();
user.setId(UUID.randomUUID().toString());
user.setId(IDGenerator.nextStr());
user.setEmail(userInvite.getEmail());
user.setPassword(CodingUtils.md5(RsaUtils.privateDecrypt(request.getPassword(), RsaUtils.getRsaKey().getPrivateKey())));
user.setName(request.getName());

View File

@ -3,7 +3,7 @@ package io.metersphere.system.uid;
import io.metersphere.system.uid.impl.CachedUidGenerator;
import io.metersphere.sdk.util.CommonBeanFactory;
public class UUID {
public class IDGenerator {
private static final CachedUidGenerator DEFAULT_UID_GENERATOR;
static {

View File

@ -17,7 +17,7 @@ import io.metersphere.system.domain.UserRolePermissionExample;
import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.mapper.UserRolePermissionMapper;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.validation.groups.Created;
import io.metersphere.validation.groups.Updated;
import jakarta.annotation.Resource;
@ -513,7 +513,7 @@ public abstract class BaseTest {
private UserRolePermission initUserRolePermission(String roleId, String permissionId) {
UserRolePermission userRolePermission = new UserRolePermission();
userRolePermission.setRoleId(roleId);
userRolePermission.setId(UUID.randomUUID().toString());
userRolePermission.setId(IDGenerator.nextStr());
userRolePermission.setPermissionId(permissionId);
userRolePermissionMapper.insert(userRolePermission);
return userRolePermission;

View File

@ -9,7 +9,7 @@ import io.metersphere.sdk.dto.request.UserRoleUpdateRequest;
import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.service.BaseUserRolePermissionService;
import io.metersphere.system.service.BaseUserRoleRelationService;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.system.utils.SessionUtils;
import io.metersphere.system.controller.param.PermissionSettingUpdateRequestDefinition;
@ -349,7 +349,7 @@ class GlobalUserRoleControllerTests extends BaseTest {
UserRole nonGlobalUserRole = userRoleMapper.selectByPrimaryKey(ADMIN.getValue());
nonGlobalUserRole.setName("非全局用户组");
nonGlobalUserRole.setScopeId("not global");
nonGlobalUserRole.setId(UUID.randomUUID().toString());
nonGlobalUserRole.setId(IDGenerator.nextStr());
userRoleMapper.insert(nonGlobalUserRole);
return nonGlobalUserRole;
}
@ -361,7 +361,7 @@ class GlobalUserRoleControllerTests extends BaseTest {
private UserRoleRelation prepareOneLimitTest(String userRoleId) {
// 插入一条用户数据
User user = new User();
user.setId(UUID.randomUUID().toString());
user.setId(IDGenerator.nextStr());
user.setCreateUser(SessionUtils.getUserId());
user.setName("test one user role");
user.setSource(UserSource.LOCAL.name());
@ -374,7 +374,7 @@ class GlobalUserRoleControllerTests extends BaseTest {
user.setDeleted(false);
userMapper.insert(user);
UserRoleRelation roleRelation = new UserRoleRelation();
roleRelation.setId(UUID.randomUUID().toString());
roleRelation.setId(IDGenerator.nextStr());
roleRelation.setCreateTime(System.currentTimeMillis());
roleRelation.setRoleId(userRoleId);
roleRelation.setCreateUser(ADMIN.getValue());

View File

@ -31,7 +31,7 @@ import org.springframework.test.web.servlet.MvcResult;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import java.util.stream.Collectors;
import static io.metersphere.sdk.constants.InternalUserRole.ADMIN;
@ -234,12 +234,12 @@ class GlobalUserRoleRelationControllerTests extends BaseTest {
private UserRoleRelation getNonGlobalUserRoleRelation() {
UserRole nonGlobalUserRole = getNonGlobalUserRole();
UserRoleRelation userRoleRelation = new UserRoleRelation();
userRoleRelation.setId(UUID.randomUUID().toString());
userRoleRelation.setId(IDGenerator.nextStr());
userRoleRelation.setRoleId(nonGlobalUserRole.getId());
userRoleRelation.setCreateUser(ADMIN.getValue());
userRoleRelation.setUserId(ADMIN.getValue());
userRoleRelation.setCreateTime(System.currentTimeMillis());
userRoleRelation.setSourceId(UUID.randomUUID().toString());
userRoleRelation.setSourceId(IDGenerator.nextStr());
userRoleRelation.setOrganizationId(UserRoleScope.SYSTEM);
userRoleRelationMapper.insert(userRoleRelation);
return userRoleRelation;
@ -250,12 +250,12 @@ class GlobalUserRoleRelationControllerTests extends BaseTest {
*/
private UserRoleRelation getNonSystemUserRoleRelation() {
UserRoleRelation userRoleRelation = new UserRoleRelation();
userRoleRelation.setId(UUID.randomUUID().toString());
userRoleRelation.setId(IDGenerator.nextStr());
userRoleRelation.setRoleId(ORG_ADMIN.getValue());
userRoleRelation.setUserId(ADMIN.getValue());
userRoleRelation.setCreateUser(ADMIN.getValue());
userRoleRelation.setCreateTime(System.currentTimeMillis());
userRoleRelation.setSourceId(UUID.randomUUID().toString());
userRoleRelation.setSourceId(IDGenerator.nextStr());
userRoleRelation.setOrganizationId(UserRoleScope.SYSTEM);
userRoleRelationMapper.insert(userRoleRelation);
return userRoleRelation;
@ -269,7 +269,7 @@ class GlobalUserRoleRelationControllerTests extends BaseTest {
UserRole nonGlobalUserRole = userRoleMapper.selectByPrimaryKey(ADMIN.getValue());
nonGlobalUserRole.setName("非全局用户组");
nonGlobalUserRole.setScopeId("not global");
nonGlobalUserRole.setId(UUID.randomUUID().toString());
nonGlobalUserRole.setId(IDGenerator.nextStr());
userRoleMapper.insert(nonGlobalUserRole);
return nonGlobalUserRole;
}
@ -282,7 +282,7 @@ class GlobalUserRoleRelationControllerTests extends BaseTest {
UserRole nonInternalRole = userRoleMapper.selectByPrimaryKey(ADMIN.getValue());
nonInternalRole.setName("非内置用户组");
nonInternalRole.setInternal(false);
nonInternalRole.setId(UUID.randomUUID().toString());
nonInternalRole.setId(IDGenerator.nextStr());
userRoleMapper.insert(nonInternalRole);
return nonInternalRole;
}

View File

@ -8,7 +8,7 @@ import io.metersphere.system.dto.ProjectDTO;
import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.mapper.UserRoleRelationMapper;
import io.metersphere.system.service.SystemProjectService;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
@ -107,7 +107,7 @@ public class LoginControllerTests extends BaseTest {
userRoleRelation.setRoleId("org-member");
userRoleRelation.setCreateUser("test.login");
userRoleRelation.setCreateTime(System.currentTimeMillis());
userRoleRelation.setId(UUID.randomUUID().toString());
userRoleRelation.setId(IDGenerator.nextStr());
userRoleRelationMapper.insert(userRoleRelation);
mockMvc.perform(MockMvcRequestBuilders.post(login)
.content(String.format("{\"username\":\"%s\",\"password\":\"%s\"}", "test.login", "test.login@163.com"))
@ -134,7 +134,7 @@ public class LoginControllerTests extends BaseTest {
userRoleRelation.setRoleId("org-member");
userRoleRelation.setCreateUser("test.login");
userRoleRelation.setCreateTime(System.currentTimeMillis());
userRoleRelation.setId(UUID.randomUUID().toString());
userRoleRelation.setId(IDGenerator.nextStr());
userRoleRelationMapper.insert(userRoleRelation);
user.setLastOrganizationId(DEFAULT_ORGANIZATION_ID);
user.setLastProjectId(null);

View File

@ -29,7 +29,7 @@ import io.metersphere.system.response.user.UserTableResponse;
import io.metersphere.system.service.GlobalUserRoleRelationService;
import io.metersphere.system.service.UserService;
import io.metersphere.system.service.UserToolService;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import io.metersphere.system.utils.user.UserParamUtils;
import io.metersphere.system.utils.user.UserRequestUtils;
import jakarta.annotation.Resource;
@ -199,7 +199,7 @@ public class UserControllerTests extends BaseTest {
public void testGetByEmailError() throws Exception {
//测试使用任意参数不能获取到任何用户信息
this.checkUserList();
String url = UserRequestUtils.URL_USER_GET + UUID.randomUUID();
String url = UserRequestUtils.URL_USER_GET + IDGenerator.randomUUID();
MvcResult mvcResult = userRequestUtils.responseGet(url);
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
@ -278,7 +278,7 @@ public class UserControllerTests extends BaseTest {
//查找不存在的用户
basePageRequest = UserParamUtils.getDefaultPageRequest();
basePageRequest.setKeyword(UUID.randomUUID().toString());
basePageRequest.setKeyword(IDGenerator.nextStr());
returnPager = userRequestUtils.selectUserPage(basePageRequest);
//返回值不为空
Assertions.assertNotNull(returnPager);
@ -1196,7 +1196,7 @@ public class UserControllerTests extends BaseTest {
//400-用户名为空
UserRegisterRequest request = new UserRegisterRequest();
request.setInviteId(inviteId);
request.setPassword(UUID.randomUUID().toString());
request.setPassword(IDGenerator.nextStr());
userRequestUtils.requestPost(UserRequestUtils.URL_INVITE_REGISTER, request, BAD_REQUEST_MATCHER);
request.setName("");
userRequestUtils.requestPost(UserRequestUtils.URL_INVITE_REGISTER, request, BAD_REQUEST_MATCHER);
@ -1211,16 +1211,16 @@ public class UserControllerTests extends BaseTest {
//400-邀请ID为空
request = new UserRegisterRequest();
request.setName("建国通过邮箱邀请2");
request.setPassword(UUID.randomUUID().toString());
request.setPassword(IDGenerator.nextStr());
userRequestUtils.requestPost(UserRequestUtils.URL_INVITE_REGISTER, request, BAD_REQUEST_MATCHER);
request.setInviteId("");
userRequestUtils.requestPost(UserRequestUtils.URL_INVITE_REGISTER, request, BAD_REQUEST_MATCHER);
//500-邀请ID不存在
request = new UserRegisterRequest();
request.setInviteId(UUID.randomUUID().toString());
request.setInviteId(IDGenerator.nextStr());
request.setName("建国通过邮箱邀请2");
request.setPassword(UUID.randomUUID().toString());
request.setPassword(IDGenerator.nextStr());
userRequestUtils.requestPost(UserRequestUtils.URL_INVITE_REGISTER, request, ERROR_REQUEST_MATCHER);
//500-邀请ID已过期且暂未删除
@ -1231,7 +1231,7 @@ public class UserControllerTests extends BaseTest {
request = new UserRegisterRequest();
request.setInviteId(inviteId);
request.setName("建国通过邮箱邀请2");
request.setPassword(UUID.randomUUID().toString());
request.setPassword(IDGenerator.nextStr());
userRequestUtils.requestPost(UserRequestUtils.URL_INVITE_REGISTER, request, ERROR_REQUEST_MATCHER);
//500-用户邮箱在用户注册之前已经被注册过了
@ -1256,7 +1256,7 @@ public class UserControllerTests extends BaseTest {
request = new UserRegisterRequest();
request.setInviteId(inviteId);
request.setName("建国通过邮箱邀请2");
request.setPassword(UUID.randomUUID().toString());
request.setPassword(IDGenerator.nextStr());
userRequestUtils.requestPost(UserRequestUtils.URL_INVITE_REGISTER, request, ERROR_REQUEST_MATCHER);
}
}

View File

@ -7,9 +7,7 @@ import io.metersphere.plan.mapper.TestPlanConfigMapper;
import io.metersphere.plan.mapper.TestPlanMapper;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.system.utils.SessionUtils;
import io.metersphere.system.domain.User;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
@ -55,7 +53,7 @@ public class TestPlanService {
}
if (StringUtils.isBlank(testPlanCreateRequest.getId())) {
testPlanCreateRequest.setId(UUID.randomUUID().toString());
testPlanCreateRequest.setId(IDGenerator.nextStr());
}
testPlanCreateRequest.setCreateTime(System.currentTimeMillis());
testPlanCreateRequest.setUpdateTime(System.currentTimeMillis());

View File

@ -6,7 +6,7 @@ import io.metersphere.plan.dto.TestPlanDTO;
import io.metersphere.sdk.constants.SessionConstants;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.system.uid.UUID;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.*;
@ -37,7 +37,7 @@ public class TestPlanControllerTests {
static List<TestPlanDTO> SAVED_TEST_PLAN_DTO_LIST = new ArrayList<>();
static final String STATIC_UUID = UUID.randomUUID().toString();
static final String STATIC_UUID = IDGenerator.nextStr();
private TestPlanDTO getSimpleTestPlan() {
TestPlanDTO testPlan = new TestPlanDTO();
@ -267,7 +267,7 @@ public class TestPlanControllerTests {
//测试parentId和id相同
testPlan = this.getSimpleTestPlan();
testPlan.setId(UUID.randomUUID().toString());
testPlan.setId(IDGenerator.nextStr());
testPlan.setParentId(testPlan.getId());
mockMvc.perform(MockMvcRequestBuilders.post("/test-plan/add")
.header(SessionConstants.HEADER_TOKEN, sessionId)

View File

@ -82,7 +82,7 @@
<frontend-maven-plugin.version>1.12.1</frontend-maven-plugin.version>
<node.version>v16.20.0</node.version>
<npm.version>8.19.4</npm.version>
<pnpm.version>8.6.12</pnpm.version>
<pnpm.version>8.9.2</pnpm.version>
<!-- -->
<skipAntRunForJenkins>false</skipAntRunForJenkins>
<commons-dbcp2-version>2.9.0</commons-dbcp2-version>