【修改】 1、学生表新增学生字段2、默认密码使用用户名
This commit is contained in:
@@ -232,7 +232,7 @@ public class UserController {
|
|||||||
public void importTemplateStu(HttpServletResponse response) throws IOException {
|
public void importTemplateStu(HttpServletResponse response) throws IOException {
|
||||||
// 手动创建导出 demo
|
// 手动创建导出 demo
|
||||||
List<UserStuImportExcelVO> list = Arrays.asList(
|
List<UserStuImportExcelVO> list = Arrays.asList(
|
||||||
UserStuImportExcelVO.builder().userType("学生").username("xueshen").classId("三年二班").email("xueshen@exam.cn").mobile("xxxxxxxx")
|
UserStuImportExcelVO.builder().userType("学生").username("xueshen").password("xxxxxxx").classId("三年二班").schoolName("xx学校").mobile("xxxxxxxx")
|
||||||
.nickname("xxxx").sfz("xxxxxxxxxxxxx").status(CommonStatusEnum.ENABLE.getStatus()).sex(SexEnum.MALE.getSex()).build()
|
.nickname("xxxx").sfz("xxxxxxxxxxxxx").status(CommonStatusEnum.ENABLE.getStatus()).sex(SexEnum.MALE.getSex()).build()
|
||||||
);
|
);
|
||||||
// 输出
|
// 输出
|
||||||
|
@@ -27,6 +27,9 @@ public class UserRespVO{
|
|||||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||||
@ExcelProperty("用户昵称")
|
@ExcelProperty("用户昵称")
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
@Schema(description = "学校名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "123")
|
||||||
|
@ExcelProperty("学校名称")
|
||||||
|
private String schoolName;
|
||||||
@Schema(description = "身份证", requiredMode = Schema.RequiredMode.REQUIRED, example = "123")
|
@Schema(description = "身份证", requiredMode = Schema.RequiredMode.REQUIRED, example = "123")
|
||||||
@ExcelProperty("身份证")
|
@ExcelProperty("身份证")
|
||||||
private String sfz;
|
private String sfz;
|
||||||
@@ -38,11 +41,8 @@ public class UserRespVO{
|
|||||||
@Schema(description = "备注", example = "我是一个用户")
|
@Schema(description = "备注", example = "我是一个用户")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@Schema(description = "部门ID", example = "我是一个用户")
|
|
||||||
private Long deptId;
|
private Long deptId;
|
||||||
|
|
||||||
@Schema(description = "部门名称", example = "IT 部")
|
|
||||||
@ExcelProperty("部门名称")
|
|
||||||
private String deptName;
|
private String deptName;
|
||||||
|
|
||||||
@Schema(description = "岗位编号数组", example = "1")
|
@Schema(description = "岗位编号数组", example = "1")
|
||||||
|
@@ -33,6 +33,10 @@ public class UserSaveReqVO {
|
|||||||
@DiffLogField(name = "用户昵称")
|
@DiffLogField(name = "用户昵称")
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
|
||||||
|
@Schema(description = "学校名称", example = "xx学校")
|
||||||
|
@DiffLogField(name = "学校名称")
|
||||||
|
private String schoolName;
|
||||||
|
|
||||||
@Schema(description = "身份证", example = "31231")
|
@Schema(description = "身份证", example = "31231")
|
||||||
@DiffLogField(name = "身份证")
|
@DiffLogField(name = "身份证")
|
||||||
private String sfz;
|
private String sfz;
|
||||||
|
@@ -19,20 +19,23 @@ import pc.exam.pp.module.system.enums.DictTypeConstants;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
|
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
|
||||||
public class UserStuImportExcelVO {
|
public class UserStuImportExcelVO {
|
||||||
@ExcelProperty("属性(学生)")
|
@ExcelProperty("属性(学生)*")
|
||||||
private String userType;
|
private String userType;
|
||||||
|
|
||||||
@ExcelProperty("学生账号")
|
@ExcelProperty("学生账号*")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@ExcelProperty("姓名")
|
@ExcelProperty("密码")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@ExcelProperty("姓名*")
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
|
||||||
@ExcelProperty("班级")
|
@ExcelProperty("班级*")
|
||||||
private String classId;
|
private String classId;
|
||||||
|
|
||||||
@ExcelProperty("用户邮箱")
|
@ExcelProperty("学校名称")
|
||||||
private String email;
|
private String schoolName;
|
||||||
|
|
||||||
@ExcelProperty("手机号码")
|
@ExcelProperty("手机号码")
|
||||||
private String mobile;
|
private String mobile;
|
||||||
@@ -44,7 +47,7 @@ public class UserStuImportExcelVO {
|
|||||||
@DictFormat(DictTypeConstants.USER_SEX)
|
@DictFormat(DictTypeConstants.USER_SEX)
|
||||||
private Integer sex;
|
private Integer sex;
|
||||||
|
|
||||||
@ExcelProperty(value = "账号状态", converter = DictConvert.class)
|
@ExcelProperty(value = "账号状态*", converter = DictConvert.class)
|
||||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
@@ -51,6 +51,10 @@ public class AdminUserDO extends TenantBaseDO {
|
|||||||
* 用户昵称
|
* 用户昵称
|
||||||
*/
|
*/
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
/**
|
||||||
|
* 学校名称
|
||||||
|
*/
|
||||||
|
private String schoolName;
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
@@ -752,9 +752,16 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
UserImportRespVO respVO = UserImportRespVO.builder().createUsernames(new ArrayList<>())
|
UserImportRespVO respVO = UserImportRespVO.builder().createUsernames(new ArrayList<>())
|
||||||
.updateUsernames(new ArrayList<>()).failureUsernames(new LinkedHashMap<>()).build();
|
.updateUsernames(new ArrayList<>()).failureUsernames(new LinkedHashMap<>()).build();
|
||||||
importUsers.forEach(importUser -> {
|
importUsers.forEach(importUser -> {
|
||||||
|
String password = "";
|
||||||
|
// 判断上传文件是否存在密码,如果存在密码,则使用密码,不存在密码,则使用用户名
|
||||||
|
if (importUser.getPassword() == null) {
|
||||||
|
password = importUser.getUsername();
|
||||||
|
} else {
|
||||||
|
password = importUser.getPassword();
|
||||||
|
}
|
||||||
// 2.1.1 校验字段是否符合要求
|
// 2.1.1 校验字段是否符合要求
|
||||||
try {
|
try {
|
||||||
ValidationUtils.validate(BeanUtils.toBean(importUser, UserSaveReqVO.class).setPassword(initPassword));
|
ValidationUtils.validate(BeanUtils.toBean(importUser, UserSaveReqVO.class).setPassword(password));
|
||||||
} catch (ConstraintViolationException ex){
|
} catch (ConstraintViolationException ex){
|
||||||
respVO.getFailureUsernames().put(importUser.getUsername(), ex.getMessage());
|
respVO.getFailureUsernames().put(importUser.getUsername(), ex.getMessage());
|
||||||
return;
|
return;
|
||||||
@@ -784,7 +791,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
AdminUserDO existUser = userMapper.selectByUsername(importUser.getUsername());
|
AdminUserDO existUser = userMapper.selectByUsername(importUser.getUsername());
|
||||||
if (existUser == null) {
|
if (existUser == null) {
|
||||||
userMapper.insert(BeanUtils.toBean(importUser, AdminUserDO.class)
|
userMapper.insert(BeanUtils.toBean(importUser, AdminUserDO.class)
|
||||||
.setPassword(encodePassword(initPassword)).setPostIds(new HashSet<>())); // 设置默认密码及空岗位编号数组
|
.setPassword(encodePassword(password)).setPostIds(new HashSet<>())); // 设置默认密码(如果没有密码填写username)及空岗位编号数组
|
||||||
respVO.getCreateUsernames().add(importUser.getUsername());
|
respVO.getCreateUsernames().add(importUser.getUsername());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user