|
@@ -2,19 +2,24 @@ package com.zhongzheng.modules.exam.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
|
+import com.zhongzheng.common.utils.ServletUtils;
|
|
|
|
+import com.zhongzheng.modules.exam.bo.*;
|
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamKnowledgeBusiness;
|
|
|
|
+import com.zhongzheng.modules.exam.service.IExamKnowledgeBusinessService;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
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 com.zhongzheng.modules.exam.bo.ExamKnowledgeAddBo;
|
|
|
|
-import com.zhongzheng.modules.exam.bo.ExamKnowledgeQueryBo;
|
|
|
|
-import com.zhongzheng.modules.exam.bo.ExamKnowledgeEditBo;
|
|
|
|
import com.zhongzheng.modules.exam.domain.ExamKnowledge;
|
|
import com.zhongzheng.modules.exam.domain.ExamKnowledge;
|
|
import com.zhongzheng.modules.exam.mapper.ExamKnowledgeMapper;
|
|
import com.zhongzheng.modules.exam.mapper.ExamKnowledgeMapper;
|
|
import com.zhongzheng.modules.exam.vo.ExamKnowledgeVo;
|
|
import com.zhongzheng.modules.exam.vo.ExamKnowledgeVo;
|
|
import com.zhongzheng.modules.exam.service.IExamKnowledgeService;
|
|
import com.zhongzheng.modules.exam.service.IExamKnowledgeService;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
@@ -30,6 +35,10 @@ import java.util.stream.Collectors;
|
|
@Service
|
|
@Service
|
|
public class ExamKnowledgeServiceImpl extends ServiceImpl<ExamKnowledgeMapper, ExamKnowledge> implements IExamKnowledgeService {
|
|
public class ExamKnowledgeServiceImpl extends ServiceImpl<ExamKnowledgeMapper, ExamKnowledge> implements IExamKnowledgeService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IExamKnowledgeBusinessService examKnowledgeBusinessService;
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public ExamKnowledgeVo queryById(Long knowledgeId){
|
|
public ExamKnowledgeVo queryById(Long knowledgeId){
|
|
ExamKnowledge db = this.baseMapper.selectById(knowledgeId);
|
|
ExamKnowledge db = this.baseMapper.selectById(knowledgeId);
|
|
@@ -38,11 +47,7 @@ public class ExamKnowledgeServiceImpl extends ServiceImpl<ExamKnowledgeMapper, E
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<ExamKnowledgeVo> queryList(ExamKnowledgeQueryBo bo) {
|
|
public List<ExamKnowledgeVo> queryList(ExamKnowledgeQueryBo bo) {
|
|
- LambdaQueryWrapper<ExamKnowledge> lqw = Wrappers.lambdaQuery();
|
|
|
|
- lqw.like(StrUtil.isNotBlank(bo.getKnowledgeName()), ExamKnowledge::getKnowledgeName, bo.getKnowledgeName());
|
|
|
|
- lqw.eq(bo.getStatus() != null, ExamKnowledge::getStatus, bo.getStatus());
|
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getEncoder()), ExamKnowledge::getEncoder, bo.getEncoder());
|
|
|
|
- return entity2Vo(this.list(lqw));
|
|
|
|
|
|
+ return entity2Vo(baseMapper.queryList(bo));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -51,12 +56,12 @@ public class ExamKnowledgeServiceImpl extends ServiceImpl<ExamKnowledgeMapper, E
|
|
* @param collection 实体类集合
|
|
* @param collection 实体类集合
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private List<ExamKnowledgeVo> entity2Vo(Collection<ExamKnowledge> collection) {
|
|
|
|
|
|
+ private List<ExamKnowledgeVo> entity2Vo(Collection<ExamKnowledgeVo> collection) {
|
|
List<ExamKnowledgeVo> voList = collection.stream()
|
|
List<ExamKnowledgeVo> voList = collection.stream()
|
|
.map(any -> BeanUtil.toBean(any, ExamKnowledgeVo.class))
|
|
.map(any -> BeanUtil.toBean(any, ExamKnowledgeVo.class))
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
if (collection instanceof Page) {
|
|
if (collection instanceof Page) {
|
|
- Page<ExamKnowledge> page = (Page<ExamKnowledge>)collection;
|
|
|
|
|
|
+ Page<ExamKnowledgeVo> page = (Page<ExamKnowledgeVo>)collection;
|
|
Page<ExamKnowledgeVo> pageVo = new Page<>();
|
|
Page<ExamKnowledgeVo> pageVo = new Page<>();
|
|
BeanUtil.copyProperties(page,pageVo);
|
|
BeanUtil.copyProperties(page,pageVo);
|
|
pageVo.addAll(voList);
|
|
pageVo.addAll(voList);
|
|
@@ -66,12 +71,23 @@ public class ExamKnowledgeServiceImpl extends ServiceImpl<ExamKnowledgeMapper, E
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
public Boolean insertByAddBo(ExamKnowledgeAddBo bo) {
|
|
public Boolean insertByAddBo(ExamKnowledgeAddBo bo) {
|
|
- ExamKnowledge add = BeanUtil.toBean(bo, ExamKnowledge.class);
|
|
|
|
- validEntityBeforeSave(add);
|
|
|
|
- add.setCreateTime(DateUtils.getNowTime());
|
|
|
|
- add.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
- return this.save(add);
|
|
|
|
|
|
+ for (String s : bo.getKnowledgeName()) {
|
|
|
|
+ ExamKnowledge examKnowledge = BeanUtil.toBean(bo, ExamKnowledge.class);
|
|
|
|
+ examKnowledge.setKnowledgeName(s);
|
|
|
|
+ examKnowledge.setEncoder(ServletUtils.getEncoded("ZSD"));
|
|
|
|
+ examKnowledge.setCreateTime(DateUtils.getNowTime());
|
|
|
|
+ examKnowledge.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
+ boolean save = this.save(examKnowledge);
|
|
|
|
+ for (ExamKnowledgeBusinessAddBo examKnowledgeBusinessAddBo : bo.getExamKnowledgeBusinessAddBoList()) {
|
|
|
|
+ examKnowledgeBusinessAddBo.setKnowledgeId(examKnowledge.getKnowledgeId());
|
|
|
|
+ examKnowledgeBusinessAddBo.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
+ examKnowledgeBusinessAddBo.setCreateTime(DateUtils.getNowTime());
|
|
|
|
+ Boolean aBoolean = examKnowledgeBusinessService.insertByAddBo(examKnowledgeBusinessAddBo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -79,6 +95,15 @@ public class ExamKnowledgeServiceImpl extends ServiceImpl<ExamKnowledgeMapper, E
|
|
ExamKnowledge update = BeanUtil.toBean(bo, ExamKnowledge.class);
|
|
ExamKnowledge update = BeanUtil.toBean(bo, ExamKnowledge.class);
|
|
validEntityBeforeSave(update);
|
|
validEntityBeforeSave(update);
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
+ LambdaQueryWrapper<ExamKnowledgeBusiness> lqw = Wrappers.lambdaQuery();
|
|
|
|
+ lqw.eq(ExamKnowledgeBusiness::getKnowledgeId,bo.getKnowledgeId());
|
|
|
|
+ boolean remove = examKnowledgeBusinessService.remove(lqw);
|
|
|
|
+ for (ExamKnowledgeBusinessAddBo examKnowledgeBusinessAddBo : bo.getExamKnowledgeBusinessAddBoList()) {
|
|
|
|
+ examKnowledgeBusinessAddBo.setKnowledgeId(bo.getKnowledgeId());
|
|
|
|
+ examKnowledgeBusinessAddBo.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
+ examKnowledgeBusinessAddBo.setCreateTime(DateUtils.getNowTime());
|
|
|
|
+ Boolean aBoolean = examKnowledgeBusinessService.insertByAddBo(examKnowledgeBusinessAddBo);
|
|
|
|
+ }
|
|
return this.updateById(update);
|
|
return this.updateById(update);
|
|
}
|
|
}
|
|
|
|
|