Ver Fonte

学生登陆增加返回字段照片地址

ting.yin há 8 anos atrás
pai
commit
3fbc894a0d

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

@@ -15,7 +15,9 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
+import cn.com.qmth.examcloud.common.uac.AccessCtrlUtil;
 import cn.com.qmth.examcloud.common.util.ErrorMsg;
+import cn.com.qmth.examcloud.service.core.dto.UserInfo;
 import cn.com.qmth.examcloud.service.core.entity.Org;
 import cn.com.qmth.examcloud.service.core.entity.Student;
 import cn.com.qmth.examcloud.service.core.entity.User;
@@ -148,9 +150,24 @@ public class StudentService {
     		student = studentRepo.findByIdentityNumber(loginName);
     	}
     	if(student != null){
-    		return userService.loginProcess(student.getUser(),password,student.getId());
+    		return this.loginProcess(student,password);
     	}
-        return userService.loginProcess(null, password,null);
+        return userService.loginProcess(null, password);
     }
 
+	private ResponseEntity<?> loginProcess(Student student, String password) {
+		if(student.getUser() == null){
+            return new ResponseEntity(new ErrorMsg("该用户不存在"),HttpStatus.NOT_FOUND);
+        }else if(!student.getUser().getPassword().equals(password)){
+            return new ResponseEntity(new ErrorMsg("密码错误"),HttpStatus.EXPECTATION_FAILED);
+        }else{
+            String token = AccessCtrlUtil.buildToken();
+            userService.createAccessUser(token, student.getUser(), student.getId());
+            UserInfo userInfo=userService.getUserInfo(student.getUser(),token);
+            userInfo.setStudentId(student.getId());
+            userInfo.setPhotoPath(student.getPhotoPath());
+            return new ResponseEntity(userInfo,HttpStatus.OK);
+        }
+	}
+
 }

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

@@ -74,7 +74,7 @@ public class UserService {
     public ResponseEntity login(String loginName,
                                 String password){
         User user = userRepo.findByLoginName(loginName);
-        return loginProcess(user,password,null);
+        return loginProcess(user,password);
 
     }
 
@@ -89,7 +89,7 @@ public class UserService {
                                 String loginName,
                                 String password){
         User user = userRepo.findByRootOrgIdAndLoginName(orgId,loginName);
-        return loginProcess(user,password,null);
+        return loginProcess(user,password);
     }
 
     /**
@@ -99,15 +99,15 @@ public class UserService {
      * @return
      */
     public ResponseEntity loginProcess(User user,
-                                       String password,Long studentId){
+                                       String password){
         if(user == null){
             return new ResponseEntity(new ErrorMsg("该用户不存在"),HttpStatus.NOT_FOUND);
         }else if(!user.getPassword().equals(password)){
             return new ResponseEntity(new ErrorMsg("密码错误"),HttpStatus.EXPECTATION_FAILED);
         }else{
             String token = AccessCtrlUtil.buildToken();
-            createAccessUser(token,user,studentId);
-            return new ResponseEntity(getUserInfo(user,token,studentId),HttpStatus.OK);
+            createAccessUser(token,user,null);
+            return new ResponseEntity(getUserInfo(user,token),HttpStatus.OK);
         }
     }
 
@@ -138,7 +138,7 @@ public class UserService {
      * @param token
      * @return
      */
-    public UserInfo getUserInfo(User user,String token,Long studentId){
+    public UserInfo getUserInfo(User user,String token){
         UserInfo userInfo = new UserInfo();
         Org org = orgRepo.findOne(user.getOrgId());
         Org rootOrg = orgRepo.findOne(user.getRootOrgId());

+ 10 - 0
core-domain/src/main/java/cn/com/qmth/examcloud/service/core/dto/UserInfo.java

@@ -31,6 +31,8 @@ public class UserInfo implements Serializable{
     private String rootOrgLogo;
     
     private Long studentId;
+    
+    private String photoPath;
 
     public static long getSerialVersionUID() {
         return serialVersionUID;
@@ -132,6 +134,14 @@ public class UserInfo implements Serializable{
 		this.studentId = studentId;
 	}
 
+	public String getPhotoPath() {
+		return photoPath;
+	}
+
+	public void setPhotoPath(String photoPath) {
+		this.photoPath = photoPath;
+	}
+
 	public UserInfo() {
     }
 }