Bläddra i källkod

fix 试听配置

he2802 4 år sedan
förälder
incheckning
13efb1c4d8

+ 16 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/goods/GoodsController.java

@@ -8,8 +8,10 @@ import com.zhongzheng.modules.bank.vo.ExamQuestionVo;
 import com.zhongzheng.modules.goods.bo.*;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
+import com.zhongzheng.modules.goods.service.IGoodsAuditionConfigService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsAttachedVo;
+import com.zhongzheng.modules.goods.vo.GoodsAuditionConfigVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -47,6 +49,9 @@ public class GoodsController extends BaseController {
 
     private final IGoodsAttachedService iGoodsAttachedService;
 
+    @Autowired
+    private IGoodsAuditionConfigService iGoodsAuditionConfigService;
+
     /**
      * 查询商品列表
      */
@@ -139,4 +144,15 @@ public class GoodsController extends BaseController {
         List<GoodsAttachedVo> list = iGoodsAttachedService.selectList(bo);
         return AjaxResult.success(list);
     }
+
+    /**
+     * 课程试听关系列表
+     */
+    @ApiOperation("课程试听列表")
+    @PreAuthorize("@ss.hasPermi('system:business:list')")
+    @GetMapping("/audition/list")
+    public AjaxResult<List<GoodsAuditionConfigVo>> auditionList(GoodsAuditionConfigQueryBo bo) {
+        List<GoodsAuditionConfigVo> list = iGoodsAuditionConfigService.queryList(bo);
+        return AjaxResult.success(list);
+    }
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsAddBo.java

@@ -109,4 +109,6 @@ public class GoodsAddBo {
     private Integer projectId;
     @ApiModelProperty("课程列表")
     private List<GoodsCourseAddBo> courseList;
+    @ApiModelProperty("试听列表")
+    private List<GoodsAuditionConfigAddBo> auditionList;
 }

+ 33 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsAuditionConfigAddBo.java

@@ -0,0 +1,33 @@
+package com.zhongzheng.modules.goods.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import java.util.Date;
+
+
+
+/**
+ * 商品试听配置添加对象 goods_audition_config
+ *
+ * @author hjl
+ * @date 2021-11-02
+ */
+@Data
+@ApiModel("商品试听配置添加对象")
+public class GoodsAuditionConfigAddBo {
+
+    /** 商品id */
+    @ApiModelProperty("商品id")
+    private Long goodsId;
+    /** 节ID */
+    @ApiModelProperty("节ID")
+    private Long sectionId;
+    /** 试听分钟数 */
+    @ApiModelProperty("试听分钟数")
+    private Long auditionMinute;
+    /** 课程ID */
+    @ApiModelProperty("课程ID")
+    private Long courseId;
+}

+ 40 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsAuditionConfigEditBo.java

@@ -0,0 +1,40 @@
+package com.zhongzheng.modules.goods.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import java.util.Date;
+
+
+/**
+ * 商品试听配置编辑对象 goods_audition_config
+ *
+ * @author hjl
+ * @date 2021-11-02
+ */
+@Data
+@ApiModel("商品试听配置编辑对象")
+public class GoodsAuditionConfigEditBo {
+
+    /** $column.columnComment */
+    @ApiModelProperty("$column.columnComment")
+    private Long id;
+
+    /** 商品id */
+    @ApiModelProperty("商品id")
+    private Long goodsId;
+
+    /** 节ID */
+    @ApiModelProperty("节ID")
+    private Long sectionId;
+
+    /** 试听分钟数 */
+    @ApiModelProperty("试听分钟数")
+    private Long auditionMinute;
+
+    /** 课程ID */
+    @ApiModelProperty("课程ID")
+    private Long courseId;
+
+}

+ 51 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsAuditionConfigQueryBo.java

@@ -0,0 +1,51 @@
+package com.zhongzheng.modules.goods.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.HashMap;
+
+import com.zhongzheng.common.core.domain.BaseEntity;
+
+/**
+ * 商品试听配置分页查询对象 goods_audition_config
+ *
+ * @author hjl
+ * @date 2021-11-02
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel("商品试听配置分页查询对象")
+public class GoodsAuditionConfigQueryBo extends BaseEntity {
+
+	/** 分页大小 */
+	@ApiModelProperty("分页大小")
+	private Integer pageSize;
+	/** 当前页数 */
+	@ApiModelProperty("当前页数")
+	private Integer pageNum;
+	/** 排序列 */
+	@ApiModelProperty("排序列")
+	private String orderByColumn;
+	/** 排序的方向desc或者asc */
+	@ApiModelProperty(value = "排序的方向", example = "asc,desc")
+	private String isAsc;
+
+
+	/** 商品id */
+	@ApiModelProperty("商品id")
+	private Long goodsId;
+	/** 节ID */
+	@ApiModelProperty("节ID")
+	private Long sectionId;
+	/** 试听分钟数 */
+	@ApiModelProperty("试听分钟数")
+	private Long auditionMinute;
+	/** 课程ID */
+	@ApiModelProperty("课程ID")
+	private Long courseId;
+}

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsEditBo.java

@@ -134,5 +134,8 @@ public class GoodsEditBo {
     @ApiModelProperty("课程列表")
     private List<GoodsCourseAddBo> courseList;
 
+    @ApiModelProperty("试听列表")
+    private List<GoodsAuditionConfigEditBo> auditionList;
+
 
 }

+ 37 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/domain/GoodsAuditionConfig.java

@@ -0,0 +1,37 @@
+package com.zhongzheng.modules.goods.domain;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+import java.util.Date;
+import java.math.BigDecimal;
+import com.zhongzheng.common.annotation.Excel;
+
+/**
+ * 商品试听配置对象 goods_audition_config
+ *
+ * @author hjl
+ * @date 2021-11-02
+ */
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
+@TableName("goods_audition_config")
+public class GoodsAuditionConfig implements Serializable {
+
+private static final long serialVersionUID=1L;
+
+    /** $column.columnComment */
+    @TableId(value = "id")
+    private Long id;
+    /** 商品id */
+    private Long goodsId;
+    /** 节ID */
+    private Long sectionId;
+    /** 试听分钟数 */
+    private Long auditionMinute;
+    /** 课程ID */
+    private Long courseId;
+}

+ 14 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/mapper/GoodsAuditionConfigMapper.java

@@ -0,0 +1,14 @@
+package com.zhongzheng.modules.goods.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.goods.domain.GoodsAuditionConfig;
+
+/**
+ * 商品试听配置Mapper接口
+ *
+ * @author hjl
+ * @date 2021-11-02
+ */
+public interface GoodsAuditionConfigMapper extends BaseMapper<GoodsAuditionConfig> {
+
+}

+ 52 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsAuditionConfigService.java

@@ -0,0 +1,52 @@
+package com.zhongzheng.modules.goods.service;
+
+import com.zhongzheng.modules.goods.bo.GoodsAuditionConfigAddBo;
+import com.zhongzheng.modules.goods.bo.GoodsAuditionConfigEditBo;
+import com.zhongzheng.modules.goods.bo.GoodsAuditionConfigQueryBo;
+import com.zhongzheng.modules.goods.domain.GoodsAuditionConfig;
+import com.zhongzheng.modules.goods.vo.GoodsAuditionConfigVo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 商品试听配置Service接口
+ *
+ * @author hjl
+ * @date 2021-11-02
+ */
+public interface IGoodsAuditionConfigService extends IService<GoodsAuditionConfig> {
+	/**
+	 * 查询单个
+	 * @return
+	 */
+	GoodsAuditionConfigVo queryById(Long id);
+
+	/**
+	 * 查询列表
+	 */
+	List<GoodsAuditionConfigVo> queryList(GoodsAuditionConfigQueryBo bo);
+
+	/**
+	 * 根据新增业务对象插入商品试听配置
+	 * @param bo 商品试听配置新增业务对象
+	 * @return
+	 */
+	Boolean insertByAddBo(GoodsAuditionConfigAddBo bo);
+
+	/**
+	 * 根据编辑业务对象修改商品试听配置
+	 * @param bo 商品试听配置编辑业务对象
+	 * @return
+	 */
+	Boolean updateByEditBo(GoodsAuditionConfigEditBo bo);
+
+	/**
+	 * 校验并删除数据
+	 * @param ids 主键集合
+	 * @param isValid 是否校验,true-删除前校验,false-不校验
+	 * @return
+	 */
+	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+}

+ 99 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsAuditionConfigServiceImpl.java

@@ -0,0 +1,99 @@
+package com.zhongzheng.modules.goods.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
+import com.zhongzheng.common.utils.DateUtils;
+import com.zhongzheng.modules.goods.bo.GoodsAuditionConfigAddBo;
+import com.zhongzheng.modules.goods.bo.GoodsAuditionConfigEditBo;
+import com.zhongzheng.modules.goods.bo.GoodsAuditionConfigQueryBo;
+import com.zhongzheng.modules.goods.domain.GoodsAuditionConfig;
+import com.zhongzheng.modules.goods.mapper.GoodsAuditionConfigMapper;
+import com.zhongzheng.modules.goods.service.IGoodsAuditionConfigService;
+import com.zhongzheng.modules.goods.vo.GoodsAuditionConfigVo;
+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 hjl
+ * @date 2021-11-02
+ */
+@Service
+public class GoodsAuditionConfigServiceImpl extends ServiceImpl<GoodsAuditionConfigMapper, GoodsAuditionConfig> implements IGoodsAuditionConfigService {
+
+    @Override
+    public GoodsAuditionConfigVo queryById(Long id){
+        GoodsAuditionConfig db = this.baseMapper.selectById(id);
+        return BeanUtil.toBean(db, GoodsAuditionConfigVo.class);
+    }
+
+    @Override
+    public List<GoodsAuditionConfigVo> queryList(GoodsAuditionConfigQueryBo bo) {
+        LambdaQueryWrapper<GoodsAuditionConfig> lqw = Wrappers.lambdaQuery();
+        lqw.eq(bo.getGoodsId() != null, GoodsAuditionConfig::getGoodsId, bo.getGoodsId());
+        lqw.eq(bo.getSectionId() != null, GoodsAuditionConfig::getSectionId, bo.getSectionId());
+        lqw.eq(bo.getAuditionMinute() != null, GoodsAuditionConfig::getAuditionMinute, bo.getAuditionMinute());
+        lqw.eq(bo.getCourseId() != null, GoodsAuditionConfig::getCourseId, bo.getCourseId());
+        return entity2Vo(this.list(lqw));
+    }
+
+    /**
+    * 实体类转化成视图对象
+    *
+    * @param collection 实体类集合
+    * @return
+    */
+    private List<GoodsAuditionConfigVo> entity2Vo(Collection<GoodsAuditionConfig> collection) {
+        List<GoodsAuditionConfigVo> voList = collection.stream()
+                .map(any -> BeanUtil.toBean(any, GoodsAuditionConfigVo.class))
+                .collect(Collectors.toList());
+        if (collection instanceof Page) {
+            Page<GoodsAuditionConfig> page = (Page<GoodsAuditionConfig>)collection;
+            Page<GoodsAuditionConfigVo> pageVo = new Page<>();
+            BeanUtil.copyProperties(page,pageVo);
+            pageVo.addAll(voList);
+            voList = pageVo;
+        }
+        return voList;
+    }
+
+    @Override
+    public Boolean insertByAddBo(GoodsAuditionConfigAddBo bo) {
+        GoodsAuditionConfig add = BeanUtil.toBean(bo, GoodsAuditionConfig.class);
+        validEntityBeforeSave(add);
+        return this.save(add);
+    }
+
+    @Override
+    public Boolean updateByEditBo(GoodsAuditionConfigEditBo bo) {
+        GoodsAuditionConfig update = BeanUtil.toBean(bo, GoodsAuditionConfig.class);
+        validEntityBeforeSave(update);
+        return this.updateById(update);
+    }
+
+    /**
+     * 保存前的数据校验
+     *
+     * @param entity 实体类数据
+     */
+    private void validEntityBeforeSave(GoodsAuditionConfig entity){
+        //TODO 做一些数据校验,如唯一约束
+    }
+
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
+        if(isValid){
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return this.removeByIds(ids);
+    }
+}

+ 31 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -10,9 +10,11 @@ import com.zhongzheng.modules.course.mapper.CourseChapterMapper;
 import com.zhongzheng.modules.goods.bo.*;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.domain.GoodsAttached;
+import com.zhongzheng.modules.goods.domain.GoodsAuditionConfig;
 import com.zhongzheng.modules.goods.domain.GoodsCourse;
 import com.zhongzheng.modules.goods.mapper.GoodsMapper;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
+import com.zhongzheng.modules.goods.service.IGoodsAuditionConfigService;
 import com.zhongzheng.modules.goods.service.IGoodsCourseService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
@@ -48,6 +50,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     @Autowired
     private IGoodsAttachedService iGoodsAttachedService;
 
+    @Autowired
+    private IGoodsAuditionConfigService iGoodsAuditionConfigService;
+
     @Override
     public GoodsVo queryById(Long goodsId){
         Goods db = this.baseMapper.selectById(goodsId);
@@ -119,6 +124,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         add.setCreateTime(DateUtils.getNowTime());
         add.setUpdateTime(DateUtils.getNowTime());
         boolean result = this.save(add);
+        //课程列表
         if(bo.getCourseList()!=null){
             Collection<GoodsCourse> coll = new HashSet<>();
             for(int i=0;i<bo.getCourseList().size();i++){
@@ -131,6 +137,17 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
             }
             iGoodsCourseService.saveBatch(coll);
         }
+        //试听列表
+        if(bo.getAuditionList()!=null){
+            Collection<GoodsAuditionConfig> coll1 = new HashSet<>();
+            for(int i=0;i<bo.getAuditionList().size();i++){
+                GoodsAuditionConfigAddBo item = bo.getAuditionList().get(i);
+                GoodsAuditionConfig addItem = BeanUtil.toBean(item, GoodsAuditionConfig.class);
+                addItem.setGoodsId(add.getGoodsId());
+                coll1.add(addItem);
+            }
+            iGoodsAuditionConfigService.saveBatch(coll1);
+        }
         return result;
     }
 
@@ -164,7 +181,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         Goods update = BeanUtil.toBean(bo, Goods.class);
         validEntityBeforeSave(update);
         update.setUpdateTime(DateUtils.getNowTime());
-        if(bo.getCourseList()!=null){
+        //课程列表
+        if(bo.getCourseList()!=null&&bo.getCourseList().size()>0){
             iGoodsCourseService.remove(new LambdaQueryWrapper<GoodsCourse>().eq(GoodsCourse::getGoodsId, bo.getGoodsId()));
             Collection<GoodsCourse> coll = new HashSet<>();
             for(int i=0;i<bo.getCourseList().size();i++){
@@ -177,6 +195,18 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
             }
             iGoodsCourseService.saveBatch(coll);
         }
+        //试听列表
+        if(bo.getAuditionList()!=null&&bo.getAuditionList().size()>0){
+            iGoodsAuditionConfigService.remove(new LambdaQueryWrapper<GoodsAuditionConfig>().eq(GoodsAuditionConfig::getGoodsId, bo.getGoodsId()));
+            Collection<GoodsAuditionConfig> coll1 = new HashSet<>();
+            for(int i=0;i<bo.getAuditionList().size();i++){
+                GoodsAuditionConfigEditBo item = bo.getAuditionList().get(i);
+                GoodsAuditionConfig addItem = BeanUtil.toBean(item, GoodsAuditionConfig.class);
+                addItem.setGoodsId(update.getGoodsId());
+                coll1.add(addItem);
+            }
+            iGoodsAuditionConfigService.saveBatch(coll1);
+        }
         return this.updateById(update);
     }
 

+ 43 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/GoodsAuditionConfigVo.java

@@ -0,0 +1,43 @@
+package com.zhongzheng.modules.goods.vo;
+
+import com.zhongzheng.common.annotation.Excel;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.util.Date;
+
+
+
+/**
+ * 商品试听配置视图对象 mall_package
+ *
+ * @author hjl
+ * @date 2021-11-02
+ */
+@Data
+@ApiModel("商品试听配置视图对象")
+public class GoodsAuditionConfigVo {
+	private static final long serialVersionUID = 1L;
+
+	/** $pkColumn.columnComment */
+	@ApiModelProperty("$pkColumn.columnComment")
+	private Long id;
+
+	/** 商品id */
+	@Excel(name = "商品id")
+	@ApiModelProperty("商品id")
+	private Long goodsId;
+	/** 节ID */
+	@Excel(name = "节ID")
+	@ApiModelProperty("节ID")
+	private Long sectionId;
+	/** 试听分钟数 */
+	@Excel(name = "试听分钟数")
+	@ApiModelProperty("试听分钟数")
+	private Long auditionMinute;
+	/** 课程ID */
+	@Excel(name = "课程ID")
+	@ApiModelProperty("课程ID")
+	private Long courseId;
+}

+ 16 - 0
zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsAuditionConfigMapper.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhongzheng.modules.goods.mapper.GoodsAuditionConfigMapper">
+
+    <resultMap type="com.zhongzheng.modules.goods.domain.GoodsAuditionConfig" id="GoodsAuditionConfigResult">
+        <result property="id" column="id"/>
+        <result property="goodsId" column="goods_id"/>
+        <result property="sectionId" column="section_id"/>
+        <result property="auditionMinute" column="audition_minute"/>
+        <result property="courseId" column="course_id"/>
+    </resultMap>
+
+
+</mapper>