|
@@ -0,0 +1,113 @@
|
|
|
|
|
+package com.zhongzheng.modules.grade.service.impl;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
|
|
+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 com.zhongzheng.modules.grade.bo.ClassGradeAddBo;
|
|
|
|
|
+import com.zhongzheng.modules.grade.bo.ClassGradeQueryBo;
|
|
|
|
|
+import com.zhongzheng.modules.grade.bo.ClassGradeEditBo;
|
|
|
|
|
+import com.zhongzheng.modules.grade.domain.ClassGrade;
|
|
|
|
|
+import com.zhongzheng.modules.grade.mapper.ClassGradeMapper;
|
|
|
|
|
+import com.zhongzheng.modules.grade.vo.ClassGradeVo;
|
|
|
|
|
+import com.zhongzheng.modules.grade.service.IClassGradeService;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Collection;
|
|
|
|
|
+import java.util.Collections;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 班级Service业务层处理
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author ruoyi
|
|
|
|
|
+ * @date 2021-11-10
|
|
|
|
|
+ */
|
|
|
|
|
+@Service
|
|
|
|
|
+public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGrade> implements IClassGradeService {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public ClassGradeVo queryById(Long classId){
|
|
|
|
|
+ ClassGrade db = this.baseMapper.selectById(classId);
|
|
|
|
|
+ return BeanUtil.toBean(db, ClassGradeVo.class);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<ClassGradeVo> queryList(ClassGradeQueryBo bo) {
|
|
|
|
|
+ LambdaQueryWrapper<ClassGrade> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
+ lqw.eq(bo.getClassStatus() != null, ClassGrade::getClassStatus, bo.getClassStatus());
|
|
|
|
|
+ lqw.like(StrUtil.isNotBlank(bo.getOfficialName()), ClassGrade::getOfficialName, bo.getOfficialName());
|
|
|
|
|
+ lqw.like(StrUtil.isNotBlank(bo.getClassName()), ClassGrade::getClassName, bo.getClassName());
|
|
|
|
|
+ lqw.eq(bo.getStudentUpper() != null, ClassGrade::getStudentUpper, bo.getStudentUpper());
|
|
|
|
|
+ lqw.eq(bo.getLearningTimeStart() != null, ClassGrade::getLearningTimeStart, bo.getLearningTimeStart());
|
|
|
|
|
+ lqw.eq(bo.getLearningStatus() != null, ClassGrade::getLearningStatus, bo.getLearningStatus());
|
|
|
|
|
+ lqw.eq(bo.getStatus() != null, ClassGrade::getStatus, bo.getStatus());
|
|
|
|
|
+ lqw.eq(bo.getClassStartTime() != null, ClassGrade::getClassStartTime, bo.getClassStartTime());
|
|
|
|
|
+ lqw.eq(bo.getClassEndTime() != null, ClassGrade::getClassEndTime, bo.getClassEndTime());
|
|
|
|
|
+ lqw.eq(bo.getExamineId() != null, ClassGrade::getExamineId, bo.getExamineId());
|
|
|
|
|
+ lqw.eq(bo.getAreasId() != null, ClassGrade::getAreasId, bo.getAreasId());
|
|
|
|
|
+ lqw.eq(bo.getSysUserId() != null, ClassGrade::getSysUserId, bo.getSysUserId());
|
|
|
|
|
+ lqw.eq(bo.getInterfacePushId() != null, ClassGrade::getInterfacePushId, bo.getInterfacePushId());
|
|
|
|
|
+ lqw.eq(bo.getInterfaceAccountId() != null, ClassGrade::getInterfaceAccountId, bo.getInterfaceAccountId());
|
|
|
|
|
+ lqw.eq(bo.getInterfacePeriodId() != null, ClassGrade::getInterfacePeriodId, bo.getInterfacePeriodId());
|
|
|
|
|
+ return entity2Vo(this.list(lqw));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 实体类转化成视图对象
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param collection 实体类集合
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<ClassGradeVo> entity2Vo(Collection<ClassGrade> collection) {
|
|
|
|
|
+ List<ClassGradeVo> voList = collection.stream()
|
|
|
|
|
+ .map(any -> BeanUtil.toBean(any, ClassGradeVo.class))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ if (collection instanceof Page) {
|
|
|
|
|
+ Page<ClassGrade> page = (Page<ClassGrade>)collection;
|
|
|
|
|
+ Page<ClassGradeVo> pageVo = new Page<>();
|
|
|
|
|
+ BeanUtil.copyProperties(page,pageVo);
|
|
|
|
|
+ pageVo.addAll(voList);
|
|
|
|
|
+ voList = pageVo;
|
|
|
|
|
+ }
|
|
|
|
|
+ return voList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean insertByAddBo(ClassGradeAddBo bo) {
|
|
|
|
|
+ ClassGrade add = BeanUtil.toBean(bo, ClassGrade.class);
|
|
|
|
|
+ validEntityBeforeSave(add);
|
|
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ return this.save(add);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean updateByEditBo(ClassGradeEditBo bo) {
|
|
|
|
|
+ ClassGrade update = BeanUtil.toBean(bo, ClassGrade.class);
|
|
|
|
|
+ validEntityBeforeSave(update);
|
|
|
|
|
+ update.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ return this.updateById(update);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 保存前的数据校验
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param entity 实体类数据
|
|
|
|
|
+ */
|
|
|
|
|
+ private void validEntityBeforeSave(ClassGrade entity){
|
|
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
|
|
+ if(isValid){
|
|
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
|
+ }
|
|
|
|
|
+ return this.removeByIds(ids);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|