|
@@ -0,0 +1,51 @@
|
|
|
+package com.zhongzheng.modules.course.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.modules.course.bo.SectionWatchPerAddBo;
|
|
|
+import com.zhongzheng.modules.course.bo.SectionWatchPerBo;
|
|
|
+import com.zhongzheng.modules.course.domain.CourseSection;
|
|
|
+import com.zhongzheng.modules.course.domain.CourseSectionWatchPer;
|
|
|
+import com.zhongzheng.modules.course.mapper.CourseSectionWatchPerMapper;
|
|
|
+import com.zhongzheng.modules.course.service.ICourseSectionWatchPerService;
|
|
|
+import com.zhongzheng.modules.course.vo.CourseSectionWatchPerVo;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author tanzh
|
|
|
+ * @date 2022年08月16日 11:05
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CourseSectionWatchPerServiceImpl extends ServiceImpl<CourseSectionWatchPerMapper, CourseSectionWatchPer> implements ICourseSectionWatchPerService {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CourseSectionWatchPerVo getSectionWatchPer(SectionWatchPerBo bo) {
|
|
|
+ CourseSectionWatchPer watchPer = getOne(new LambdaQueryWrapper<CourseSectionWatchPer>()
|
|
|
+ .eq(ObjectUtils.isNotNull(bo.getCourseId()), CourseSectionWatchPer::getCourseId, bo.getCourseId())
|
|
|
+ .eq(ObjectUtils.isNotNull(bo.getChapterId()), CourseSectionWatchPer::getChapterId, bo.getChapterId())
|
|
|
+ .eq(ObjectUtils.isNotNull(bo.getModuleId()), CourseSectionWatchPer::getModuleId, bo.getModuleId())
|
|
|
+ .eq(ObjectUtils.isNotNull(bo.getSectionId()), CourseSectionWatchPer::getSectionId, bo.getSectionId())
|
|
|
+ .eq(ObjectUtils.isNotNull(bo.getGoodsId()), CourseSectionWatchPer::getGoodsId, bo.getGoodsId())
|
|
|
+ .eq(CourseSectionWatchPer::getStatus, 1)
|
|
|
+ .last("LIMIT 1"));
|
|
|
+ if (ObjectUtils.isNull(watchPer)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CourseSectionWatchPerVo vo = new CourseSectionWatchPerVo();
|
|
|
+ BeanUtil.copyProperties(watchPer,vo,true);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean insertByAddBo(SectionWatchPerAddBo bo) {
|
|
|
+ CourseSectionWatchPer add = BeanUtil.toBean(bo, CourseSectionWatchPer.class);
|
|
|
+ add.setStatus(1);
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return saveOrUpdate(add);
|
|
|
+ }
|
|
|
+}
|