试卷列表二次校验

main
hujunpeng 4 months ago
parent 3c64adaa06
commit 1c000a46cb
  1. 8
      ccic-exam/src/main/java/com/ccic/safeliab/dao/ExamPaperMapper.java
  2. 2
      ccic-exam/src/main/java/com/ccic/safeliab/dao/QuestionMapper.java
  3. 4
      ccic-exam/src/main/java/com/ccic/safeliab/service/ExamPaperService.java
  4. 46
      ccic-exam/src/main/java/com/ccic/safeliab/service/ExamPaperServiceImpl.java
  5. 2
      ccic-exam/src/main/java/com/ccic/safeliab/service/QuestionServiceImpl.java
  6. 16
      ccic-exam/src/main/java/com/ccic/safeliab/web/ExamPaperController.java
  7. 19
      ccic-exam/src/main/resources/mappers/ExamPaperMapper.xml
  8. 2
      ccic-exam/src/main/resources/mappers/QuestionMapper.xml

@ -69,4 +69,12 @@ public interface ExamPaperMapper extends BaseMapper<ExamPapers> {
@Param("industryId") Long industryId,
@Param("questionCount") Integer questionCount);
/**
* 查询试卷是否被引用
*
* @param ids 试卷ID
* @return 查询结果
*/
int getExamIsUsed(@Param("ids") List<Long> ids);
}

@ -78,6 +78,6 @@ public interface QuestionMapper extends BaseMapper<QuestionCategories> {
* @param ids 试题ID
* @return 查询结果
*/
int getQuestiongInExamSize(@Param("ids") List<Long> ids);
int getQuestionIsUsed(@Param("ids") List<Long> ids);
}

@ -28,7 +28,7 @@ public interface ExamPaperService extends BaseService<ExamPapers> {
* @param ids 试卷ID
* @return 删除结果
*/
boolean delExamPaper(List<Long> ids);
Map<String, Object> delExamPaper(List<Long> ids);
/**
* 更新试卷状态
@ -36,7 +36,7 @@ public interface ExamPaperService extends BaseService<ExamPapers> {
* @param vo 试卷vo
* @return 更新结果
*/
boolean upPaperStatus(InsExamPaperVO vo);
Map<String, Object> upPaperStatus(InsExamPaperVO vo);
/**
* 获取试卷详情

@ -42,7 +42,20 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamP
}
@Override
public boolean delExamPaper(List<Long> ids) {
public Map<String, Object> delExamPaper(List<Long> ids) {
Map<String, Object> map = new HashMap<>();
int size = baseMapper.getExamIsUsed(ids);
if( size > 0 )
{
map.put("success", "error");
if (ids.size() > 1){
map.put("message", "选中的试卷中有" + size + "个已被引用,需删除引用的考试后方可删除");
} else {
map.put("message", "该试卷已被引用,需删除引用的考试后方可删除");
}
return map;
}
boolean flag = false;
flag = deleteLogic(ids);
@ -54,11 +67,29 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamP
}
}
}
return flag;
if (flag) {
map.put("success", "true");
map.put("message", "试卷更新成功");
} else {
map.put("success", "false");
map.put("message", "试卷更新失败");
}
return map;
}
@Override
public boolean upPaperStatus(InsExamPaperVO vo) {
public Map<String, Object> upPaperStatus(InsExamPaperVO vo) {
Map<String, Object> map = new HashMap<>();
int size = baseMapper.getExamIsUsed(vo.getIds());
if (size > 0) {
map.put("success", "error");
if (vo.getIds().size() > 1) {
map.put("message", "选中的试卷中有" + size + "个已被引用,需删除引用的考试后方可" + (vo.getPaperStatus() == 0 ? "停用" : "启用"));
} else {
map.put("message", "该试卷已被引用,需删除引用的考试后方可" + (vo.getPaperStatus() == 0 ? "停用" : "启用"));
}
return map;
}
boolean flag = false;
for (Long id : vo.getIds()) {
ExamPapers entity = baseMapper.getExamPaperDetail(id);
@ -68,7 +99,14 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamP
break;
}
}
return flag;
if (flag) {
map.put("success", "true");
map.put("message", "试卷更新成功");
} else {
map.put("success", "false");
map.put("message", "试卷更新失败");
}
return map;
}
@Override

@ -43,7 +43,7 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
@Override
public Map<String, Object> delQuestion(List<Long> ids) {
Map<String, Object> map = new HashMap<>();
int size = baseMapper.getQuestiongInExamSize(ids);
int size = baseMapper.getQuestionIsUsed(ids);
if( size > 0 )
{
map.put("success", "error");

@ -40,12 +40,8 @@ public class ExamPaperController {
*/
@PostMapping("/delExamPaper")
public R delExamPaper(@RequestBody List<Long> ids) {
boolean flag = examPaperService.delExamPaper(ids);
if (flag) {
return R.ok();
} else {
return R.error();
}
Map<String, Object> map = examPaperService.delExamPaper(ids);
return R.ok().data(map);
}
/**
@ -55,12 +51,8 @@ public class ExamPaperController {
*/
@PostMapping("/upPaperStatus")
public R upPaperStatus(@RequestBody InsExamPaperVO vo) {
boolean flag = examPaperService.upPaperStatus(vo);
if (flag) {
return R.ok();
} else {
return R.error();
}
Map<String, Object> map = examPaperService.upPaperStatus(vo);
return R.ok().data(map);
}
/**

@ -137,4 +137,23 @@
</where>
ORDER BY pq.question_number
</select>
<select id="getExamIsUsed" resultType="int">
SELECT
count(DISTINCT ep.id)
FROM
ex_exam_papers ep
INNER JOIN ex_exam_info ei
ON ei.paper_id = ep.id
AND ei.is_deleted = 0
<where>
ep.is_deleted = 0
<if test="ids!= null and ids.size() > 0">
AND ep.id IN
<foreach item="item" index="index" collection="ids"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
</mapper>

@ -133,7 +133,7 @@
</where>
ORDER BY b.question_number asc
</select>
<select id="getQuestiongInExamSize" resultType="int">
<select id="getQuestionIsUsed" resultType="int">
SELECT
count(DISTINCT qc.id)
FROM

Loading…
Cancel
Save