|
@@ -6,6 +6,8 @@ import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
+import javax.persistence.EntityManager;
|
|
|
+import javax.persistence.Query;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
@@ -48,6 +50,7 @@ import cn.com.qmth.examcloud.core.basic.api.response.GetCourseResp;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
|
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.examwork.api.controller.bean.CourseDomain;
|
|
|
import cn.com.qmth.examcloud.core.examwork.api.controller.bean.ExamStudentDomain;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
|
|
@@ -68,6 +71,9 @@ import io.swagger.annotations.ApiOperation;
|
|
|
@RequestMapping("${$rmp.ctr.examwork}/exam_student")
|
|
|
public class ExamStudentController extends ControllerSupport {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private EntityManager em;
|
|
|
+
|
|
|
@Autowired
|
|
|
ExamStudentRepo examStudentRepo;
|
|
|
|
|
@@ -89,6 +95,65 @@ public class ExamStudentController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
ExamRecordCloudService examRecordCloudService;
|
|
|
|
|
|
+ @ApiOperation(value = "查询考试的课程分页")
|
|
|
+ @GetMapping("examCoursePage/{curPage}/{pageSize}")
|
|
|
+ public PageInfo<CourseDomain> getExamCoursePage(@PathVariable Integer curPage,
|
|
|
+ @PathVariable Integer pageSize, @RequestParam(required = true) Long examId,
|
|
|
+ @RequestParam(required = false) Long courseId,
|
|
|
+ @RequestParam(required = false) String courseLevel) {
|
|
|
+
|
|
|
+ User accessUser = getAccessUser();
|
|
|
+ Long rootOrgId = accessUser.getRootOrgId();
|
|
|
+
|
|
|
+ StringBuilder sql = new StringBuilder(
|
|
|
+ "SELECT t.exam_id from ec_e_exam_student t where t.exam_id=?");
|
|
|
+ if (null != courseId) {
|
|
|
+ sql.append(" and t.course_id=?");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(courseLevel)) {
|
|
|
+ sql.append(" and t.course_level=?");
|
|
|
+ }
|
|
|
+
|
|
|
+ sql.append(" group by t.exam_id,t.course_id");
|
|
|
+ sql.append(" limit ").append(curPage).append(",").append("pageSize");
|
|
|
+
|
|
|
+ Query query = em.createNativeQuery(
|
|
|
+ "SELECT t.exam_id from ec_e_exam_student t where t.exam_id=1 group by t.exam_id,t.course_id");
|
|
|
+ query.setParameter(1, examId);
|
|
|
+ if (null != courseId) {
|
|
|
+ query.setParameter(2, courseId);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(courseLevel)) {
|
|
|
+ query.setParameter(3, courseLevel);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<?> resultList = query.getResultList();
|
|
|
+
|
|
|
+ List<CourseDomain> list = Lists.newArrayList();
|
|
|
+ for (Object cur : resultList) {
|
|
|
+ GetCourseReq req = new GetCourseReq();
|
|
|
+ req.setId((Long) cur);
|
|
|
+ req.setRootOrgId(rootOrgId);
|
|
|
+ GetCourseResp getCourseResp = courseCloudService.getCourse(req);
|
|
|
+ CourseBean courseBean = getCourseResp.getCourseBean();
|
|
|
+
|
|
|
+ CourseDomain d = new CourseDomain();
|
|
|
+ d.setCode(courseBean.getCode());
|
|
|
+ d.setLevel(courseBean.getLevel());
|
|
|
+ d.setName(courseBean.getName());
|
|
|
+ d.setId(courseBean.getId());
|
|
|
+
|
|
|
+ list.add(d);
|
|
|
+ }
|
|
|
+
|
|
|
+ em.close();
|
|
|
+
|
|
|
+ PageInfo<CourseDomain> page = new PageInfo<CourseDomain>();
|
|
|
+ page.setList(list);
|
|
|
+
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 方法注释
|
|
|
*
|