| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.common.utils.arg; |
| | | import org.springblade.modules.exam.entity.ExamSubjectChoices; |
| | | import org.springblade.modules.exam.entity.ExamSubjectOption; |
| | | import org.springblade.modules.exam.mapper.ExamSubjectChoicesMapper; |
| | | import org.springblade.modules.exam.service.ExamSubjectChoicesService; |
| | | import org.springblade.modules.exam.service.ExamSubjectOptionService; |
| | | import org.springblade.modules.exam.vo.ExamSubjectChoicesVO; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 选择题服务实现类 |
| | | * @author zhongrj |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class ExamSubjectChoicesServiceImpl extends ServiceImpl<ExamSubjectChoicesMapper, ExamSubjectChoices> implements ExamSubjectChoicesService { |
| | | |
| | | private final ExamSubjectOptionService examSubjectOptionService; |
| | | |
| | | @Override |
| | | public IPage<ExamSubjectChoicesVO> selectExamSubjectChoicesPage(IPage<ExamSubjectChoicesVO> page, ExamSubjectChoicesVO examSubjectChoices) { |
| | |
| | | public ExamSubjectChoicesVO selectExamSubjectChoicesInfo(ExamSubjectChoices examSubjectChoices) { |
| | | return baseMapper.selectExamSubjectChoicesInfo(examSubjectChoices); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateChoicesValue(String id, String value) { |
| | | return baseMapper.updateChoicesValue(id,value); |
| | | } |
| | | |
| | | /** |
| | | * 新增题目及选项信息 |
| | | * @param examSubjectChoices 题目信息对象 |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveSubjectChoicesAndOption(ExamSubjectChoicesVO examSubjectChoices) { |
| | | boolean status = false; |
| | | //新增 |
| | | if (null == examSubjectChoices.getId()) { |
| | | ExamSubjectChoices subjectChoices = new ExamSubjectChoices(); |
| | | subjectChoices.setCreateDate(new Date()); |
| | | subjectChoices.setDelFlag(0); |
| | | subjectChoices.setAnswer(examSubjectChoices.getAnswer()); |
| | | if (null != examSubjectChoices.getAnalysis() && examSubjectChoices.getAnalysis() != "") { |
| | | subjectChoices.setAnalysis(examSubjectChoices.getAnalysis()); |
| | | } |
| | | subjectChoices.setCreator(examSubjectChoices.getCreator()); |
| | | subjectChoices.setChoicesType(examSubjectChoices.getChoicesType()); |
| | | subjectChoices.setSubjectName(examSubjectChoices.getSubjectName()); |
| | | subjectChoices.setScore(examSubjectChoices.getScore()); |
| | | subjectChoices.setTktype(examSubjectChoices.getTktype()); |
| | | //题目新增 |
| | | status = this.save(subjectChoices); |
| | | //判断类型,单选,多选,实操 |
| | | if (examSubjectChoices.getChoicesType() == 0 || examSubjectChoices.getChoicesType() == 1 || examSubjectChoices.getChoicesType() == 3) { |
| | | //选项新增 |
| | | List<ExamSubjectOption> examSubjectOptions = examSubjectChoices.getExamSubjectOptions(); |
| | | examSubjectOptions.forEach(examSubjectOption -> { |
| | | examSubjectOption.setSubjectChoicesId(subjectChoices.getId()); |
| | | examSubjectOption.setCreateDate(new Date()); |
| | | examSubjectOption.setDelFlag(0); |
| | | //新增 |
| | | examSubjectOptionService.save(examSubjectOption); |
| | | }); |
| | | return true; |
| | | } |
| | | //内网数据同步 |
| | | try { |
| | | // arg.test01(arg.url+"/examSubjectChoices/saveSubjectChoicesAndOption",examSubjectChoices); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }else { |
| | | //修改 |
| | | ExamSubjectChoices subjectChoices = new ExamSubjectChoices(); |
| | | subjectChoices.setId(examSubjectChoices.getId()); |
| | | subjectChoices.setModifyDate(new Date()); |
| | | subjectChoices.setAnswer(examSubjectChoices.getAnswer()); |
| | | if (null != examSubjectChoices.getAnalysis() && examSubjectChoices.getAnalysis() != "") { |
| | | subjectChoices.setAnalysis(examSubjectChoices.getAnalysis()); |
| | | } |
| | | subjectChoices.setModifier(examSubjectChoices.getCreator()); |
| | | subjectChoices.setChoicesType(examSubjectChoices.getChoicesType()); |
| | | subjectChoices.setSubjectName(examSubjectChoices.getSubjectName()); |
| | | subjectChoices.setScore(examSubjectChoices.getScore()); |
| | | subjectChoices.setTktype(examSubjectChoices.getTktype()); |
| | | //题目修改 |
| | | status = this.updateById(subjectChoices); |
| | | //判断类型,单选,多选 |
| | | if (examSubjectChoices.getChoicesType() == 0 || examSubjectChoices.getChoicesType() == 1) { |
| | | //选项修改 |
| | | List<ExamSubjectOption> examSubjectOptions = examSubjectChoices.getExamSubjectOptions(); |
| | | examSubjectOptions.forEach(examSubjectOption -> { |
| | | examSubjectOption.setSubjectChoicesId(subjectChoices.getId()); |
| | | examSubjectOption.setModifyDate(new Date()); |
| | | examSubjectOption.setModifier(examSubjectChoices.getCreator()); |
| | | //修改 |
| | | examSubjectOptionService.updateById(examSubjectOption); |
| | | }); |
| | | return true; |
| | | } |
| | | //实操 |
| | | if (examSubjectChoices.getChoicesType() == 3) { |
| | | //先将选项删除 |
| | | baseMapper.removeBySubjectId(examSubjectChoices.getId()); |
| | | //选项新增 |
| | | List<ExamSubjectOption> examSubjectOptions = examSubjectChoices.getExamSubjectOptions(); |
| | | examSubjectOptions.forEach(examSubjectOption -> { |
| | | examSubjectOption.setSubjectChoicesId(subjectChoices.getId()); |
| | | examSubjectOption.setCreateDate(new Date()); |
| | | examSubjectOption.setDelFlag(0); |
| | | //新增 |
| | | examSubjectOptionService.save(examSubjectOption); |
| | | }); |
| | | return true; |
| | | } |
| | | //内网数据同步 |
| | | try { |
| | | // arg.test01(arg.url+"/examSubjectChoices/saveSubjectChoicesAndOption",examSubjectChoices); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return status; |
| | | } |
| | | } |