|
@@ -1,15 +1,28 @@
|
|
|
package cn.com.qmth.examcloud.core.examwork.api.provider;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
+import org.springframework.data.domain.Sort.Direction;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
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 com.google.common.collect.Lists;
|
|
|
+
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.core.examwork.base.enums.ExamProperty;
|
|
@@ -26,10 +39,12 @@ import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
|
|
|
import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
|
|
|
import cn.com.qmth.examcloud.examwork.api.request.GetExamPropertyReq;
|
|
|
import cn.com.qmth.examcloud.examwork.api.request.GetExamReq;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.GetOngoingExamListReq;
|
|
|
import cn.com.qmth.examcloud.examwork.api.request.SaveExamReq;
|
|
|
import cn.com.qmth.examcloud.examwork.api.request.SetExamPropertyReq;
|
|
|
import cn.com.qmth.examcloud.examwork.api.response.GetExamPropertyResp;
|
|
|
import cn.com.qmth.examcloud.examwork.api.response.GetExamResp;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.response.GetOngoingExamListResp;
|
|
|
import cn.com.qmth.examcloud.examwork.api.response.SaveExamResp;
|
|
|
import cn.com.qmth.examcloud.examwork.api.response.SetExamPropertyResp;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -189,4 +204,47 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public GetOngoingExamListResp getOngoingExamList(GetOngoingExamListReq req) {
|
|
|
+
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
+
|
|
|
+ Specification<ExamEntity> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
|
|
|
+ predicates.add(cb.lessThan(root.get("beginTime"), new Date()));
|
|
|
+ predicates.add(cb.greaterThan(root.get("endTime"), new Date()));
|
|
|
+
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+
|
|
|
+ PageRequest pageRequest = new PageRequest(0, 100, new Sort(Direction.DESC, "updateTime"));
|
|
|
+
|
|
|
+ Page<ExamEntity> page = examRepo.findAll(specification, pageRequest);
|
|
|
+
|
|
|
+ Iterator<ExamEntity> iterator = page.iterator();
|
|
|
+
|
|
|
+ List<ExamBean> list = Lists.newArrayList();
|
|
|
+
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ ExamEntity exam = iterator.next();
|
|
|
+ ExamBean bean = new ExamBean();
|
|
|
+ list.add(bean);
|
|
|
+
|
|
|
+ bean.setId(exam.getId());
|
|
|
+ bean.setBeginTime(exam.getBeginTime());
|
|
|
+ bean.setDuration(exam.getDuration());
|
|
|
+ bean.setEnable(exam.getEnable());
|
|
|
+ bean.setEndTime(exam.getEndTime());
|
|
|
+ bean.setExamTimes(exam.getExamTimes());
|
|
|
+ bean.setExamType(exam.getExamType().name());
|
|
|
+ bean.setName(exam.getName());
|
|
|
+ bean.setRemark(exam.getRemark());
|
|
|
+ bean.setRootOrgId(exam.getRootOrgId());
|
|
|
+ }
|
|
|
+ GetOngoingExamListResp resp = new GetOngoingExamListResp();
|
|
|
+ resp.setExamList(list);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
}
|