Bladeren bron

更新学生登陆

ting.yin 8 jaren geleden
bovenliggende
commit
4ebe294124

+ 4 - 3
core-api/src/main/java/cn/com/qmth/examcloud/service/core/api/StudentApi.java

@@ -93,11 +93,12 @@ public class StudentApi {
     }
     
     @ApiOperation(value="学生登录",notes="学生登录")
-    @PostMapping("/login/{orgId}")
-    public ResponseEntity login(@PathVariable long orgId,
+    @PostMapping("/login")
+    public ResponseEntity login(@RequestParam String orgCode,
                                 @RequestParam String loginName,
                                 @RequestParam String password,
                                 @RequestParam LoginType loginType){
-        return studentService.login(orgId,loginName,password,loginType);
+    	
+        return studentService.login(orgCode,loginName,password,loginType);
     }
 }

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

@@ -10,16 +10,19 @@ 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;
 
 import cn.com.qmth.examcloud.common.util.ErrorMsg;
+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;
 import cn.com.qmth.examcloud.service.core.enums.LoginType;
 import cn.com.qmth.examcloud.service.core.enums.UserScope;
 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;
 
@@ -36,6 +39,8 @@ public class StudentService {
     UserRepo userRepo;
     @Autowired
     UserService userService;
+    @Autowired
+    OrgRepo orgRepo;
     
     private static final String JPG = ".jpg";
 
@@ -129,11 +134,15 @@ public class StudentService {
      * @param password
      * @return
      */
-    public ResponseEntity<?> login(long orgId,String loginName,
+    public ResponseEntity<?> login(String orgId,String loginName,
                                 String password,LoginType loginType){
+    	Org org = orgRepo.findByParentIdAndCode((long)0, orgId);
+    	if(org == null){
+    		return new ResponseEntity(new ErrorMsg("学校不存在"),HttpStatus.NOT_FOUND);
+    	}
     	Student student = null;
     	if(LoginType.STUDENT_CODE.equals(loginType)){
-    		student = studentRepo.findByUserRootOrgIdAndStudentCode(orgId, loginName);
+    		student = studentRepo.findByUserRootOrgIdAndStudentCode(org.getId(), loginName);
     	}
     	if(LoginType.IDENTITY_NUMBER.equals(loginType)){
     		student = studentRepo.findByIdentityNumber(loginName);