wangwei 6 лет назад
Родитель
Сommit
7101d25004

+ 16 - 4
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/StudentController.java

@@ -257,7 +257,7 @@ public class StudentController extends ControllerSupport {
 	}
 
 	/**
-	 * 查询用户
+	 * 查询学生
 	 *
 	 * @author WANGWEI
 	 * @param identityNumber
@@ -265,15 +265,27 @@ public class StudentController extends ControllerSupport {
 	 * @param securityPhone
 	 * @return
 	 */
+	@ApiOperation(value = "查询学生")
+	@GetMapping("getStudentInfoBySession")
+	public StudentInfo getStudentInfoBySession() {
+		User accessUser = getAccessUser();
+		Long rootOrgId = accessUser.getRootOrgId();
+		Long studentId = accessUser.getStudentId();
+		StudentInfo studentInfo = studentService.getStudentInfo(rootOrgId, studentId, null, null,
+				null);
+		return studentInfo;
+	}
+
 	@ApiOperation(value = "查询学生")
 	@GetMapping("getStudentInfo")
-	public StudentInfo getStudentInfo(@RequestParam(required = false) String identityNumber,
+	public StudentInfo getStudentInfo(@RequestParam(required = false) Long studentId,
+			@RequestParam(required = false) String identityNumber,
 			@RequestParam(required = false) String studentCode,
 			@RequestParam(required = false) String securityPhone) {
 		User accessUser = getAccessUser();
 		Long rootOrgId = accessUser.getRootOrgId();
-		StudentInfo studentInfo = studentService.getStudentInfo(rootOrgId, identityNumber,
-				studentCode, securityPhone);
+		StudentInfo studentInfo = studentService.getStudentInfo(rootOrgId, studentId,
+				identityNumber, studentCode, securityPhone);
 		return studentInfo;
 	}
 

+ 3 - 4
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/StudentService.java

@@ -1,7 +1,5 @@
 package cn.com.qmth.examcloud.core.basic.service;
 
-import org.springframework.web.bind.annotation.RequestParam;
-
 import cn.com.qmth.examcloud.core.basic.dao.entity.Student;
 import cn.com.qmth.examcloud.core.basic.service.bean.StudentInfo;
 
@@ -28,12 +26,13 @@ public interface StudentService {
 	 *
 	 * @author WANGWEI
 	 * @param rootOrgId
+	 * @param studentId
 	 * @param identityNumber
 	 * @param studentCode
 	 * @param securityPhone
 	 * @return
 	 */
-	StudentInfo getStudentInfo(Long rootOrgId, String identityNumber, String studentCode,
-			String securityPhone);
+	StudentInfo getStudentInfo(Long rootOrgId, Long studentId, String identityNumber,
+			String studentCode, String securityPhone);
 
 }

+ 12 - 3
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/StudentServiceImpl.java

@@ -259,10 +259,19 @@ public class StudentServiceImpl implements StudentService {
 	 * java.lang.Long, java.lang.String, java.lang.String, java.lang.String)
 	 */
 	@Override
-	public StudentInfo getStudentInfo(Long rootOrgId, String identityNumber, String studentCode,
-			String securityPhone) {
+	public StudentInfo getStudentInfo(Long rootOrgId, Long studentId, String identityNumber,
+			String studentCode, String securityPhone) {
+
+		if (null == rootOrgId) {
+			throw new StatusException("B-160250", "rootOrgId is null");
+		}
+
 		Student s = null;
 		int count = 0;
+		if (null != studentId) {
+			count++;
+			s = studentRepo.findOne(studentId);
+		}
 		if (StringUtils.isNotBlank(identityNumber)) {
 			count++;
 			s = studentRepo.findByIdentityNumberAndRootOrgId(identityNumber, rootOrgId);
@@ -278,7 +287,7 @@ public class StudentServiceImpl implements StudentService {
 
 		if (count > 1) {
 			throw new StatusException("B-160210",
-					"参数过多,只需要[identityNumber,studentCode,securityPhone]中的一个");
+					"参数过多,只需要[studentId,identityNumber,studentCode,securityPhone]中的一个");
 		}
 
 		if (null == s) {