diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java index b5b2413955..21dfb2fd99 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java @@ -550,8 +550,8 @@ public class FileMetadataService { fileMetadata.setProjectId(oldFile.getProjectId()); fileMetadata.setModuleId(oldFile.getModuleId()); fileMetadata.setName(oldFile.getName()); - fileMetadata.setCreateTime(oldFile.getCreateTime()); - fileMetadata.setCreateUser(oldFile.getCreateUser()); + fileMetadata.setCreateTime(operationTime); + fileMetadata.setCreateUser(operator); fileMetadata.setUpdateTime(operationTime); fileMetadata.setPath(oldFile.getPath()); fileMetadata.setUpdateUser(operator); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/UserRegisterRequest.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/UserRegisterRequest.java index d121899f73..902ed6fafe 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/UserRegisterRequest.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/UserRegisterRequest.java @@ -2,6 +2,7 @@ package io.metersphere.system.dto.request; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; import lombok.Data; @Data @@ -12,6 +13,7 @@ public class UserRegisterRequest { @NotBlank @Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED) + @Size(min = 1, max = 255, message = "{user.name.length_range}") private String name; @NotBlank diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLogService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLogService.java index 85db51cf22..1dde9ba892 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLogService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLogService.java @@ -319,7 +319,7 @@ public class UserLogService { LogDTO log = LogDTOBuilder.builder() .projectId(OperationLogConstants.SYSTEM) .module(OperationLogModule.SETTING_SYSTEM_USER_SINGLE) - .createUser(user.getName()) + .createUser(user.getId()) .organizationId(OperationLogConstants.SYSTEM) .sourceId(user.getId()) .type(OperationLogType.ADD.name()) diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/user/UserControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/user/UserControllerTests.java index 751d33727c..b313b4f78f 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/user/UserControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/user/UserControllerTests.java @@ -1351,8 +1351,18 @@ public class UserControllerTests extends BaseTest { String inviteId = INVITE_RECORD_ID_LIST.getFirst(); UserRegisterRequest request = new UserRegisterRequest(); request.setInviteId(inviteId); - request.setName("建国通过邮箱邀请"); request.setPassword(RsaUtils.publicEncrypt("Cao..12138", RsaUtils.getRsaKey().getPublicKey())); + + //先测试反例:名称超过255 + StringBuilder overSizeName = new StringBuilder(); + while (overSizeName.length() < 256) { + overSizeName.append("i"); + } + request.setName(overSizeName.toString()); + this.requestPost(UserRequestUtils.URL_INVITE_REGISTER, request).andExpect(BAD_REQUEST_MATCHER); + + //测试正常创建 + request.setName("建国通过邮箱邀请"); MvcResult mvcResult = userRequestUtils.responsePost(UserRequestUtils.URL_INVITE_REGISTER, request); String resultHolderStr = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); ResultHolder resultHolder = JSON.parseObject(resultHolderStr, ResultHolder.class); @@ -1361,6 +1371,8 @@ public class UserControllerTests extends BaseTest { LOG_CHECK_LIST.add( new CheckLogModel(resultHolder.getData().toString(), OperationLogType.ADD, UserRequestUtils.URL_INVITE_REGISTER) ); + + } private void testUserRegisterError() throws Exception {