|
|
@@ -1,8 +1,13 @@
|
|
|
package com.zhongzheng.modules.node.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.modules.course.domain.Course;
|
|
|
+import com.zhongzheng.modules.course.service.ICourseService;
|
|
|
import com.zhongzheng.modules.node.bo.NodeDirAddBo;
|
|
|
import com.zhongzheng.modules.node.bo.NodeDirEditBo;
|
|
|
import com.zhongzheng.modules.node.bo.NodeDirQueryBo;
|
|
|
@@ -10,6 +15,8 @@ import com.zhongzheng.modules.node.domain.NodeDir;
|
|
|
import com.zhongzheng.modules.node.mapper.NodeDirMapper;
|
|
|
import com.zhongzheng.modules.node.service.INodeDirService;
|
|
|
import com.zhongzheng.modules.node.vo.NodeDirVo;
|
|
|
+import com.zhongzheng.modules.user.domain.UserVisitLog;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -30,6 +37,9 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class NodeDirServiceImpl extends ServiceImpl<NodeDirMapper, NodeDir> implements INodeDirService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICourseService iCourseService;
|
|
|
+
|
|
|
@Override
|
|
|
public NodeDirVo queryById(Long dirId){
|
|
|
NodeDir db = this.baseMapper.selectById(dirId);
|
|
|
@@ -40,9 +50,9 @@ public class NodeDirServiceImpl extends ServiceImpl<NodeDirMapper, NodeDir> impl
|
|
|
public List<NodeDirVo> queryList(NodeDirQueryBo bo) {
|
|
|
LambdaQueryWrapper<NodeDir> lqw = Wrappers.lambdaQuery();
|
|
|
lqw.eq(bo.getCourseId() != null, NodeDir::getCourseId, bo.getCourseId());
|
|
|
- lqw.eq(bo.getGoodsId() != null, NodeDir::getGoodsId, bo.getGoodsId());
|
|
|
- lqw.eq(bo.getAuditingStatus() != null, NodeDir::getAuditingStatus, bo.getAuditingStatus());
|
|
|
lqw.eq(bo.getTeacherId() != null, NodeDir::getTeacherId, bo.getTeacherId());
|
|
|
+ lqw.like(StrUtil.isNotBlank(bo.getDirName()), NodeDir::getDirName, bo.getDirName());
|
|
|
+ lqw.eq( NodeDir::getStatus, 1);
|
|
|
return entity2Vo(this.list(lqw));
|
|
|
}
|
|
|
|
|
|
@@ -67,12 +77,14 @@ public class NodeDirServiceImpl extends ServiceImpl<NodeDirMapper, NodeDir> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean insertByAddBo(NodeDirAddBo bo) {
|
|
|
+ public NodeDir insertByAddBo(NodeDirAddBo bo) {
|
|
|
NodeDir add = BeanUtil.toBean(bo, NodeDir.class);
|
|
|
validEntityBeforeSave(add);
|
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
|
- return this.save(add);
|
|
|
+ add.setStatus(1);
|
|
|
+ this.save(add);
|
|
|
+ return add;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -90,6 +102,14 @@ public class NodeDirServiceImpl extends ServiceImpl<NodeDirMapper, NodeDir> impl
|
|
|
*/
|
|
|
private void validEntityBeforeSave(NodeDir entity){
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
+ if(Validator.isNotEmpty(entity.getTeacherId())&&entity.getTeacherId()==0){
|
|
|
+ throw new CustomException("教师数据错误");
|
|
|
+ }
|
|
|
+ if(Validator.isNotEmpty(entity.getStatus())&&entity.getStatus()==-1){
|
|
|
+ if(iCourseService.count(new QueryWrapper<Course>().lambda().eq(Course::getAuditingDirId,entity.getDirId()).ne(Course::getStatus,-1))>0){
|
|
|
+ throw new CustomException("该目录已被课程指定为审核目录");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|