|
@@ -109,12 +109,15 @@ public class StudentService {
|
|
public Student save(Student student) {
|
|
public Student save(Student student) {
|
|
if (student.getUser() == null || null == student.getUser().getId()) {//判断是否有用户
|
|
if (student.getUser() == null || null == student.getUser().getId()) {//判断是否有用户
|
|
//判断是否有该学生,
|
|
//判断是否有该学生,
|
|
- Student domain = studentRepo.findByUserRootOrgIdAndStudentCode(student.getUser().getRootOrgId(), student.getStudentCode());
|
|
|
|
- if (domain != null) {//学号查找不为空,更新身份证号
|
|
|
|
- domain.setIdentityNumber(student.getIdentityNumber());
|
|
|
|
- domain.setUpdateTime(new Date());
|
|
|
|
- return studentRepo.save(domain);
|
|
|
|
|
|
+ if (!StringUtils.isEmpty(student.getStudentCode())) {
|
|
|
|
+ Student domain = studentRepo.findByUserRootOrgIdAndStudentCode(student.getUser().getRootOrgId(), student.getStudentCode());
|
|
|
|
+ if (domain != null) {//学号查找不为空,更新身份证号
|
|
|
|
+ domain.setIdentityNumber(student.getIdentityNumber());
|
|
|
|
+ domain.setUpdateTime(new Date());
|
|
|
|
+ return studentRepo.save(domain);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
Student entity = studentRepo.findByIdentityNumber(student.getIdentityNumber());
|
|
Student entity = studentRepo.findByIdentityNumber(student.getIdentityNumber());
|
|
if (entity != null) {//身份证查找不为空,更新学号
|
|
if (entity != null) {//身份证查找不为空,更新学号
|
|
entity.setStudentCode(student.getStudentCode());
|
|
entity.setStudentCode(student.getStudentCode());
|
|
@@ -136,7 +139,7 @@ public class StudentService {
|
|
}
|
|
}
|
|
user.setPassword(password);
|
|
user.setPassword(password);
|
|
List<UserRole> userRoles = new ArrayList<UserRole>();
|
|
List<UserRole> userRoles = new ArrayList<UserRole>();
|
|
- userRoles.add(new UserRole("ecs_oe","STUDENT"));
|
|
|
|
|
|
+ userRoles.add(new UserRole("ecs_oe", "STUDENT"));
|
|
user.setUserRoles(userRoles);
|
|
user.setUserRoles(userRoles);
|
|
userRepo.save(user);
|
|
userRepo.save(user);
|
|
student.setUser(user);
|
|
student.setUser(user);
|
|
@@ -155,10 +158,10 @@ public class StudentService {
|
|
public UserInfo login(String orgId,
|
|
public UserInfo login(String orgId,
|
|
String loginName,
|
|
String loginName,
|
|
String password,
|
|
String password,
|
|
- LoginType loginType) throws Exception{
|
|
|
|
|
|
+ LoginType loginType) throws Exception {
|
|
Org org = orgRepo.findFirstByParentIdAndCode((long) 0, orgId);
|
|
Org org = orgRepo.findFirstByParentIdAndCode((long) 0, orgId);
|
|
if (org == null) {
|
|
if (org == null) {
|
|
- throw new RuntimeException("学校不存在");
|
|
|
|
|
|
+ throw new RuntimeException("学校不存在");
|
|
}
|
|
}
|
|
Student student = null;
|
|
Student student = null;
|
|
if (LoginType.STUDENT_CODE.equals(loginType)) {
|
|
if (LoginType.STUDENT_CODE.equals(loginType)) {
|
|
@@ -168,23 +171,23 @@ public class StudentService {
|
|
student = studentRepo.findByIdentityNumber(loginName);
|
|
student = studentRepo.findByIdentityNumber(loginName);
|
|
}
|
|
}
|
|
if (student == null) {
|
|
if (student == null) {
|
|
- throw new RuntimeException("该用户不存在");
|
|
|
|
|
|
+ throw new RuntimeException("该用户不存在");
|
|
}
|
|
}
|
|
return this.loginProcess(student, password);
|
|
return this.loginProcess(student, password);
|
|
}
|
|
}
|
|
|
|
|
|
- private UserInfo loginProcess(Student student, String password) throws Exception{
|
|
|
|
|
|
+ private UserInfo loginProcess(Student student, String password) throws Exception {
|
|
if (student.getUser() == null) {
|
|
if (student.getUser() == null) {
|
|
- throw new RuntimeException("该用户不存在");
|
|
|
|
|
|
+ throw new RuntimeException("该用户不存在");
|
|
} else if (!student.getUser().getPassword().equals(password)) {
|
|
} else if (!student.getUser().getPassword().equals(password)) {
|
|
- throw new RuntimeException("密码错误");
|
|
|
|
- } else if(!student.getUser().getEnable()){
|
|
|
|
|
|
+ throw new RuntimeException("密码错误");
|
|
|
|
+ } else if (!student.getUser().getEnable()) {
|
|
throw new RuntimeException("该用户被禁用");
|
|
throw new RuntimeException("该用户被禁用");
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
String token = AccessCtrlUtil.buildToken();
|
|
String token = AccessCtrlUtil.buildToken();
|
|
- userService.initUserLogin(student.getUser());
|
|
|
|
- userService.createAccessUser(token,student.getUser(),student.getId());
|
|
|
|
- userService.createUserLogin(token,student.getUser());
|
|
|
|
|
|
+ userService.initUserLogin(student.getUser());
|
|
|
|
+ userService.createAccessUser(token, student.getUser(), student.getId());
|
|
|
|
+ userService.createUserLogin(token, student.getUser());
|
|
UserInfo userInfo = userService.getUserInfo(student.getUser(), token);
|
|
UserInfo userInfo = userService.getUserInfo(student.getUser(), token);
|
|
userInfo.setStudentId(student.getId());
|
|
userInfo.setStudentId(student.getId());
|
|
userInfo.setIdentityNumber(student.getIdentityNumber());
|
|
userInfo.setIdentityNumber(student.getIdentityNumber());
|