|
@@ -0,0 +1,109 @@
|
|
|
+package com.zhongzheng.modules.exam.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.modules.course.domain.CourseChapterBusiness;
|
|
|
+import com.zhongzheng.modules.course.domain.CourseChapterSection;
|
|
|
+import com.zhongzheng.modules.exam.bo.ExamBeforeApplyAddBo;
|
|
|
+import com.zhongzheng.modules.exam.bo.ExamBeforeApplyEditBo;
|
|
|
+import com.zhongzheng.modules.exam.bo.ExamBeforeApplyQueryBo;
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamBeforeApply;
|
|
|
+import com.zhongzheng.modules.exam.mapper.ExamBeforeApplyMapper;
|
|
|
+import com.zhongzheng.modules.exam.service.IExamBeforeApplyService;
|
|
|
+import com.zhongzheng.modules.exam.vo.ExamBeforeApplyVo;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 前培绑定考试计划Service业务层处理
|
|
|
+ *
|
|
|
+ * @author hjl
|
|
|
+ * @date 2022-05-19
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ExamBeforeApplyServiceImpl extends ServiceImpl<ExamBeforeApplyMapper, ExamBeforeApply> implements IExamBeforeApplyService {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ExamBeforeApplyVo queryById(Long id){
|
|
|
+ ExamBeforeApply db = this.baseMapper.selectById(id);
|
|
|
+ return BeanUtil.toBean(db, ExamBeforeApplyVo.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExamBeforeApplyVo> queryList(ExamBeforeApplyQueryBo bo) {
|
|
|
+ LambdaQueryWrapper<ExamBeforeApply> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(bo.getBeforeId() != null, ExamBeforeApply::getBeforeId, bo.getBeforeId());
|
|
|
+ lqw.eq(bo.getApplyId() != null, ExamBeforeApply::getApplyId, bo.getApplyId());
|
|
|
+ return entity2Vo(this.list(lqw));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 实体类转化成视图对象
|
|
|
+ *
|
|
|
+ * @param collection 实体类集合
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<ExamBeforeApplyVo> entity2Vo(Collection<ExamBeforeApply> collection) {
|
|
|
+ List<ExamBeforeApplyVo> voList = collection.stream()
|
|
|
+ .map(any -> BeanUtil.toBean(any, ExamBeforeApplyVo.class))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (collection instanceof Page) {
|
|
|
+ Page<ExamBeforeApply> page = (Page<ExamBeforeApply>)collection;
|
|
|
+ Page<ExamBeforeApplyVo> pageVo = new Page<>();
|
|
|
+ BeanUtil.copyProperties(page,pageVo);
|
|
|
+ pageVo.addAll(voList);
|
|
|
+ voList = pageVo;
|
|
|
+ }
|
|
|
+ return voList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean insertByAddBo(ExamBeforeApplyAddBo bo) {
|
|
|
+ remove(new LambdaQueryWrapper<ExamBeforeApply>().eq(ExamBeforeApply::getBeforeId, bo.getBeforeId()));
|
|
|
+ Collection<ExamBeforeApply> coll = new HashSet<>();
|
|
|
+ for(Long applyId : bo.getApplyIds()){
|
|
|
+ ExamBeforeApply add = new ExamBeforeApply();
|
|
|
+ add.setBeforeId(bo.getBeforeId());
|
|
|
+ add.setApplyId(applyId);
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ coll.add(add);
|
|
|
+ }
|
|
|
+ return saveBatch(coll);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean updateByEditBo(ExamBeforeApplyEditBo bo) {
|
|
|
+ ExamBeforeApply update = BeanUtil.toBean(bo, ExamBeforeApply.class);
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ update.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return this.updateById(update);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存前的数据校验
|
|
|
+ *
|
|
|
+ * @param entity 实体类数据
|
|
|
+ */
|
|
|
+ private void validEntityBeforeSave(ExamBeforeApply entity){
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
+ if(isValid){
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
+ }
|
|
|
+ return this.removeByIds(ids);
|
|
|
+ }
|
|
|
+}
|