|
@@ -1,144 +1,145 @@
|
|
|
-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.transaction.annotation.Transactional;
|
|
|
-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.SaveStudentReq;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.response.SaveStudentResp;
|
|
|
-import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
|
-import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
|
|
|
-import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
|
|
|
-import cn.com.qmth.examcloud.core.basic.dao.entity.OrgEntity;
|
|
|
-import cn.com.qmth.examcloud.core.basic.dao.entity.StudentEntity;
|
|
|
-import cn.com.qmth.examcloud.core.basic.service.bean.StudentInfo;
|
|
|
-import cn.com.qmth.examcloud.core.basic.service.impl.StudentServiceImpl;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-
|
|
|
-/**
|
|
|
- * 类注释
|
|
|
- *
|
|
|
- * @author WANGWEI
|
|
|
- * @date 2018年8月14日
|
|
|
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
- */
|
|
|
-@Transactional
|
|
|
-@RestController
|
|
|
-@RequestMapping("${$rmp.cloud.basic}" + "student")
|
|
|
-public class StudentCloudServiceProvider extends ControllerSupport implements StudentCloudService {
|
|
|
-
|
|
|
- private static final long serialVersionUID = -571041158847398070L;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- OrgRepo orgRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- UserRepo userRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- StudentServiceImpl studentService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- StudentRepo studentRepo;
|
|
|
-
|
|
|
- @ApiOperation(value = "保存学生")
|
|
|
- @PostMapping("saveStudent")
|
|
|
- @Override
|
|
|
- public SaveStudentResp saveStudent(@RequestBody SaveStudentReq req) {
|
|
|
-
|
|
|
- trim(req);
|
|
|
-
|
|
|
- StudentInfo studentInfo = new StudentInfo();
|
|
|
- studentInfo.setName(req.getName());
|
|
|
- studentInfo.setIdentityNumber(req.getIdentityNumber());
|
|
|
- studentInfo.setStudentCode(req.getStudentCode());
|
|
|
- studentInfo.setRootOrgId(req.getRootOrgId());
|
|
|
-
|
|
|
- studentInfo.setOrgId(req.getOrgId());
|
|
|
- studentInfo.setOrgCode(req.getOrgCode());
|
|
|
- studentInfo.setOrgName(req.getOrgName());
|
|
|
-
|
|
|
- studentInfo.setPhoneNumber(req.getPhoneNumber());
|
|
|
- studentInfo.setPhotoPath(req.getPhotoPath());
|
|
|
- studentInfo.setRemark(req.getRemark());
|
|
|
-
|
|
|
- StudentEntity student = studentService.saveStudent(studentInfo);
|
|
|
-
|
|
|
- SaveStudentResp resp = new SaveStudentResp();
|
|
|
- resp.setStudentId(student.getId());
|
|
|
- resp.setRootOrgId(student.getRootOrgId());
|
|
|
-
|
|
|
- OrgEntity org = orgRepo.findOne(student.getOrgId());
|
|
|
- resp.setOrgId(org.getId());
|
|
|
- resp.setOrgName(org.getName());
|
|
|
-
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "查询学生")
|
|
|
- @PostMapping("getStudent")
|
|
|
- @Override
|
|
|
- public GetStudentResp getStudent(@RequestBody GetStudentReq req) {
|
|
|
- Long studentId = req.getStudentId();
|
|
|
- Long rootOrgId = req.getRootOrgId();
|
|
|
- String identityNumber = req.getIdentityNumber();
|
|
|
-
|
|
|
- StudentEntity student = null;
|
|
|
- if (null != studentId) {
|
|
|
- student = studentRepo.findOne(studentId);
|
|
|
- } else {
|
|
|
-
|
|
|
- if (null == rootOrgId) {
|
|
|
- throw new StatusException("B-150000", "rootOrgId is null");
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(identityNumber)) {
|
|
|
- throw new StatusException("B-150004", "identityNumber is null");
|
|
|
- }
|
|
|
-
|
|
|
- OrgEntity rootOrg = orgRepo.findOne(rootOrgId);
|
|
|
- if (null == rootOrg) {
|
|
|
- throw new StatusException("B-150001", "机构不存在");
|
|
|
- }
|
|
|
- if (null != rootOrg.getParentId()) {
|
|
|
- throw new StatusException("B-150002", "机构错误");
|
|
|
- }
|
|
|
-
|
|
|
- student = studentRepo.findByIdentityNumberAndRootOrgId(identityNumber, rootOrgId);
|
|
|
- }
|
|
|
-
|
|
|
- if (null == student) {
|
|
|
- throw new StatusException("B-150005", "学生不存在");
|
|
|
- }
|
|
|
-
|
|
|
- OrgEntity org = orgRepo.findOne(student.getOrgId());
|
|
|
-
|
|
|
- StudentBean studentBean = new StudentBean();
|
|
|
- studentBean.setId(student.getId());
|
|
|
- studentBean.setName(student.getName());
|
|
|
- studentBean.setIdentityNumber(student.getIdentityNumber());
|
|
|
- studentBean.setStudentCode(student.getStudentCode());
|
|
|
- studentBean.setRootOrgId(student.getRootOrgId());
|
|
|
- studentBean.setOrgId(org.getId());
|
|
|
- studentBean.setOrgCode(org.getCode());
|
|
|
- studentBean.setOrgName(org.getName());
|
|
|
- studentBean.setPhoneNumber(student.getPhoneNumber());
|
|
|
- studentBean.setPhotoPath(student.getPhotoPath());
|
|
|
- studentBean.setRemark(student.getRemark());
|
|
|
- studentBean.setSecurityPhone(student.getSecurityPhone());
|
|
|
-
|
|
|
- GetStudentResp resp = new GetStudentResp();
|
|
|
- resp.setStudentInfo(studentBean);
|
|
|
- return resp;
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+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.transaction.annotation.Transactional;
|
|
|
+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.SaveStudentReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.SaveStudentResp;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.OrgEntity;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.StudentEntity;
|
|
|
+import cn.com.qmth.examcloud.core.basic.service.bean.StudentInfo;
|
|
|
+import cn.com.qmth.examcloud.core.basic.service.impl.StudentServiceImpl;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 类注释
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @date 2018年8月14日
|
|
|
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
+ */
|
|
|
+@Transactional
|
|
|
+@RestController
|
|
|
+@RequestMapping("${$rmp.cloud.basic}" + "student")
|
|
|
+public class StudentCloudServiceProvider extends ControllerSupport implements StudentCloudService {
|
|
|
+
|
|
|
+ private static final long serialVersionUID = -571041158847398070L;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OrgRepo orgRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UserRepo userRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StudentServiceImpl studentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StudentRepo studentRepo;
|
|
|
+
|
|
|
+ @ApiOperation(value = "保存学生")
|
|
|
+ @PostMapping("saveStudent")
|
|
|
+ @Override
|
|
|
+ public SaveStudentResp saveStudent(@RequestBody SaveStudentReq req) {
|
|
|
+
|
|
|
+ trim(req);
|
|
|
+
|
|
|
+ StudentInfo studentInfo = new StudentInfo();
|
|
|
+ studentInfo.setName(req.getName());
|
|
|
+ studentInfo.setIdentityNumber(req.getIdentityNumber());
|
|
|
+ studentInfo.setStudentCode(req.getStudentCode());
|
|
|
+ studentInfo.setRootOrgId(req.getRootOrgId());
|
|
|
+
|
|
|
+ studentInfo.setOrgId(req.getOrgId());
|
|
|
+ studentInfo.setOrgCode(req.getOrgCode());
|
|
|
+ studentInfo.setOrgName(req.getOrgName());
|
|
|
+
|
|
|
+ studentInfo.setPhoneNumber(req.getPhoneNumber());
|
|
|
+ studentInfo.setPhotoPath(req.getPhotoPath());
|
|
|
+ studentInfo.setRemark(req.getRemark());
|
|
|
+
|
|
|
+ StudentEntity student = studentService.saveStudent(studentInfo);
|
|
|
+
|
|
|
+ SaveStudentResp resp = new SaveStudentResp();
|
|
|
+ resp.setStudentId(student.getId());
|
|
|
+ resp.setRootOrgId(student.getRootOrgId());
|
|
|
+
|
|
|
+ OrgEntity org = orgRepo.findOne(student.getOrgId());
|
|
|
+ resp.setOrgId(org.getId());
|
|
|
+ resp.setOrgName(org.getName());
|
|
|
+
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询学生")
|
|
|
+ @PostMapping("getStudent")
|
|
|
+ @Override
|
|
|
+ public GetStudentResp getStudent(@RequestBody GetStudentReq req) {
|
|
|
+ Long studentId = req.getStudentId();
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
+ String identityNumber = req.getIdentityNumber();
|
|
|
+
|
|
|
+ StudentEntity student = null;
|
|
|
+ if (null != studentId) {
|
|
|
+ student = studentRepo.findOne(studentId);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if (null == rootOrgId) {
|
|
|
+ throw new StatusException("B-150000", "rootOrgId is null");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(identityNumber)) {
|
|
|
+ throw new StatusException("B-150004", "identityNumber is null");
|
|
|
+ }
|
|
|
+
|
|
|
+ OrgEntity rootOrg = orgRepo.findOne(rootOrgId);
|
|
|
+ if (null == rootOrg) {
|
|
|
+ throw new StatusException("B-150001", "机构不存在");
|
|
|
+ }
|
|
|
+ if (null != rootOrg.getParentId()) {
|
|
|
+ throw new StatusException("B-150002", "机构错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ student = studentRepo.findByIdentityNumberAndRootOrgId(identityNumber, rootOrgId);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null == student) {
|
|
|
+ throw new StatusException("B-150005", "学生不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ StudentBean studentBean = new StudentBean();
|
|
|
+ studentBean.setId(student.getId());
|
|
|
+ studentBean.setName(student.getName());
|
|
|
+ studentBean.setIdentityNumber(student.getIdentityNumber());
|
|
|
+ studentBean.setStudentCode(student.getStudentCode());
|
|
|
+ studentBean.setRootOrgId(student.getRootOrgId());
|
|
|
+ if (null != student.getOrgId()) {
|
|
|
+ OrgEntity org = orgRepo.findOne(student.getOrgId());
|
|
|
+ studentBean.setOrgId(org.getId());
|
|
|
+ studentBean.setOrgCode(org.getCode());
|
|
|
+ studentBean.setOrgName(org.getName());
|
|
|
+ }
|
|
|
+ studentBean.setPhoneNumber(student.getPhoneNumber());
|
|
|
+ studentBean.setPhotoPath(student.getPhotoPath());
|
|
|
+ studentBean.setRemark(student.getRemark());
|
|
|
+ studentBean.setSecurityPhone(student.getSecurityPhone());
|
|
|
+
|
|
|
+ GetStudentResp resp = new GetStudentResp();
|
|
|
+ resp.setStudentInfo(studentBean);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|