feat(系统管理): 用户导入模板增加中文模板

This commit is contained in:
song-tianyang 2024-01-31 20:43:40 +08:00 committed by 刘瑞斌
parent 9951b73c7c
commit 567a626998
4 changed files with 22 additions and 4 deletions

View File

@ -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;
}

View File

@ -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")

View File

@ -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);