|
@@ -0,0 +1,106 @@
|
|
|
|
|
+package com.zhongzheng.modules.bank.service.impl;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
|
|
+import com.zhongzheng.modules.bank.bo.QuestionSimulateAddBo;
|
|
|
|
|
+import com.zhongzheng.modules.bank.bo.QuestionSimulateEditBo;
|
|
|
|
|
+import com.zhongzheng.modules.bank.bo.QuestionSimulateQueryBo;
|
|
|
|
|
+import com.zhongzheng.modules.bank.domain.QuestionSimulate;
|
|
|
|
|
+import com.zhongzheng.modules.bank.mapper.QuestionSimulateMapper;
|
|
|
|
|
+import com.zhongzheng.modules.bank.service.IQuestionSimulateService;
|
|
|
|
|
+import com.zhongzheng.modules.bank.vo.QuestionSimulateVo;
|
|
|
|
|
+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.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 模拟题库Service业务层处理
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author ruoyi
|
|
|
|
|
+ * @date 2021-06-24
|
|
|
|
|
+ */
|
|
|
|
|
+@Service
|
|
|
|
|
+public class QuestionSimulateServiceImpl extends ServiceImpl<QuestionSimulateMapper, QuestionSimulate> implements IQuestionSimulateService {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public QuestionSimulateVo queryById(Long simulateId){
|
|
|
|
|
+ QuestionSimulate db = this.baseMapper.selectById(simulateId);
|
|
|
|
|
+ return BeanUtil.toBean(db, QuestionSimulateVo.class);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<QuestionSimulateVo> queryList(QuestionSimulateQueryBo bo) {
|
|
|
|
|
+ LambdaQueryWrapper<QuestionSimulate> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
+ lqw.eq(bo.getUserId() != null, QuestionSimulate::getUserId, bo.getUserId());
|
|
|
|
|
+ lqw.eq(bo.getExamConfigId() != null, QuestionSimulate::getExamConfigId, bo.getExamConfigId());
|
|
|
|
|
+ lqw.eq(bo.getStatus() != null, QuestionSimulate::getStatus, bo.getStatus());
|
|
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getType1Ids()), QuestionSimulate::getType1Ids, bo.getType1Ids());
|
|
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getType2Ids()), QuestionSimulate::getType2Ids, bo.getType2Ids());
|
|
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getType3Ids()), QuestionSimulate::getType3Ids, bo.getType3Ids());
|
|
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getType4Ids()), QuestionSimulate::getType4Ids, bo.getType4Ids());
|
|
|
|
|
+ lqw.eq(bo.getBankId() != null, QuestionSimulate::getBankId, bo.getBankId());
|
|
|
|
|
+ return entity2Vo(this.list(lqw));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 实体类转化成视图对象
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param collection 实体类集合
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<QuestionSimulateVo> entity2Vo(Collection<QuestionSimulate> collection) {
|
|
|
|
|
+ List<QuestionSimulateVo> voList = collection.stream()
|
|
|
|
|
+ .map(any -> BeanUtil.toBean(any, QuestionSimulateVo.class))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ if (collection instanceof Page) {
|
|
|
|
|
+ Page<QuestionSimulate> page = (Page<QuestionSimulate>)collection;
|
|
|
|
|
+ Page<QuestionSimulateVo> pageVo = new Page<>();
|
|
|
|
|
+ BeanUtil.copyProperties(page,pageVo);
|
|
|
|
|
+ pageVo.addAll(voList);
|
|
|
|
|
+ voList = pageVo;
|
|
|
|
|
+ }
|
|
|
|
|
+ return voList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean insertByAddBo(QuestionSimulateAddBo bo) {
|
|
|
|
|
+ QuestionSimulate add = BeanUtil.toBean(bo, QuestionSimulate.class);
|
|
|
|
|
+ validEntityBeforeSave(add);
|
|
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ return this.save(add);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean updateByEditBo(QuestionSimulateEditBo bo) {
|
|
|
|
|
+ QuestionSimulate update = BeanUtil.toBean(bo, QuestionSimulate.class);
|
|
|
|
|
+ validEntityBeforeSave(update);
|
|
|
|
|
+ update.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ return this.updateById(update);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 保存前的数据校验
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param entity 实体类数据
|
|
|
|
|
+ */
|
|
|
|
|
+ private void validEntityBeforeSave(QuestionSimulate entity){
|
|
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
|
|
+ if(isValid){
|
|
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
|
+ }
|
|
|
|
|
+ return this.removeByIds(ids);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|