|
@@ -1,5 +1,7 @@
|
|
package cn.com.qmth.examcloud.service.core.service;
|
|
package cn.com.qmth.examcloud.service.core.service;
|
|
|
|
|
|
|
|
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
|
|
|
|
+
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -10,8 +12,6 @@ import org.springframework.data.domain.Example;
|
|
import org.springframework.data.domain.ExampleMatcher;
|
|
import org.springframework.data.domain.ExampleMatcher;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.domain.Pageable;
|
|
-import org.springframework.http.HttpStatus;
|
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
@@ -28,7 +28,6 @@ import cn.com.qmth.examcloud.service.core.enums.UserType;
|
|
import cn.com.qmth.examcloud.service.core.repo.OrgRepo;
|
|
import cn.com.qmth.examcloud.service.core.repo.OrgRepo;
|
|
import cn.com.qmth.examcloud.service.core.repo.StudentRepo;
|
|
import cn.com.qmth.examcloud.service.core.repo.StudentRepo;
|
|
import cn.com.qmth.examcloud.service.core.repo.UserRepo;
|
|
import cn.com.qmth.examcloud.service.core.repo.UserRepo;
|
|
-import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 学生服务类
|
|
* 学生服务类
|
|
@@ -148,7 +147,7 @@ public class StudentService {
|
|
* @param password
|
|
* @param password
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public ResponseEntity<?> login(String orgId, String loginName,
|
|
|
|
|
|
+ public UserInfo login(String orgId, String loginName,
|
|
String password, LoginType loginType) {
|
|
String password, LoginType loginType) {
|
|
Org org = orgRepo.findByParentIdAndCode((long) 0, orgId);
|
|
Org org = orgRepo.findByParentIdAndCode((long) 0, orgId);
|
|
if (org == null) {
|
|
if (org == null) {
|
|
@@ -161,13 +160,13 @@ public class StudentService {
|
|
if (LoginType.IDENTITY_NUMBER.equals(loginType)) {
|
|
if (LoginType.IDENTITY_NUMBER.equals(loginType)) {
|
|
student = studentRepo.findByIdentityNumber(loginName);
|
|
student = studentRepo.findByIdentityNumber(loginName);
|
|
}
|
|
}
|
|
- if (student != null) {
|
|
|
|
- return this.loginProcess(student, password);
|
|
|
|
|
|
+ if (student == null) {
|
|
|
|
+ throw new RuntimeException("该用户不存在");
|
|
}
|
|
}
|
|
- return userService.loginProcess(null, password);
|
|
|
|
|
|
+ return this.loginProcess(student, password);
|
|
}
|
|
}
|
|
|
|
|
|
- private ResponseEntity<?> loginProcess(Student student, String password) {
|
|
|
|
|
|
+ private UserInfo loginProcess(Student student, String password) {
|
|
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)) {
|
|
@@ -178,7 +177,7 @@ public class StudentService {
|
|
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());
|
|
- return new ResponseEntity(userInfo, HttpStatus.OK);
|
|
|
|
|
|
+ return userInfo;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|