Commit 59ec29e3 by 罗志长

fix: 平台用户导入格式校验

parent 571871bd
......@@ -69,4 +69,12 @@ public class ExcelErrorVo implements Serializable {
emailMap.put(key,"system");
}
}
public static void incorrectFormatting(List<ExcelErrorVo> errorVoList, int i, String title, String msg) {
if (StringUtils.isBlank(msg)) {
errorVoList.add(new ExcelErrorVo(i, title, "格式不正确"));
} else {
errorVoList.add(new ExcelErrorVo(i, title, msg));
}
}
}
package com.makeit.service.platform.auth.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -1202,6 +1203,9 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
for (int i = 0; i < platUserImportDTOS.size(); i++) {
PlatUserImportDTO dto = platUserImportDTOS.get(i);
ExcelErrorVo.isNotNull(dto.getUsername(), errorVoList, start + i, "姓名*");
if (!Validator.isMobile(dto.getMobile())) {
ExcelErrorVo.incorrectFormatting(errorVoList, start + i, "手机号*", null);
}
ExcelErrorVo.isNotNull(dto.getMobile(), errorVoList, start + i, "手机号*");
ExcelErrorVo.isNotNull(dto.getRoleName(), errorVoList, start + i, "*角色");
ExcelErrorVo.isNotNull(dto.getOrgName(), errorVoList, start + i, "*所属组织");
......@@ -1210,7 +1214,13 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
ExcelErrorVo.notExists(roleNameMap.get(platOrg.getId()+dto.getRoleName()), errorVoList, start + i, "*角色");
ExcelErrorVo.exists(accountMap, dto.getMobile(), errorVoList, start + i, "账户*");
ExcelErrorVo.exists(mobileMap, dto.getMobile(), errorVoList, start + i, "手机号*");
if (!Validator.isEmail(dto.getEmail())) {
ExcelErrorVo.incorrectFormatting(errorVoList, start + i, "邮箱", null);
}
ExcelErrorVo.exists(emailMap, dto.getEmail(), errorVoList, start + i, "邮箱");
if (StringUtils.isNotBlank(dto.getRemark()) && dto.getRemark().length() > 200) {
ExcelErrorVo.incorrectFormatting(errorVoList, start + i, "备注", "长度不能超过200字符");
}
}
if (errorVoList.isEmpty()) {
List<PlatUser> platUsers = new ArrayList<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment