| | |
| | | |
| | | 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 boolean updateChoicesValue(String id, String value) { |
| | | return baseMapper.updateChoicesValue(id,value); |
| | | } |
| | | |
| | | /** |
| | | * 新增题目及选项信息 |
| | | * @param examSubjectChoices 题目信息对象 |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveSubjectChoicesAndOption(ExamSubjectChoicesVO examSubjectChoices) { |
| | | 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()); |
| | | //题目新增 |
| | | boolean 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(); |
| | | } |
| | | return status; |
| | | } |
| | | } |