From 567a626998841818926d578b6087535fa22fb862 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 31 Jan 2024 20:43:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=B3=BB=E7=BB=9F=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=AF=BC=E5=85=A5=E6=A8=A1=E6=9D=BF=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=AD=E6=96=87=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/sdk/util/FilterChainUtils.java | 3 ++- .../system/dto/excel/UserExcel.java | 6 +++--- .../controller/user/UserControllerTests.java | 17 +++++++++++++++++ .../resources/file/user_import_cn_success.xls | Bin 0 -> 27136 bytes 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 backend/services/system-setting/src/test/resources/file/user_import_cn_success.xls diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilterChainUtils.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilterChainUtils.java index 9a77bcc31f..6730fd1ba5 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilterChainUtils.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilterChainUtils.java @@ -70,7 +70,8 @@ public class FilterChainUtils { // 获取插件中的图片 filterChainDefinitionMap.put("/plugin/image/**", "anon"); - filterChainDefinitionMap.put("/templates/user_import.xlsx", "anon"); + filterChainDefinitionMap.put("/templates/user_import_en.xlsx", "anon"); + filterChainDefinitionMap.put("/templates/user_import_cn.xlsx", "anon"); return filterChainDefinitionMap; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/excel/UserExcel.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/excel/UserExcel.java index d9a903f9bd..79cbd1a567 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/excel/UserExcel.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/excel/UserExcel.java @@ -10,16 +10,16 @@ import lombok.Data; public class UserExcel { @NotBlank(message = "{user.name.not_blank}") @Size(min = 1, max = 255, message = "{user.name.length_range}") - @ExcelProperty("name*") + @ExcelProperty(index = 0) private String name; @NotBlank(message = "{cannot_be_null}") @Size(min = 1, max = 64, message = "{user.email.length_range}") @Email(message = "{user.email.invalid}") - @ExcelProperty("email*") + @ExcelProperty(index = 1) private String email; - @ExcelProperty("phone") + @ExcelProperty(index = 2) private String phone; @ExcelProperty("workspace") 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 faa5e18220..751d33727c 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 @@ -560,7 +560,24 @@ public class UserControllerTests extends BaseTest { errorDataIndex = new int[]{}; UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex); + + //导入中文文件 + importSuccessData = 19; + filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_cn_success.xls")).getPath(); + file = new MockMultipartFile("file", "userImportCn.xls", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath)); + userImportReportDTOByFile = userService.getUserExcelParseDTO(file); + response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(UserRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class); + UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);//检查返回值 + userDTOList = this.checkImportUserInDb(userImportReportDTOByFile);//检查数据已入库 + for (UserDTO item : userDTOList) { + LOG_CHECK_LIST.add( + new CheckLogModel(item.getId(), OperationLogType.ADD, UserRequestUtils.URL_USER_IMPORT) + ); + } + + //文件内没有一条合格数据 应当导入成功的数据为0 + importSuccessData = 0; filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_error_all.xlsx")).getPath(); file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath)); response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(UserRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class); diff --git a/backend/services/system-setting/src/test/resources/file/user_import_cn_success.xls b/backend/services/system-setting/src/test/resources/file/user_import_cn_success.xls new file mode 100644 index 0000000000000000000000000000000000000000..854e08db07773c796b93620ca31577a0f2a02ebe GIT binary patch literal 27136 zcmeHQ3tUav_uuz+t6PcQQpzpqrP8}FdR&h|A%rm@uLzNeNzG{FJqXc^XMg+hVk0Elq=PxvoF zz(@)eX`oLEOivje$`la;sPG#^Oum;Kf-506Ar2xFNh2akB*VxAGLlRp$z(i9V16f% z(L|<;AZK(KCPEzw!O1$norpAJbh2QsmdtfK!?B;ab|4nO4g8Jr2ZS4SQlw_krlQ~2zS`gQ_7o{tvy({{DrkQc&O9?;SiqS`; zp-+&2o<;)nU;+8z0(2t*x*3mr2_PmU-15Ilr z87z=7gcw3A&?v_T$`UG#O>>k)f_pm(XVqRZ6*7i+5`Q9!C$bs^J>gDeFVfqS+Nrf| z=i_h&bex%7Y~Bdw-cd4uc)%Z1m{2iD7b*bLghZ!96}1z#gEf~=*V=^%^RWeolW-op zMw8Yskn-5Y6{l$(ABVQ0+CZDKCZa*arB*F@KrIa-?hw`Kg8*$uNn7wtJN_&x9}&vj z9=y|@o0%%jUn-l*mfaajmTAkbO#_vnGU(4SJXgTz1|dQgA%k&2hIA1;GxTSefoN{3SLF{z@E_bUTKw$sfSbZK#|t%*~gZEH@#N zHUe^l2TzvZK& zo(w&v#;JbT(!9M^ijRq=&KI5-|5Nsn0&{S@oHlJ5vr>Q=jd^H>JTxf}4dFp~iqe%zd8ic9!oyRQGy!LgxISIANMH~tJ7!~ ztWKj{a9&=XQXcgHT>peZnNWi}S1C70)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