|
@@ -7,18 +7,27 @@ import com.zhongzheng.common.utils.ServletUtils;
|
|
|
import com.zhongzheng.modules.bank.bo.ExamAddBo;
|
|
import com.zhongzheng.modules.bank.bo.ExamAddBo;
|
|
|
import com.zhongzheng.modules.bank.bo.ExamEditBo;
|
|
import com.zhongzheng.modules.bank.bo.ExamEditBo;
|
|
|
import com.zhongzheng.modules.bank.bo.ExamQueryBo;
|
|
import com.zhongzheng.modules.bank.bo.ExamQueryBo;
|
|
|
|
|
+import com.zhongzheng.modules.bank.bo.ExamQuestionAddBo;
|
|
|
import com.zhongzheng.modules.bank.domain.Exam;
|
|
import com.zhongzheng.modules.bank.domain.Exam;
|
|
|
|
|
+import com.zhongzheng.modules.bank.domain.ExamQuestion;
|
|
|
import com.zhongzheng.modules.bank.mapper.ExamMapper;
|
|
import com.zhongzheng.modules.bank.mapper.ExamMapper;
|
|
|
|
|
+import com.zhongzheng.modules.bank.service.IExamQuestionService;
|
|
|
import com.zhongzheng.modules.bank.service.IExamService;
|
|
import com.zhongzheng.modules.bank.service.IExamService;
|
|
|
import com.zhongzheng.modules.bank.vo.ExamVo;
|
|
import com.zhongzheng.modules.bank.vo.ExamVo;
|
|
|
|
|
+import com.zhongzheng.modules.course.bo.CourseChapterSectionListAddBo;
|
|
|
|
|
+import com.zhongzheng.modules.course.domain.CourseChapterSection;
|
|
|
|
|
+import com.zhongzheng.modules.course.service.ICourseChapterBusinessService;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -31,6 +40,9 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
@Service
|
|
|
public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IExamService {
|
|
public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IExamService {
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IExamQuestionService iExamQuestionService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public ExamVo queryById(Long examId){
|
|
public ExamVo queryById(Long examId){
|
|
|
Exam db = this.baseMapper.selectById(examId);
|
|
Exam db = this.baseMapper.selectById(examId);
|
|
@@ -77,20 +89,50 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean insertByAddBo(ExamAddBo bo) {
|
|
public Boolean insertByAddBo(ExamAddBo bo) {
|
|
|
Exam add = BeanUtil.toBean(bo, Exam.class);
|
|
Exam add = BeanUtil.toBean(bo, Exam.class);
|
|
|
add.setCode(ServletUtils.getEncoded("SJ"));
|
|
add.setCode(ServletUtils.getEncoded("SJ"));
|
|
|
validEntityBeforeSave(add);
|
|
validEntityBeforeSave(add);
|
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
|
- return this.save(add);
|
|
|
|
|
|
|
+ boolean result = this.save(add);
|
|
|
|
|
+ if(bo.getQuestionList()!=null){
|
|
|
|
|
+ Collection<ExamQuestion> coll = new HashSet<>();
|
|
|
|
|
+ for(int i=0;i<bo.getQuestionList().size();i++){
|
|
|
|
|
+ ExamQuestionAddBo item = bo.getQuestionList().get(i);
|
|
|
|
|
+ ExamQuestion addItem = new ExamQuestion();
|
|
|
|
|
+ addItem.setExamId(add.getExamId());
|
|
|
|
|
+ addItem.setQuestionId(item.getQuestionId());
|
|
|
|
|
+ addItem.setSort(item.getSort());
|
|
|
|
|
+ coll.add(addItem);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ iExamQuestionService.saveBatch(coll);
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean updateByEditBo(ExamEditBo bo) {
|
|
public Boolean updateByEditBo(ExamEditBo bo) {
|
|
|
Exam update = BeanUtil.toBean(bo, Exam.class);
|
|
Exam update = BeanUtil.toBean(bo, Exam.class);
|
|
|
validEntityBeforeSave(update);
|
|
validEntityBeforeSave(update);
|
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ if(bo.getQuestionList()!=null){
|
|
|
|
|
+ Collection<ExamQuestion> coll = new HashSet<>();
|
|
|
|
|
+ iExamQuestionService.remove(new LambdaQueryWrapper<ExamQuestion>().eq(ExamQuestion::getExamId, bo.getExamId()));
|
|
|
|
|
+ for(int i=0;i<bo.getQuestionList().size();i++){
|
|
|
|
|
+ ExamQuestionAddBo item = bo.getQuestionList().get(i);
|
|
|
|
|
+ ExamQuestion addItem = new ExamQuestion();
|
|
|
|
|
+ addItem.setExamId(update.getExamId());
|
|
|
|
|
+ addItem.setQuestionId(item.getQuestionId());
|
|
|
|
|
+ addItem.setSort(item.getSort());
|
|
|
|
|
+ coll.add(addItem);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ iExamQuestionService.saveBatch(coll);
|
|
|
|
|
+ }
|
|
|
return this.updateById(update);
|
|
return this.updateById(update);
|
|
|
}
|
|
}
|
|
|
|
|
|