Browse Source

fix 商品编辑限制

he2802 3 năm trước cách đây
mục cha
commit
00a4c86bbf

+ 12 - 2
zhongzheng-admin/src/main/java/com/zhongzheng/controller/grade/ClassGradeController.java

@@ -462,15 +462,25 @@ public class ClassGradeController extends BaseController {
     }
 
     /**
-     * 查询查询以往审核记录列表
+     * 检查编辑数据是否有用户通过学时
      */
-    @ApiOperation("查编辑数据是否有用户通过学时")
+    @ApiOperation("查编辑数据是否有用户通过学时")
     @PreAuthorize("@ss.hasPermi('grade:user:list')")
     @GetMapping("/checkGoodsChange")
     public AjaxResult<Long> checkGoodsChange(UserPeriodQueryBo bo) {
         return AjaxResult.success(iUserPeriodService.checkGoodsChange(bo));
     }
 
+    /**
+     * 检查编辑数据是否有用户通过学时
+     */
+    @ApiOperation("检查编辑数据是否有用户在学习")
+    @PreAuthorize("@ss.hasPermi('grade:user:list')")
+    @GetMapping("/checkGoodsStudy")
+    public AjaxResult<Long> checkGoodsStudy(UserPeriodQueryBo bo) {
+        return AjaxResult.success(iUserPeriodService.checkGoodsStudy(bo));
+    }
+
     /**
      * 查询班级信息推送数量
      */

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -255,12 +255,14 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
             }
             iGoodsCourseService.saveBatch(coll);
         }
+        //购买须知
         if(Validator.isEmpty(bo.getBuyNote())){
             LambdaUpdateWrapper<Goods> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
             objectLambdaUpdateWrapper.eq(Goods::getGoodsId,bo.getGoodsId());
             objectLambdaUpdateWrapper.set(Goods::getBuyNote,null);
             update(null, objectLambdaUpdateWrapper);
         }
+        //最大节数量
         if(Validator.isEmpty(bo.getSectionMaxNum())){
             LambdaUpdateWrapper<Goods> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
             objectLambdaUpdateWrapper.eq(Goods::getGoodsId,bo.getGoodsId());

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/mapper/UserPeriodMapper.java

@@ -17,6 +17,8 @@ import java.util.List;
 public interface UserPeriodMapper extends BaseMapper<UserPeriod> {
     Long checkGoodsChange(UserPeriodQueryBo bo);
 
+    Long checkGoodsStudy(UserPeriodQueryBo bo);
+
     Long selectCountPeriod(@Param("userId") Long userId, @Param("id") Long id);
 
     Long selectCountConfirmPeriod(@Param("userId") Long userId, @Param("id") Long id);

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/IUserPeriodService.java

@@ -25,6 +25,8 @@ public interface IUserPeriodService extends IService<UserPeriod> {
 
 	Long checkGoodsChange(UserPeriodQueryBo bo);
 
+	Long checkGoodsStudy(UserPeriodQueryBo bo);
+
 	/**
 	 * 查询列表
 	 */

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/UserPeriodServiceImpl.java

@@ -113,6 +113,11 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
         return this.baseMapper.checkGoodsChange(bo);
     }
 
+    @Override
+    public Long checkGoodsStudy(UserPeriodQueryBo bo) {
+        return this.baseMapper.checkGoodsStudy(bo);
+    }
+
     @Override
     public List<UserPeriodVo> queryList(UserPeriodQueryBo bo) {
         LambdaQueryWrapper<UserPeriod> lqw = Wrappers.lambdaQuery();

+ 34 - 0
zhongzheng-system/src/main/resources/mapper/modules/grade/UserPeriodMapper.xml

@@ -54,6 +54,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
     </select>
 
+    <select id="checkGoodsStudy" parameterType="com.zhongzheng.modules.grade.bo.UserPeriodQueryBo" resultType="Long">
+        SELECT
+        IFNULL(count(*),0)
+        FROM
+        user_period up
+        WHERE
+        <if test="goodsId != null and goodsId != ''">
+            and up.goods_id = #{goodsId}
+        </if>
+        <if test="gradeId != null and gradeId != ''">
+            and up.grade_id = #{gradeId}
+        </if>
+
+        <if test="userId != null and userId != ''">
+            and up.user_id = #{userId}
+        </if>
+        <if test="sectionId != null ">
+            and up.section_id = #{sectionId}
+        </if>
+        <if test="moduleId != null ">
+            and up.module_id = #{moduleId}
+        </if>
+
+        <if test="chapterId != null">
+            and up.chapter_id = #{chapterId}
+        </if>
+        <if test="courseId != null ">
+            and up.course_id = #{courseId}
+        </if>
+        <if test="examId != null ">
+            and up.exam_id = #{examId}
+        </if>
+    </select>
+
     <select id="selectCountPeriod" parameterType="map" resultType="Long">
         SELECT
             COUNT(1)