|
@@ -1,16 +1,18 @@
|
|
|
package cn.com.qmth.examcloud.core.examwork.api.controller;
|
|
|
|
|
|
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
|
|
|
+
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
-import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Example;
|
|
|
+import org.springframework.data.domain.ExampleMatcher;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.domain.Sort;
|
|
@@ -33,7 +35,6 @@ import com.google.common.collect.Lists;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
|
|
|
-import cn.com.qmth.examcloud.commons.web.security.entity.AccessUser;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.core.examwork.api.controller.bean.CourseGroupBean;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.CourseGroupRelationRepo;
|
|
@@ -45,7 +46,6 @@ import cn.com.qmth.examcloud.core.examwork.dao.entity.CourseGroupEntity;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.CourseGroupRelation;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.Exam;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgEntity;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgPK;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudent;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.enums.ExamType;
|
|
|
import cn.com.qmth.examcloud.core.examwork.service.impl.ExamService;
|
|
@@ -76,7 +76,7 @@ public class ExamController extends ControllerSupport {
|
|
|
|
|
|
@Autowired
|
|
|
ExamOrgRepo examOrgRepo;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
CourseGroupRelationRepo courseGroupRelationRepo;
|
|
|
|
|
@@ -129,13 +129,11 @@ public class ExamController extends ControllerSupport {
|
|
|
|
|
|
@ApiOperation(value = "查询所有考试批次(包含有效无效)", notes = "不分页带查询")
|
|
|
@GetMapping("/exam/all/both")
|
|
|
- public ResponseEntity getAllExam(HttpServletRequest request,
|
|
|
- @ModelAttribute Exam examCriteria) {
|
|
|
- cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
- if (accessUser != null) {
|
|
|
- examCriteria.setOrgId(accessUser.getRootOrgId());
|
|
|
- }
|
|
|
- return new ResponseEntity(examService.getAllExam(examCriteria), HttpStatus.OK);
|
|
|
+ public List<Exam> getAllExam(@ModelAttribute Exam examCriteria) {
|
|
|
+ examCriteria.setRootOrgId(getRootOrgId());
|
|
|
+ ExampleMatcher exampleMatcher = ExampleMatcher.matching().withMatcher("name", contains());
|
|
|
+ Example<Exam> examExample = Example.of(examCriteria, exampleMatcher);
|
|
|
+ return examRepo.findAll(examExample, new Sort(Direction.DESC, "id"));
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "根据名称查询考试批次(包含有效)", notes = "不分页带查询")
|
|
@@ -280,7 +278,8 @@ public class ExamController extends ControllerSupport {
|
|
|
public List<CourseGroupBean> queryCourseGroupList(@PathVariable Long examId,
|
|
|
@PathVariable Integer curPage, @PathVariable Integer pageSize) {
|
|
|
|
|
|
- Pageable pageable = new PageRequest(curPage-1, pageSize, Sort.Direction.DESC, "updateTime");
|
|
|
+ Pageable pageable = new PageRequest(curPage - 1, pageSize, Sort.Direction.DESC,
|
|
|
+ "updateTime");
|
|
|
List<CourseGroupEntity> groupList = courseGroupRepo.findAllByExamId(examId, pageable);
|
|
|
|
|
|
List<CourseGroupBean> ret = Lists.newArrayList();
|
|
@@ -305,7 +304,7 @@ public class ExamController extends ControllerSupport {
|
|
|
for (CourseGroupRelation cur : relationList) {
|
|
|
courseIdList.add(cur.getCourseId());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
ret.add(bean);
|
|
|
}
|
|
|
|
|
@@ -377,7 +376,7 @@ public class ExamController extends ControllerSupport {
|
|
|
List<CourseGroupRelation> relationList = Lists.newArrayList();
|
|
|
|
|
|
courseGroupRelationRepo.deleteByGroupId(courseGroup.getId());
|
|
|
-
|
|
|
+
|
|
|
for (Long cur : courseIdList) {
|
|
|
CourseGroupRelation relation = new CourseGroupRelation();
|
|
|
relation.setCourseId(cur);
|
|
@@ -399,7 +398,8 @@ public class ExamController extends ControllerSupport {
|
|
|
@GetMapping("/exam/getExamOrgList/{examId}/{curPage}/{pageSize}")
|
|
|
public List<?> getExamOrgList(@PathVariable Long examId, @PathVariable Integer curPage,
|
|
|
@PathVariable Integer pageSize) {
|
|
|
- Pageable pageable = new PageRequest(curPage-1, pageSize, Sort.Direction.DESC, "updateTime");
|
|
|
+ Pageable pageable = new PageRequest(curPage - 1, pageSize, Sort.Direction.DESC,
|
|
|
+ "updateTime");
|
|
|
List<ExamOrgEntity> allByExamId = examOrgRepo.findAllByExamId(examId, pageable);
|
|
|
return allByExamId;
|
|
|
}
|
|
@@ -417,7 +417,7 @@ public class ExamController extends ControllerSupport {
|
|
|
ExamOrgEntity ret = examOrgRepo.save(examOrg);
|
|
|
return ret;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@ApiOperation(value = "删除考试相关的学习中心设置", notes = "")
|
|
|
@DeleteMapping("/exam/examOrg/{examId}/{orgId}")
|
|
|
public void deleteExamOrg(@PathVariable Long examId, @PathVariable Long orgId) {
|