wangwei 7 년 전
부모
커밋
d5ce7572b3

+ 10 - 1
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/StudentController.java

@@ -207,7 +207,16 @@ public class StudentController extends ControllerSupport {
 				.collect(Collectors.toList());
 		for (Long cur : studentIds) {
 			Student s = studentRepo.findOne(cur);
-			s.setPassword(Consts.DEFAULT_PASSWORD);
+			if (null == s) {
+				throw new StatusException("B-450110", "学生不存在");
+			}
+			String identityNumber = s.getIdentityNumber();
+			if (StringUtils.isNotEmpty(identityNumber)
+					&& identityNumber.matches("[0-9a-zA-Z]{6,}")) {
+				s.setPassword(StringUtils.substring(identityNumber, -6, identityNumber.length()));
+			} else {
+				s.setPassword(Consts.DEFAULT_PASSWORD);
+			}
 			studentRepo.save(s);
 		}
 	}