ting.yin %!s(int64=8) %!d(string=hai) anos
pai
achega
10bc370d6d

+ 1 - 2
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/StudentApi.java

@@ -100,7 +100,6 @@ public class StudentApi {
                                 @RequestParam String loginName,
                                 @RequestParam String password,
                                 @RequestParam LoginType loginType){
-    	
-        return studentService.login(orgCode,loginName,password,loginType);
+        return new ResponseEntity(studentService.login(orgCode,loginName,password,loginType), HttpStatus.OK);
     }
 }

+ 2 - 2
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/UserApi.java

@@ -155,7 +155,7 @@ public class UserApi {
     @PostMapping("/login")
     public ResponseEntity login(@RequestParam String loginName,
                                 @RequestParam String password){
-        return userService.login(loginName,password);
+        return new ResponseEntity(userService.login(loginName,password),HttpStatus.OK);
     }
 
     @ApiOperation(value="二级登录",notes="二级登录")
@@ -163,7 +163,7 @@ public class UserApi {
     public ResponseEntity login(@PathVariable long orgId,
                                 @RequestParam String loginName,
                                 @RequestParam String password){
-        return userService.login(orgId,loginName,password);
+        return new ResponseEntity(userService.login(orgId,loginName,password),HttpStatus.OK);
     }
     
     @ApiOperation(value="登出",notes="登出")

+ 8 - 9
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/StudentService.java

@@ -1,5 +1,7 @@
 package cn.com.qmth.examcloud.service.core.service;
 
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
+
 import java.io.File;
 import java.util.ArrayList;
 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.Page;
 import org.springframework.data.domain.Pageable;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 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.StudentRepo;
 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
      * @return
      */
-    public ResponseEntity<?> login(String orgId, String loginName,
+    public UserInfo login(String orgId, String loginName,
                                    String password, LoginType loginType) {
         Org org = orgRepo.findByParentIdAndCode((long) 0, orgId);
         if (org == null) {
@@ -161,13 +160,13 @@ public class StudentService {
         if (LoginType.IDENTITY_NUMBER.equals(loginType)) {
             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) {
         	throw new RuntimeException("该用户不存在");
         } else if (!student.getUser().getPassword().equals(password)) {
@@ -178,7 +177,7 @@ public class StudentService {
             UserInfo userInfo = userService.getUserInfo(student.getUser(), token);
             userInfo.setStudentId(student.getId());
             userInfo.setIdentityNumber(student.getIdentityNumber());
-            return new ResponseEntity(userInfo, HttpStatus.OK);
+            return userInfo;
         }
     }
 

+ 4 - 6
core-api/src/main/java/cn/com/qmth/examcloud/service/core/service/UserService.java

@@ -14,8 +14,6 @@ import org.springframework.data.domain.Example;
 import org.springframework.data.domain.ExampleMatcher;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 
 import cn.com.qmth.examcloud.common.uac.AccessCtrlUtil;
@@ -88,7 +86,7 @@ public class UserService {
      * @param password
      * @return
      */
-    public ResponseEntity login(String loginName,
+    public UserInfo login(String loginName,
                                 String password){
         User user = userRepo.findByLoginName(loginName);
         return loginProcess(user,password);
@@ -102,7 +100,7 @@ public class UserService {
      * @param password
      * @return
      */
-    public ResponseEntity login(long orgId,
+    public UserInfo login(long orgId,
                                 String loginName,
                                 String password){
         User user = userRepo.findByRootOrgIdAndLoginName(orgId,loginName);
@@ -115,7 +113,7 @@ public class UserService {
      * @param password
      * @return
      */
-    public ResponseEntity loginProcess(User user,
+    public UserInfo loginProcess(User user,
                                        String password){
         if(user == null){
         	throw new RuntimeException("该用户不存在");
@@ -124,7 +122,7 @@ public class UserService {
         }else{
             String token = AccessCtrlUtil.buildToken();
             createAccessUser(token,user,null);
-            return new ResponseEntity(getUserInfo(user,token),HttpStatus.OK);
+            return getUserInfo(user,token);
         }
     }