Merge remote-tracking branch 'origin/main'

# Conflicts:
#	ccic-exam/src/main/java/com/ccic/safeliab/dao/QuestionMapper.java
#	ccic-exam/src/main/resources/mappers/QuestionMapper.xml
main
liuyiliang 4 months ago
commit 6b861b8382
  1. 5
      ccic-entity/src/main/java/com/ccic/safeliab/entity/PaperQuestion.java
  2. 15
      ccic-exam/src/main/java/com/ccic/safeliab/dao/ExamPaperMapper.java
  3. 24
      ccic-exam/src/main/java/com/ccic/safeliab/dao/PaperQuestionMapper.java
  4. 42
      ccic-exam/src/main/java/com/ccic/safeliab/dao/QuestionMapper.java
  5. 30
      ccic-exam/src/main/java/com/ccic/safeliab/service/ExamPaperService.java
  6. 70
      ccic-exam/src/main/java/com/ccic/safeliab/service/ExamPaperServiceImpl.java
  7. 34
      ccic-exam/src/main/java/com/ccic/safeliab/service/PaperQuestionService.java
  8. 51
      ccic-exam/src/main/java/com/ccic/safeliab/service/PaperQuestionServiceImpl.java
  9. 61
      ccic-exam/src/main/java/com/ccic/safeliab/service/QuestionService.java
  10. 87
      ccic-exam/src/main/java/com/ccic/safeliab/service/QuestionServiceImpl.java
  11. 4
      ccic-exam/src/main/java/com/ccic/safeliab/vo/InsExamPaperVO.java
  12. 20
      ccic-exam/src/main/java/com/ccic/safeliab/vo/InsQuestionVO.java
  13. 60
      ccic-exam/src/main/java/com/ccic/safeliab/web/ExamPaperController.java
  14. 88
      ccic-exam/src/main/java/com/ccic/safeliab/web/QuestionController.java
  15. 56
      ccic-exam/src/main/resources/mappers/ExamPaperMapper.xml
  16. 8
      ccic-exam/src/main/resources/mappers/PaperQuestionMapper.xml
  17. 61
      ccic-exam/src/main/resources/mappers/QuestionMapper.xml

@ -40,4 +40,9 @@ public class PaperQuestion extends BaseEntity implements Serializable {
* 题目 ID外键关联题库管理表(ex_question_categories.id)
*/
private Long questionId;
/**
* 题目编号
*/
private Integer questionNumber;
}

@ -43,13 +43,21 @@ public interface ExamPaperMapper extends BaseMapper<ExamPapers> {
@Param("paperName") String paperName);
/**
* 查询当题目详情
* 试卷详情
*
* @param id 监管行业
* @return 题目详情
* @param id ID
* @return 试卷详情
*/
ExamPapers getDetail(@Param("id") Long id);
/**
* 试卷详情(试题)
*
* @param id ID
* @return 试卷详情
*/
List<QuestionCategories> getQuestions(@Param("id") Long id);
/**
* 随机获取题目
*
@ -60,4 +68,5 @@ public interface ExamPaperMapper extends BaseMapper<ExamPapers> {
List<QuestionCategories> getRandomQuestions(
@Param("industryId") Long industryId,
@Param("questionCount") Integer questionCount);
}

@ -0,0 +1,24 @@
package com.ccic.safeliab.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ccic.safeliab.entity.PaperQuestion;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* Mapper 接口
*
* @author Chill
*/
@Mapper
public interface PaperQuestionMapper extends BaseMapper<PaperQuestion> {
/**
* 删除试卷的所有试题
*
* @param id 试卷id
* @return 删除件数
*/
boolean deletePaperALlQuestion(@Param("id") Long id);
}

@ -10,11 +10,6 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Mapper 接口
*
* @author Chill
*/
@Mapper
public interface QuestionMapper extends BaseMapper<QuestionCategories> {
@ -24,13 +19,13 @@ public interface QuestionMapper extends BaseMapper<QuestionCategories> {
QuestionCategories selectQuestionById(Integer questionId);
/**
* 查询当前页数据
* 查询试题
*
* @param industryId 监管行业
* @param serviceTypeId 服务类型
* @param industryId 监管行业
* @param serviceTypeId 服务类型
* @param questionContent 题干条件
* @param offset 偏移量
* @param num 每页显示的记录
* @param offset 偏移量
* @param num 每页数
* @return 当前页数据
*/
List<QuestionCategories> getList(
@ -38,35 +33,37 @@ public interface QuestionMapper extends BaseMapper<QuestionCategories> {
@Param("serviceTypeId") Long serviceTypeId,
@Param("questionContent") String questionContent,
@Param("offset") int offset,
@Param("num") int num);
@Param("num") int num
);
/**
* 查询数量
* 查询试题数量
*
* @param industryId 监管行业
* @param serviceTypeId 服务类型
* @param industryId 监管行业
* @param serviceTypeId 服务类型
* @param questionContent 题干条件
* @return 数量
* @return 试题数量
*/
int getListSize(
@Param("industryId") Long industryId,
@Param("serviceTypeId") Long serviceTypeId,
@Param("questionContent") String questionContent);
@Param("questionContent") String questionContent
);
/**
* 获取行业
* 获取字典数据
*
* @return 行业
* @return 字典数据
*/
List<Industry> getIndustry();
/**
* 查询当题目详情
* 获取试题详情
*
* @param id 监管行业
* @return 详情
* @param id 试题ID
* @return 题详情
*/
QuestionCategories getDetail(@Param("id") Long id);
QuestionCategories getQuestionDetail(@Param("id") Long id);
/**
* 根据试卷id获取题目集合
@ -74,4 +71,5 @@ public interface QuestionMapper extends BaseMapper<QuestionCategories> {
* @return
*/
List<PageQuestionCategoriesVO> getListByPaperId(@Param("paperId") Long id);
}

@ -49,26 +49,12 @@ public interface ExamPaperService extends BaseService<ExamPapers> {
*/
boolean batchUpdatePaperStatus(List<InsExamPaperVO> vos);
/**
* 添加试题
* @param vo 试题 VO 列表
* @return 添加是否成功
*/
int add(List<InsExamPaperVO> vo);
/**
* 修改试题
* @param vo 试题 VO 列表
* @return 添加是否成功
*/
boolean update(InsExamPaperVO vo);
/**
* 获取试卷列表
* @param id 题目ID
* @return 题目详情
*/
ExamPapers getDetail(String id);
Map<String, Object> getDetail(String id);
/**
* 随机获取题目
@ -76,4 +62,18 @@ public interface ExamPaperService extends BaseService<ExamPapers> {
* @return 试卷列表
*/
List<QuestionCategories> getRandomQuestions(ExamPapers entity);
/**
* 添加试卷
* @param vo 试卷
* @return 添加是否成功
*/
ExamPapers add(InsExamPaperVO vo);
/**
* 修改试题
* @param vo 试题 VO 列表
* @return 添加是否成功
*/
ExamPapers update(InsExamPaperVO vo);
}

@ -4,6 +4,7 @@ import com.ccic.safeliab.dao.ExamPaperMapper;
import com.ccic.safeliab.entity.*;
import com.ccic.safeliab.support.BaseServiceImpl;
import com.ccic.safeliab.vo.InsExamPaperVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -13,8 +14,12 @@ import java.util.List;
import java.util.Map;
@Service
@Transactional
public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamPapers> implements ExamPaperService {
@Autowired
private PaperQuestionService paperQuestionService;
@Override
public Map<String, Object> getList(int page,int num, ExamPapers entity) {
int offset = (page - 1) * num;
@ -35,18 +40,33 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamP
@Override
public boolean deleteExamPaperById(Long id) {
boolean flag = false;
List<Long> ids = new ArrayList<>();
ids.add(id);
return deleteLogic(ids);
flag = deleteLogic(ids);
if(flag){
flag = paperQuestionService.delete(id);
}
return flag;
}
@Override
public boolean deleteExamPaperListByIds(List<Long> ids) {
return deleteLogic(ids);
boolean flag = false;
flag = deleteLogic(ids);
if(flag){
for(Long id : ids){
flag = paperQuestionService.delete(id);
if(!flag){
break;
}
}
}
return flag;
}
@Override
@Transactional
public boolean updatePaperStatus(InsExamPaperVO vo) {
ExamPapers entity = baseMapper.getDetail(vo.getId());
if(vo.getPaperStatus()==0){
@ -58,7 +78,6 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamP
}
@Override
@Transactional
public boolean batchUpdatePaperStatus(List<InsExamPaperVO> vos) {
boolean flag = false;
for(InsExamPaperVO vo : vos){
@ -68,22 +87,49 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamP
}
@Override
public int add(List<InsExamPaperVO> vo) {
return 0;
public Map<String, Object> getDetail(String id){
Map<String, Object> map = new HashMap<>();
ExamPapers head = baseMapper.getDetail(Long.valueOf(id));
List<QuestionCategories> detail = baseMapper.getQuestions(Long.valueOf(id));
map.put("head", head);
map.put("data", detail);
return map;
}
@Override
public boolean update(InsExamPaperVO vo) {
return true;
public List<QuestionCategories> getRandomQuestions(ExamPapers entity) {
return baseMapper.getRandomQuestions(entity.getIndustryId(), entity.getQuestionCount());
}
@Override
public ExamPapers getDetail(String id){
return baseMapper.getDetail(Long.valueOf(id));
public ExamPapers add(InsExamPaperVO vo){
// 试卷
ExamPapers examPapers = new ExamPapers();
examPapers.setPaperName(vo.getPaperName());
examPapers.setIndustryId(vo.getIndustryId());
examPapers.setQuestionCount(vo.getQuestionCount());
examPapers.setTotalScore(vo.getTotalScore());
examPapers.setExamDuration(vo.getExamDuration());
examPapers.setDurationType(vo.getDurationType());
examPapers.setPaperContent(vo.getPaperContent());
examPapers.setPaperStatus(1);
save(examPapers);
return examPapers;
}
@Override
public List<QuestionCategories> getRandomQuestions(ExamPapers entity) {
return baseMapper.getRandomQuestions(entity.getIndustryId(), entity.getQuestionCount());
public ExamPapers update(InsExamPaperVO vo) {
// 试卷
ExamPapers examPapers = new ExamPapers();
examPapers.setId(vo.getId());
examPapers.setPaperName(vo.getPaperName());
examPapers.setIndustryId(vo.getIndustryId());
examPapers.setQuestionCount(vo.getQuestionCount());
examPapers.setTotalScore(vo.getTotalScore());
examPapers.setExamDuration(vo.getExamDuration());
examPapers.setDurationType(vo.getDurationType());
examPapers.setPaperContent(vo.getPaperContent());
updateById(examPapers);
return examPapers;
}
}

@ -0,0 +1,34 @@
package com.ccic.safeliab.service;
import com.ccic.safeliab.entity.PaperQuestion;
import com.ccic.safeliab.support.BaseService;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public interface PaperQuestionService extends BaseService<PaperQuestion> {
/**
* 添加试卷试题关系
* @param paperID 试卷ID
* @param QuestionIds 题目ID集合
* @return 添加是否成功
*/
int add(Long paperID, List<String> QuestionIds);
/**
* 删除试卷试题关系
* @param paperID 试卷ID
* @return 添加是否成功
*/
boolean delete(Long paperID);
/**
* 更新试卷试题关系
* @param paperID 试卷ID
* @param QuestionIds 题目ID集合
* @return 添加是否成功
*/
int update(Long paperID, List<String> QuestionIds);
}

@ -0,0 +1,51 @@
package com.ccic.safeliab.service;
import com.ccic.safeliab.dao.PaperQuestionMapper;
import com.ccic.safeliab.entity.*;
import com.ccic.safeliab.support.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional
public class PaperQuestionServiceImpl extends BaseServiceImpl<PaperQuestionMapper, PaperQuestion> implements PaperQuestionService {
@Override
public int add(Long paperID, List<String> QuestionIds){
int number = 0;
for(String QuestionId : QuestionIds){
number++;
PaperQuestion paperQuestion = new PaperQuestion();
paperQuestion.setPaperId(paperID);
paperQuestion.setQuestionId(Long.valueOf(QuestionId));
paperQuestion.setQuestionNumber(number);
save(paperQuestion);
}
return number;
}
@Override
public boolean delete(Long paperID){
return baseMapper.deletePaperALlQuestion(paperID);
}
@Override
public int update(Long paperID, List<String> QuestionIds){
baseMapper.deletePaperALlQuestion(paperID);
int number = 0;
for(String QuestionId : QuestionIds){
number++;
PaperQuestion paperQuestion = new PaperQuestion();
paperQuestion.setPaperId(paperID);
paperQuestion.setQuestionId(Long.valueOf(QuestionId));
paperQuestion.setQuestionNumber(number);
save(paperQuestion);
}
return number;
}
}

@ -11,54 +11,53 @@ import java.util.Map;
@Service
public interface QuestionService extends BaseService<QuestionCategories> {
/**
* 获取题库列表
* @param page 页码
* @param num 每页数量
* @param entity 题库表
* @return 题库列表
*/
Map<String, Object> getList(int page, int num, QuestionCategories entity);
/**
* 根据主键删除题库记录
* @param id 题库记录的主键
* @return 删除操作是否成功
* 查询试题
*
* @param page 页码
* @param num 数量
* @param entity 题库entity
* @return 查询结果
*/
boolean deleteQuestionById(Long id);
Map<String, Object> getList(int page, int num, QuestionCategories entity);
/**
* 根据主键批量删除题库记录
* @param ids 题库记录的主键列表
* @return 删除操作是否成功
* 删除试题
*
* @param ids 试题ID
* @return 删除结果
*/
boolean deleteQuestionListByIds(List<Long> ids);
boolean delQuestion(List<Long> ids);
/**
* 添加试题
* @param vo 试题 VO 列表
* @return 添加是否成功
*
* @param vo 试题vo
* @return 添加结果
*/
int add(List<InsQuestionVO> vo);
boolean addQuestion(List<InsQuestionVO> vo);
/**
* 修改试题
* @param vo 试题 VO 列表
* @return 添加是否成功
*
* @param vo 试题vo
* @return 修改结果
*/
boolean update(InsQuestionVO vo);
boolean editQuestion(InsQuestionVO vo);
/**
* 获取行业
* @return 行业
* 获取试题详情
*
* @param id 试题ID
* @return 试题详情
*/
List<Industry> getDictionary();
QuestionCategories getQuestionDetail(String id);
/**
* 获取题库列表
* @param id 题目ID
* @return 题目详情
* 监管行业字典
*
* @return 字典数据
*/
QuestionCategories getDetail(String id);
}
List<Industry> findDictionary();
}

@ -7,82 +7,75 @@ import com.ccic.safeliab.vo.InsQuestionVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Transactional
public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, QuestionCategories> implements QuestionService {
@Override
public Map<String, Object> getList(int page,int num, QuestionCategories entity) {
public Map<String, Object> getList(int page, int num, QuestionCategories entity) {
int offset = (page - 1) * num;
Map<String, Object> map = new HashMap<>();
List<QuestionCategories> data = baseMapper.getList(
entity.getIndustryId(),
entity.getServiceTypeId(),
entity.getQuestionContent(),
offset,
num);
num
);
int total = baseMapper.getListSize(
int total = baseMapper.getListSize(
entity.getIndustryId(),
entity.getServiceTypeId(),
entity.getQuestionContent());
entity.getQuestionContent()
);
map.put("data", data);
map.put("total", total);
return map;
}
@Override
public boolean deleteQuestionById(Long id) {
List<Long> ids = new ArrayList<>();
ids.add(id);
return deleteLogic(ids);
return map;
}
@Override
public boolean deleteQuestionListByIds(List<Long> ids) {
public boolean delQuestion(List<Long> ids) {
return deleteLogic(ids);
}
@Override
@Transactional
public int add(List<InsQuestionVO> vo) {
int count =0;
for(InsQuestionVO item :vo){
public boolean addQuestion(List<InsQuestionVO> vo) {
int count = 0;
for (InsQuestionVO item : vo) {
save(convertToEntity(item));
count ++;
count++;
}
return count;
return count > 0;
}
@Override
@Transactional
public boolean update(InsQuestionVO vo) {
public boolean editQuestion(InsQuestionVO vo) {
return updateById(convertToEntity(vo));
}
@Override
public List<Industry> getDictionary() {
return baseMapper.getIndustry();
public QuestionCategories getQuestionDetail(String id) {
return baseMapper.getQuestionDetail(Long.valueOf(id));
}
@Override
public QuestionCategories getDetail(String id){
return baseMapper.getDetail(Long.valueOf(id));
public List<Industry> findDictionary() {
return baseMapper.getIndustry();
}
/**
* VO 转换为实体类
* @param vo 试题 VO
* @return 试题实体类
* 将VO转换为Entity
*/
private QuestionCategories convertToEntity(InsQuestionVO vo) {
QuestionCategories entity = new QuestionCategories();
// 赋值从父类继承的属性
entity.setId(vo.getId());
entity.setQuestionTypes(vo.getQuestionTypes());
entity.setIndustryId(vo.getIndustryId());
@ -90,25 +83,23 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
entity.setQuestionContent(vo.getQuestionContent());
entity.setAnswer(vo.getAnswer());
// 处理答题选项,拼接成字符串
InsQuestionVO.AnswerOptions answerOptions = vo.getAnswerOptions();
if (answerOptions != null) {
StringBuilder optionsBuilder = new StringBuilder();
if (answerOptions.A != null) {
optionsBuilder.append("A:").append(answerOptions.A).append(",");
}
if (answerOptions.B != null) {
optionsBuilder.append("B:").append(answerOptions.B).append(",");
}
if (answerOptions.C != null) {
optionsBuilder.append("C:").append(answerOptions.C).append(",");
}
if (answerOptions.D != null) {
optionsBuilder.append("D:").append(answerOptions.D);
}
String options = optionsBuilder.toString();
entity.setOptions(options);
StringBuilder optionsBuilder = new StringBuilder();
if (vo.getOptionA()!= null) {
optionsBuilder.append("A:").append(vo.getOptionA()).append(",");
}
if (vo.getOptionB()!= null) {
optionsBuilder.append("B:").append(vo.getOptionB()).append(",");
}
if (vo.getOptionC()!= null) {
optionsBuilder.append("C:").append(vo.getOptionC()).append(",");
}
if (vo.getOptionD()!= null) {
optionsBuilder.append("D:").append(vo.getOptionD());
}
String options = optionsBuilder.toString();
entity.setOptions(options);
return entity;
}
}
}

@ -4,6 +4,8 @@ import com.ccic.safeliab.entity.ExamPapers;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* 值对象VO用于在不同层之间传递题目相关数据
* 该类的属性与数据库中题目表的字段相对应以满足数据传输需求
@ -15,6 +17,8 @@ public class InsExamPaperVO extends ExamPapers {
private int num;
// 页码
private int page;
// 试题ID
List<String> questionIds;
}

@ -5,8 +5,7 @@ import lombok.Getter;
import lombok.Setter;
/**
* 值对象VO用于在不同层之间传递题目相关数据
* 该类的属性与数据库中题目表的字段相对应以满足数据传输需求
* vo 试题vo
*/
@Getter
@Setter
@ -15,15 +14,14 @@ public class InsQuestionVO extends QuestionCategories {
private int num;
// 页码
private int page;
// 答案
AnswerOptions answerOptions;
public static class AnswerOptions {
public String A;
public String B;
public String C;
public String D;
}
// 答案A
public String optionA;
// 答案B
public String optionB;
// 答案C
public String optionC;
// 答案D
public String optionD;
}

@ -3,6 +3,7 @@ package com.ccic.safeliab.web;
import com.ccic.safeliab.entity.ExamPapers;
import com.ccic.safeliab.entity.QuestionCategories;
import com.ccic.safeliab.service.ExamPaperService;
import com.ccic.safeliab.service.PaperQuestionService;
import com.ccic.safeliab.util.R;
import com.ccic.safeliab.vo.InsExamPaperVO;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,6 +19,9 @@ public class ExamPaperController {
@Autowired
private ExamPaperService examPaperService;
@Autowired
private PaperQuestionService paperQuestionService;
/**
* 获取试卷
* @param vo 试卷对象VO
@ -37,8 +41,8 @@ public class ExamPaperController {
*/
@GetMapping("/delete")
public R delete(String id) {
boolean resultFlg = examPaperService.deleteExamPaperById(Long.valueOf((id)));
return R.ok().data(resultFlg);
boolean flag = examPaperService.deleteExamPaperById(Long.valueOf((id)));
return R.ok().data(flag);
}
/**
@ -46,8 +50,8 @@ public class ExamPaperController {
*/
@PostMapping("/deleteList")
public R deleteList(@RequestBody List<Long> ids) {
boolean resultFlg = examPaperService.deleteExamPaperListByIds(ids);
return R.ok().data(resultFlg);
boolean flag = examPaperService.deleteExamPaperListByIds(ids);
return R.ok().data(flag);
}
/**
@ -69,41 +73,43 @@ public class ExamPaperController {
}
/**
* 添加试卷
* 随机获取试题
* @param vo 题库对象VO
* @return 查询结果
*/
@PostMapping("/add")
public R add(@RequestBody List<InsExamPaperVO> vo) {
return R.ok().data(examPaperService.add(vo));
@PostMapping("/getRandomQuestions")
public R getRandomQuestions(@RequestBody InsExamPaperVO vo) {
ExamPapers entity = new ExamPapers();
entity.setIndustryId(vo.getIndustryId());
entity.setQuestionCount(vo.getQuestionCount());
List<QuestionCategories> data = examPaperService.getRandomQuestions(entity);
return R.ok().data(data);
}
/**
* 修改试卷
* 试卷详情
*/
@PostMapping("/update")
public R add(@RequestBody InsExamPaperVO vo) {
return R.ok().data(examPaperService.update(vo));
@GetMapping("/getDetail")
public R getDetail(String id) {
Map<String, Object> data = examPaperService.getDetail(id);
return R.ok().data(data);
}
/**
* 题目详情
* 添加试卷
*/
@GetMapping("/getDetail")
public R getDetail(String id) {
ExamPapers data = examPaperService.getDetail(id);
return R.ok().data(data);
@PostMapping("/add")
public R add(@RequestBody InsExamPaperVO vo) {
ExamPapers examPapers = examPaperService.add(vo);
return R.ok().data(paperQuestionService.add(examPapers.getId(), vo.getQuestionIds()));
}
/**
* 随机获取试题
* @param vo 题库对象VO
* @return 查询结果
* 修改试卷
*/
@PostMapping("/getRandomQuestions")
public R getRandomQuestions(@RequestBody InsExamPaperVO vo) {
ExamPapers entity = new ExamPapers();
entity.setIndustryId(vo.getIndustryId());
entity.setQuestionCount(vo.getQuestionCount());
List<QuestionCategories> data = examPaperService.getRandomQuestions(entity);
return R.ok().data(data);
@PostMapping("/update")
public R update(@RequestBody InsExamPaperVO vo) {
ExamPapers examPapers =examPaperService.update(vo);
return R.ok().data(paperQuestionService.update(examPapers.getId(), vo.getQuestionIds()));
}
}

@ -19,12 +19,12 @@ public class QuestionController {
private QuestionService questionService;
/**
* 获取题库
* @param vo 题库对象VO
* 查询试题
* @param vo 试题vo
* @return 查询结果
*/
@PostMapping("/list")
public R list(@RequestBody InsQuestionVO vo) {
@PostMapping("/getList")
public R getList(@RequestBody InsQuestionVO vo) {
QuestionCategories entity = new QuestionCategories();
entity.setIndustryId(vo.getIndustryId());
entity.setServiceTypeId(vo.getServiceTypeId());
@ -34,64 +34,68 @@ public class QuestionController {
}
/**
* 删除单个试题
* 删除试题
* @param ids 试题ID
* @return 删除结果
*/
@GetMapping("/delete")
public R delete(String id) {
boolean resultFlg = questionService.deleteQuestionById(Long.valueOf((id)));
return R.ok().data(resultFlg);
}
/**
* 删除多个试题
*/
@PostMapping("/deleteList")
public R deleteList(@RequestBody List<Long> ids) {
boolean resultFlg = questionService.deleteQuestionListByIds(ids);
return R.ok().data(resultFlg);
@PostMapping("/delQuestion")
public R delQuestion(@RequestBody List<Long> ids) {
boolean flag = questionService.delQuestion(ids);
if (flag) {
return R.ok();
} else {
return R.error();
}
}
/**
* 添加试题
* @param vo 试题vo
* @return 添加结果
*/
@PostMapping("/add")
public R add(@RequestBody List<InsQuestionVO> vo) {
return R.ok().data(questionService.add(vo));
@PostMapping("/addQuestion")
public R addQuestion(@RequestBody List<InsQuestionVO> vo) {
boolean flag = questionService.addQuestion(vo);
if (flag) {
return R.ok();
} else {
return R.error();
}
}
/**
* 修改试题
* @param vo 试题vo
* @return 修改结果
*/
@PostMapping("/update")
public R add(@RequestBody InsQuestionVO vo) {
return R.ok().data(questionService.update(vo));
@PostMapping("/editQuestion")
public R editQuestion(@RequestBody InsQuestionVO vo) {
boolean flag = questionService.editQuestion(vo);
if (flag) {
return R.ok();
} else {
return R.error();
}
}
/**
* 更新试题
* 获取试题详情
* @param id 试题ID
* @return 试题详情
*/
@GetMapping("/update")
public boolean update(@RequestParam InsQuestionVO vo) {
// return questionService.updateQuestion(add);
return true;
@GetMapping("/getQuestionDetail")
public R getQuestionDetail(String id) {
QuestionCategories data = questionService.getQuestionDetail(id);
return R.ok().data(data);
}
/**
* 行业查询
* @return 行业
* 查询字典数据
* @return 字典数据
*/
@GetMapping("/findIndustry")
public R findIndustry() {
List<Industry> tree = questionService.getDictionary();
List<Industry> tree = questionService.findDictionary();
return R.ok().data(tree);
}
/**
* 题目详情
*/
@GetMapping("/getDetail")
public R getDetail(String id) {
QuestionCategories data = questionService.getDetail(id);
return R.ok().data(data);
}
}
}

@ -60,6 +60,25 @@
</if>
</where>
</select>
<select id="getRandomQuestions" resultMap="QuestionCategoriesResultMap">
SELECT
id,
question_types,
industry_id,
service_type_id,
question_content,
answer,
options
FROM ex_question_categories
<where>
is_deleted = '0'
<if test="industryId!= null and industryId!= ''">
AND industry_id = #{industryId}
</if>
</where>
ORDER BY RANDOM()
LIMIT #{questionCount};
</select>
<select id="getDetail" resultMap="ExamPapersResultMap">
SELECT
id
@ -79,23 +98,32 @@
</if>
</where>
</select>
<select id="getRandomQuestions" resultMap="QuestionCategoriesResultMap">
<select id="getQuestions" resultMap="QuestionCategoriesResultMap">
SELECT
id,
question_types,
industry_id,
service_type_id,
question_content,
answer,
options
FROM ex_question_categories
qc.id
, qc.question_types
, qc.industry_id
, qc.service_type_id
, qc.question_content
, qc.answer
, qc.options
FROM
ex_exam_papers ep
inner join ex_paper_questions pq
on pq.paper_id = ep.id
and pq.is_deleted = 0
inner join ex_question_categories qc
on qc.id = pq.question_id
and qc.is_deleted = 0
<where>
is_deleted = '0'
<if test="industryId!= null and industryId!= ''">
AND industry_id = #{industryId}
ep.is_deleted = '0'
<if test="id!= null and id!= ''">
AND ep.id = #{id}
</if>
</where>
ORDER BY RANDOM()
LIMIT #{questionCount};
</select>
<delete id="deletePaperALlQuestion">
DELETE FROM ex_paper_questions
WHERE paper_id = #{id}
</delete>
</mapper>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ccic.safeliab.dao.PaperQuestionMapper">
<delete id="deletePaperALlQuestion">
DELETE FROM ex_paper_questions
WHERE paper_id = #{id}
</delete>
</mapper>

@ -1,22 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ccic.safeliab.dao.QuestionMapper">
<!-- 通用查询映射结果 -->
<resultMap id="IndustryResultMap" type="com.ccic.safeliab.entity.Industry">
<id column="industry_id" property="industryId"/>
<result column="industry_name" property="industryName"/>
<id column="industry_id" property="industryId" />
<result column="industry_name" property="industryName" />
</resultMap>
<resultMap id="QuestionCategoriesResultMap" type="com.ccic.safeliab.entity.QuestionCategories">
<id column="id" property="id"/>
<result column="question_types" property="questionTypes"/>
<result column="industry_id" property="industryId"/>
<result column="service_type_id" property="serviceTypeId"/>
<result column="question_content" property="questionContent"/>
<result column="answer" property="answer"/>
<result column="options" property="options"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<id column="id" property="id" />
<result column="question_types" property="questionTypes" />
<result column="industry_id" property="industryId" />
<result column="service_type_id" property="serviceTypeId" />
<result column="question_content" property="questionContent" />
<result column="answer" property="answer" />
<result column="options" property="options" />
<result column="status" property="status" />
<result column="is_deleted" property="isDeleted" />
</resultMap>
<resultMap id="PaperQuestionCategoriesMap" type="com.ccic.safeliab.vo.PageQuestionCategoriesVO">
<id column="id" property="id"/>
<result column="question_types" property="questionTypes"/>
@ -55,6 +58,7 @@
ORDER BY id DESC
LIMIT #{offset}, #{num};
</select>
<select id="getListSize" resultType="int">
SELECT
COUNT(id)
@ -72,14 +76,16 @@
</if>
</where>
</select>
<select id="getIndustry" resultMap="IndustryResultMap">
select
industry_id,
industry_name
from tbl_industry
where status = 1
SELECT
industry_id,
industry_name
FROM tbl_industry
WHERE status = 1
</select>
<select id="getDetail" resultMap="QuestionCategoriesResultMap">
<select id="getQuestionDetail" resultMap="QuestionCategoriesResultMap">
SELECT
id,
question_types,
@ -98,17 +104,18 @@
</if>
</where>
</select>
<select id="getListByPaperId" resultMap="PaperQuestionCategoriesMap">
SELECT
a.id,
a.question_types,
a.industry_id,
a.service_type_id,
a.question_content,
a.answer,
a.options,
a.status,
b.question_number
a.id,
a.question_types,
a.industry_id,
a.service_type_id,
a.question_content,
a.answer,
a.options,
a.status,
b.question_number
FROM ex_question_categories a
LEFT JOIN ex_paper_questions b ON b.question_id = a.id AND b.is_deleted = '0'
<where>
@ -119,4 +126,4 @@
</where>
ORDER BY b.question_number asc
</select>
</mapper>
</mapper>
Loading…
Cancel
Save