diff --git a/src/main/java/xyz/playedu/api/controller/backend/SystemController.java b/src/main/java/xyz/playedu/api/controller/backend/SystemController.java index 0ed73d9..2d167d8 100644 --- a/src/main/java/xyz/playedu/api/controller/backend/SystemController.java +++ b/src/main/java/xyz/playedu/api/controller/backend/SystemController.java @@ -70,7 +70,7 @@ public class SystemController { defaultCourseThumbs.add(apiUrl + "/images/courses/thumb1.png"); defaultCourseThumbs.add(apiUrl + "/images/courses/thumb2.png"); defaultCourseThumbs.add(apiUrl + "/images/courses/thumb3.png"); - data.put("default_course_thumbs", defaultCourseThumbs); + data.put("default.course_thumbs", defaultCourseThumbs); return JsonResponse.data(data); } diff --git a/src/main/java/xyz/playedu/api/controller/backend/UserController.java b/src/main/java/xyz/playedu/api/controller/backend/UserController.java index 7973a3c..e59587a 100644 --- a/src/main/java/xyz/playedu/api/controller/backend/UserController.java +++ b/src/main/java/xyz/playedu/api/controller/backend/UserController.java @@ -13,7 +13,9 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import xyz.playedu.api.BCtx; import xyz.playedu.api.constant.BPermissionConstant; +import xyz.playedu.api.constant.CConfig; import xyz.playedu.api.constant.SystemConstant; import xyz.playedu.api.domain.Department; import xyz.playedu.api.domain.User; @@ -36,7 +38,6 @@ import java.util.stream.Collectors; /** * @Author 杭州白书科技有限公司 - * * @create 2023/2/23 09:48 */ @RestController @@ -44,13 +45,17 @@ import java.util.stream.Collectors; @RequestMapping("/backend/v1/user") public class UserController { - @Autowired private UserService userService; + @Autowired + private UserService userService; - @Autowired private UserDepartmentService userDepartmentService; + @Autowired + private UserDepartmentService userDepartmentService; - @Autowired private DepartmentService departmentService; + @Autowired + private DepartmentService departmentService; - @Autowired private ApplicationContext context; + @Autowired + private ApplicationContext context; @BackendPermissionMiddleware(slug = BPermissionConstant.USER_INDEX) @GetMapping("/index") @@ -188,10 +193,14 @@ public class UserController { return JsonResponse.error("一次最多导入1000条数据"); } + // 导入表格的有效数据起始行-用于错误提醒 Integer startLine = req.getStartLine(); + // 默认的学员头像 + String defaultAvatar = BCtx.getConfig().get(CConfig.MEMBER_DEFAULT_AVATAR); + List errorLines = new ArrayList<>(); - errorLines.add(new String[] {"错误行", "错误信息"}); // 错误表-表头 + errorLines.add(new String[]{"错误行", "错误信息"}); // 错误表-表头 // 读取存在的部门 List departments = departmentService.all(); @@ -231,14 +240,14 @@ public class UserController { i++; // 索引值 if (userItem.getEmail() == null || userItem.getEmail().trim().length() == 0) { - errorLines.add(new String[] {"第" + (i + startLine) + "行", "未输入邮箱账号"}); + errorLines.add(new String[]{"第" + (i + startLine) + "行", "未输入邮箱账号"}); } else { // 邮箱重复判断 Integer repeatLine = emailRepeat.get(userItem.getEmail()); if (repeatLine != null) { errorLines.add( - new String[] { - "第" + (i + startLine) + "行", "与第" + repeatLine + "行邮箱重复" + new String[]{ + "第" + (i + startLine) + "行", "与第" + repeatLine + "行邮箱重复" }); } else { emailRepeat.put(userItem.getEmail(), i + startLine); @@ -248,7 +257,7 @@ public class UserController { // 部门数据检测 if (userItem.getDeps() == null || userItem.getDeps().trim().length() == 0) { - errorLines.add(new String[] {"第" + (i + startLine) + "行", "未选择部门"}); + errorLines.add(new String[]{"第" + (i + startLine) + "行", "未选择部门"}); } else { String[] tmpDepList = userItem.getDeps().trim().split("\\|"); Integer[] tmpDepIds = new Integer[tmpDepList.length]; @@ -258,8 +267,8 @@ public class UserController { // 判断部门id是否存在 if (tmpDepId == null || tmpDepId == 0) { errorLines.add( - new String[] { - "第" + (i + startLine) + "行", "部门『" + tmpDepList[j] + "』不存在" + new String[]{ + "第" + (i + startLine) + "行", "部门『" + tmpDepList[j] + "』不存在" }); continue; } @@ -271,13 +280,13 @@ public class UserController { // 姓名为空检测 String tmpName = userItem.getName(); if (tmpName == null || tmpName.trim().length() == 0) { - errorLines.add(new String[] {"第" + (i + startLine) + "行", "昵称为空"}); + errorLines.add(new String[]{"第" + (i + startLine) + "行", "昵称为空"}); } // 密码为空检测 String tmpPassword = userItem.getPassword(); if (tmpPassword == null || tmpPassword.trim().length() == 0) { - errorLines.add(new String[] {"第" + (i + startLine) + "行", "密码为空"}); + errorLines.add(new String[]{"第" + (i + startLine) + "行", "密码为空"}); } // 待插入数据 @@ -287,6 +296,7 @@ public class UserController { tmpInsertUser.setPassword(HelperUtil.MD5(tmpPassword + tmpSalt)); tmpInsertUser.setSalt(tmpSalt); tmpInsertUser.setName(tmpName); + tmpInsertUser.setAvatar(defaultAvatar); tmpInsertUser.setIdCard(userItem.getIdCard()); tmpInsertUser.setCreateIp(SystemConstant.INTERNAL_IP); tmpInsertUser.setCreateCity(SystemConstant.INTERNAL_IP_AREA); @@ -304,7 +314,7 @@ public class UserController { List existsEmails = userService.existsEmailsByEmails(emails); if (existsEmails.size() > 0) { for (String tmpEmail : existsEmails) { - errorLines.add(new String[] {"第" + emailRepeat.get(tmpEmail) + "行", "邮箱已注册"}); + errorLines.add(new String[]{"第" + emailRepeat.get(tmpEmail) + "行", "邮箱已注册"}); } } if (errorLines.size() > 1) {