|
@@ -1,14 +1,19 @@
|
|
|
package cn.com.qmth.examcloud.core.basic.api.provider;
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.bean.StudentBean;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetStudentReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.InsertOrUpdateStudentReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.response.InsertOrUpdateStudentResp;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
|
|
@@ -67,4 +72,55 @@ public class StudentCloudServiceProvider extends ControllerSupport implements St
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "查询学生")
|
|
|
+ @PostMapping("getStudent")
|
|
|
+ @Override
|
|
|
+ public GetStudentResp getStudent(GetStudentReq req) {
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
+ String studentCode = req.getStudentCode();
|
|
|
+ String identityNumber = req.getIdentityNumber();
|
|
|
+
|
|
|
+ if (null == rootOrgId) {
|
|
|
+ throw new StatusException("B-150000", "rootOrgId is null");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(studentCode)) {
|
|
|
+ throw new StatusException("B-150003", "studentCode is null");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(identityNumber)) {
|
|
|
+ throw new StatusException("B-150004", "identityNumber is null");
|
|
|
+ }
|
|
|
+
|
|
|
+ Org rootOrg = orgRepo.findOne(rootOrgId);
|
|
|
+ if (null == rootOrg) {
|
|
|
+ throw new StatusException("B-150001", "机构不存在");
|
|
|
+ }
|
|
|
+ if (!rootOrg.getParentId().equals(0L)) {
|
|
|
+ throw new StatusException("B-150002", "机构错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ Student student = studentRepo.findByIdentityNumberAndStudentCodeAndRootOrgId(identityNumber,
|
|
|
+ studentCode, rootOrgId);
|
|
|
+
|
|
|
+ if (null == student) {
|
|
|
+ throw new StatusException("B-150005", "学生不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ Org org = orgRepo.findOne(student.getOrgId());
|
|
|
+
|
|
|
+ StudentBean studentBean = new StudentBean();
|
|
|
+ studentBean.setName(student.getName());
|
|
|
+ studentBean.setIdentityNumber(student.getIdentityNumber());
|
|
|
+ studentBean.setStudentCode(student.getStudentCode());
|
|
|
+ studentBean.setRootOrgId(student.getRootOrgId());
|
|
|
+ studentBean.setOrgCode(org.getCode());
|
|
|
+ studentBean.setOrgName(org.getName());
|
|
|
+ studentBean.setPhoneNumber(student.getPhoneNumber());
|
|
|
+ studentBean.setPhotoPath(student.getPhotoPath());
|
|
|
+ studentBean.setRemark(student.getRemark());
|
|
|
+
|
|
|
+ GetStudentResp resp = new GetStudentResp();
|
|
|
+ resp.setStudentInfo(studentBean);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
}
|