|
@@ -7,9 +7,6 @@
|
|
|
|
|
|
package cn.com.qmth.examcloud.core.print.service.impl;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import ch.qos.logback.core.joran.util.beans.BeanUtil;
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.print.common.Constants;
|
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.OrderBuilder;
|
|
@@ -19,10 +16,9 @@ import cn.com.qmth.examcloud.core.print.common.utils.Check;
|
|
|
import cn.com.qmth.examcloud.core.print.entity.ExamStructure;
|
|
|
import cn.com.qmth.examcloud.core.print.repository.ExamStructureRepository;
|
|
|
import cn.com.qmth.examcloud.core.print.service.ExamStructureService;
|
|
|
-import cn.com.qmth.examcloud.core.print.service.bean.ExamStructureConvert;
|
|
|
-import cn.com.qmth.examcloud.core.print.service.bean.ExamStructureInfo;
|
|
|
-import cn.com.qmth.examcloud.core.print.service.bean.ExamStructureQuery;
|
|
|
-
|
|
|
+import cn.com.qmth.examcloud.core.print.service.bean.examstructure.ExamStructureConvert;
|
|
|
+import cn.com.qmth.examcloud.core.print.service.bean.examstructure.ExamStructureInfo;
|
|
|
+import cn.com.qmth.examcloud.core.print.service.bean.examstructure.ExamStructureQuery;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
@@ -31,107 +27,108 @@ import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @author: fengdesheng
|
|
|
* @since: 2018/10/17
|
|
|
* @update: weiwenhai
|
|
|
- * @date: 2018.10.30
|
|
|
+ * @date: 2018.10.30
|
|
|
*/
|
|
|
@Service
|
|
|
public class ExamStructureServiceImpl implements ExamStructureService {
|
|
|
-
|
|
|
@Autowired
|
|
|
private ExamStructureRepository examStructureRepository;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
- @Override
|
|
|
- public Page<ExamStructureInfo> getExamStructureList(ExamStructureQuery query) {
|
|
|
- Check.isNull(query, "查询参数不能为空!");
|
|
|
- Check.isEmpty(query.getOrgId(), "机构id不能为空");
|
|
|
- //查询条件
|
|
|
- SearchBuilder searches = new SearchBuilder();
|
|
|
- searches.eq("orgId", query.getOrgId());
|
|
|
- if(query.getExamId() != null){
|
|
|
- searches.eq("examId", query.getExamId());
|
|
|
- }
|
|
|
- Specification<ExamStructure> spec = SpecUtils.buildSearchers(ExamStructure.class, searches.build());
|
|
|
- //排序条件
|
|
|
- OrderBuilder orders = new OrderBuilder().desc("id");
|
|
|
- //分页条件
|
|
|
+ @Override
|
|
|
+ public Page<ExamStructureInfo> getExamStructureList(ExamStructureQuery query) {
|
|
|
+ Check.isNull(query, "查询参数不能为空!");
|
|
|
+ Check.isEmpty(query.getOrgId(), "机构id不能为空");
|
|
|
+ //查询条件
|
|
|
+ SearchBuilder searches = new SearchBuilder();
|
|
|
+ searches.eq("orgId", query.getOrgId());
|
|
|
+ if (query.getExamId() != null) {
|
|
|
+ searches.eq("examId", query.getExamId());
|
|
|
+ }
|
|
|
+ Specification<ExamStructure> spec = SpecUtils.buildSearchers(ExamStructure.class, searches.build());
|
|
|
+ //排序条件
|
|
|
+ OrderBuilder orders = new OrderBuilder().desc("id");
|
|
|
+ //分页条件
|
|
|
Pageable pageable = SpecUtils.buildPageable(query.getPageNo(), query.getPageSize(), orders.build());
|
|
|
Page<ExamStructure> page = examStructureRepository.findAll(spec, pageable);
|
|
|
- return ExamStructureConvert.ofPage(page);
|
|
|
- }
|
|
|
+ return ExamStructureConvert.ofPage(page);
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void saveExamStructure(ExamStructureInfo info) {
|
|
|
- Check.isNull(info.getExamId(), "考试id不能为空");
|
|
|
- Check.isNull(info.getOrgId(), "机构id不能为空");
|
|
|
- Check.isBlank(info.getExamName(), "考试名称不能为空");
|
|
|
- Check.isBlank(info.getOrgName(), "机构名称不能为空");
|
|
|
- Check.isBlank(info.getExamType(), "考试类型不能为空");
|
|
|
- Check.isNull(info.getQuestionStructure(), "结构详情设置不能空");
|
|
|
- Check.isNull(info.getQuestionStructure().getSingleChoiceTotal(), "结构详情中,单选题数量不能为空");
|
|
|
- Check.isNull(info.getQuestionStructure().getMultipleChoiceTotal(), "结构详情中,多选题数量不能为空");
|
|
|
- Check.isNull(info.getQuestionStructure().getBoolQuestionTotal(), "结构详情中,判断题数量不能为空");
|
|
|
- ExamStructure entity = ExamStructureConvert.of(info);
|
|
|
- examStructureRepository.save(entity);
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public void saveExamStructure(ExamStructureInfo info) {
|
|
|
+ Check.isNull(info.getExamId(), "考试id不能为空");
|
|
|
+ Check.isNull(info.getOrgId(), "机构id不能为空");
|
|
|
+ Check.isBlank(info.getExamName(), "考试名称不能为空");
|
|
|
+ Check.isBlank(info.getOrgName(), "机构名称不能为空");
|
|
|
+ Check.isBlank(info.getExamType(), "考试类型不能为空");
|
|
|
+ Check.isNull(info.getQuestionStructure(), "结构详情设置不能空");
|
|
|
+ Check.isNull(info.getQuestionStructure().getSingleChoiceTotal(), "结构详情中,单选题数量不能为空");
|
|
|
+ Check.isNull(info.getQuestionStructure().getMultipleChoiceTotal(), "结构详情中,多选题数量不能为空");
|
|
|
+ Check.isNull(info.getQuestionStructure().getBoolQuestionTotal(), "结构详情中,判断题数量不能为空");
|
|
|
+ ExamStructure entity = ExamStructureConvert.of(info);
|
|
|
+ examStructureRepository.save(entity);
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void deleteExamStructure(List<Long> ids) {
|
|
|
- if(ids != null && ids.size()>0){
|
|
|
- for(Long id:ids){
|
|
|
- examStructureRepository.delete(id);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public void deleteExamStructure(List<Long> ids) {
|
|
|
+ if (ids != null && ids.size() > 0) {
|
|
|
+ for (Long id : ids) {
|
|
|
+ examStructureRepository.delete(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void copyExamStructure(ExamStructureInfo info) {
|
|
|
- //数据校验
|
|
|
- Check.isNull(info.getOrgId(), "被复用的机构id不能为空");
|
|
|
- Check.isNull(info.getExamId(), "被复用的考试id不能为空");
|
|
|
- Check.isNull(info.getNewOrgId(), "复用后的机构id不能为空");
|
|
|
- Check.isNull(info.getExamId(), "复用后的考试id不能为空");
|
|
|
- //首先查询要复用 导出结构设置信息
|
|
|
- ExamStructure examStructure = examStructureRepository.findByExamIdAndOrgId(info.getExamId(), info.getOrgId());
|
|
|
- if(examStructure == null){
|
|
|
- throw new StatusException(Constants.PRT_CODE_500, "复用导出结构不存在");
|
|
|
- }
|
|
|
- ExamStructure newExamStructure = examStructureRepository.findByExamIdAndOrgId(info.getNewExamId(), info.getNewOrgId());
|
|
|
- if(newExamStructure != null){
|
|
|
- throw new StatusException(Constants.PRT_CODE_500, "该场考试的导出结构已经存在,不能复用");
|
|
|
- }
|
|
|
- newExamStructure = new ExamStructure();
|
|
|
- BeanUtils.copyProperties(examStructure, newExamStructure);
|
|
|
- newExamStructure.setId(null);
|
|
|
- newExamStructure.setExamId(info.getNewExamId());
|
|
|
- newExamStructure.setExamName(info.getNewExamName());
|
|
|
- newExamStructure.setOrgId(info.getNewOrgId());
|
|
|
- newExamStructure.setOrgName(info.getNewOrgName());
|
|
|
- examStructureRepository.save(newExamStructure);
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public void copyExamStructure(ExamStructureInfo info) {
|
|
|
+ //数据校验
|
|
|
+ Check.isNull(info.getOrgId(), "被复用的机构id不能为空");
|
|
|
+ Check.isNull(info.getExamId(), "被复用的考试id不能为空");
|
|
|
+ Check.isNull(info.getNewOrgId(), "复用后的机构id不能为空");
|
|
|
+ Check.isNull(info.getExamId(), "复用后的考试id不能为空");
|
|
|
+ //首先查询要复用 导出结构设置信息
|
|
|
+ ExamStructure examStructure = examStructureRepository.findByExamIdAndOrgId(info.getExamId(), info.getOrgId());
|
|
|
+ if (examStructure == null) {
|
|
|
+ throw new StatusException(Constants.PRT_CODE_500, "复用导出结构不存在");
|
|
|
+ }
|
|
|
+ ExamStructure newExamStructure = examStructureRepository.findByExamIdAndOrgId(info.getNewExamId(), info.getNewOrgId());
|
|
|
+ if (newExamStructure != null) {
|
|
|
+ throw new StatusException(Constants.PRT_CODE_500, "该场考试的导出结构已经存在,不能复用");
|
|
|
+ }
|
|
|
+ newExamStructure = new ExamStructure();
|
|
|
+ BeanUtils.copyProperties(examStructure, newExamStructure);
|
|
|
+ newExamStructure.setId(null);
|
|
|
+ newExamStructure.setExamId(info.getNewExamId());
|
|
|
+ newExamStructure.setExamName(info.getNewExamName());
|
|
|
+ newExamStructure.setOrgId(info.getNewOrgId());
|
|
|
+ newExamStructure.setOrgName(info.getNewOrgName());
|
|
|
+ examStructureRepository.save(newExamStructure);
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void syncExamStructureExamName(Long examId, String examName) {
|
|
|
- String updateSql = String.format("UPDATE ec_prt_exam_structure SET exam_name = '%s' WHERE exam_id = %s", examName,examId);
|
|
|
- jdbcTemplate.update(updateSql);
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public void syncExamStructureExamName(Long examId, String examName) {
|
|
|
+ String updateSql = String.format("UPDATE ec_prt_exam_structure SET exam_name = '%s' WHERE exam_id = %s", examName, examId);
|
|
|
+ jdbcTemplate.update(updateSql);
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public ExamStructureInfo getExamStructure(ExamStructureQuery query) {
|
|
|
- Check.isNull(query, "查询参数不能为空!");
|
|
|
- Check.isEmpty(query.getOrgId(), "机构id不能为空");
|
|
|
- Check.isEmpty(query.getExamId(), "考试id不能为空");
|
|
|
- ExamStructure entity = examStructureRepository.findByExamIdAndOrgId(query.getExamId(), query.getOrgId());
|
|
|
- if(entity == null){
|
|
|
- return null;
|
|
|
- }
|
|
|
- ExamStructureInfo info = ExamStructureConvert.of(entity);
|
|
|
- return info;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public ExamStructureInfo getExamStructure(ExamStructureQuery query) {
|
|
|
+ Check.isNull(query, "查询参数不能为空!");
|
|
|
+ Check.isEmpty(query.getOrgId(), "机构id不能为空");
|
|
|
+ Check.isEmpty(query.getExamId(), "考试id不能为空");
|
|
|
+ ExamStructure entity = examStructureRepository.findByExamIdAndOrgId(query.getExamId(), query.getOrgId());
|
|
|
+ if (entity == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ ExamStructureInfo info = ExamStructureConvert.of(entity);
|
|
|
+ return info;
|
|
|
+ }
|
|
|
|
|
|
}
|