瀏覽代碼

fix 课程目录卷

he2802 3 年之前
父節點
當前提交
d2b09c99aa

+ 1 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/course/CourseSectionController.java

@@ -53,6 +53,7 @@ public class CourseSectionController extends BaseController {
     @PreAuthorize("@ss.hasPermi('system:section:list')")
     @GetMapping("/list")
     public TableDataInfo<CourseSectionVo> list(CourseSectionQueryBo bo) {
+        System.out.println(bo);
         startPage();
         List<CourseSectionVo> list = iCourseSectionService.selectSectionList(bo);
         return getDataTable(list);

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/domain/ClassGrade.java

@@ -21,6 +21,7 @@ import com.zhongzheng.common.annotation.Excel;
 @Accessors(chain = true)
 @TableName("class_grade")
 public class ClassGrade implements Serializable {
+    public static final Integer INIT_UPPER = 300;  //初始人数
 
 private static final long serialVersionUID=1L;
 

+ 40 - 6
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -5,9 +5,14 @@ import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
+import com.zhongzheng.common.utils.SecurityUtils;
+import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.bank.domain.QuestionBusiness;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.service.IGoodsService;
+import com.zhongzheng.modules.grade.domain.ClassGrade;
+import com.zhongzheng.modules.grade.domain.ClassGradeSys;
+import com.zhongzheng.modules.grade.domain.ClassGradeUser;
 import com.zhongzheng.modules.grade.service.IClassGradeService;
 import com.zhongzheng.modules.grade.service.IClassGradeUserService;
 import com.zhongzheng.modules.grade.vo.ClassGradeVo;
@@ -240,20 +245,49 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 
     /**
      * 加入班级
-     * @param goodsId
-     * @param classId
+     * @param orderGoodsId
+     * @param gradeId
      * @return
      */
-    public boolean joinClass(Long goodsId,Long gradeId,Long userId){
+    public boolean checkGrade(String goodsName,Long orderGoodsId,Long gradeId,Long userId){
         if(gradeId!=null){
             ClassGradeVo classGradeVo = iClassGradeService.queryById(gradeId);
             if(classGradeVo==null){
                 throw new CustomException("班级不存在");
             }
-
-
-
+            LambdaQueryWrapper<ClassGradeUser> lqw = new LambdaQueryWrapper<>();
+            lqw.eq(ClassGradeUser::getGradeId,gradeId);
+            lqw.eq(ClassGradeUser::getStatus,1);
+            int studentNum = iClassGradeUserService.count(lqw);
+            if(classGradeVo.getStudentUpper()>studentNum){
+                //加入班级
+                joinGrade(orderGoodsId,gradeId,userId);
+            }
         }
+        //创建新班级
+        ClassGrade classGrade = new ClassGrade();
+        classGrade.setStudentUpper(ClassGrade.INIT_UPPER); //上限300
+        classGrade.setCreateTime(DateUtils.getNowTime());
+        classGrade.setUpdateTime(DateUtils.getNowTime());
+        String gradeCode = ServletUtils.getEncoded("BJ");
+        classGrade.setGradeCode(gradeCode);
+        classGrade.setClassName(goodsName+gradeCode);
+        boolean save = iClassGradeService.save(classGrade);
+        //加入班级
+        joinGrade(orderGoodsId,classGrade.getGradeId(),userId);
         return false;
     }
+
+    public boolean joinGrade(Long orderGoodsId,Long gradeId,Long userId){
+        //班级还有剩位,进入班级
+        ClassGradeUser classGradeUser = new ClassGradeUser();
+        classGradeUser.setUserId(userId);
+        classGradeUser.setGradeId(gradeId);
+        classGradeUser.setStatus(1);
+        classGradeUser.setCreateBy(SecurityUtils.getUsername());
+        classGradeUser.setFromType(1);
+        classGradeUser.setOrderGoodsId(orderGoodsId);
+        iClassGradeUserService.save(classGradeUser);
+        return true;
+    }
 }

+ 3 - 3
zhongzheng-system/src/main/resources/mapper/modules/course/CourseChapterMapper.xml

@@ -125,7 +125,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 #{item}
             </foreach>
         </if>
-        <if test="publishStatus != null and publishStatus != ''">
+        <if test="publishStatus != null ">
             AND c.publish_status = #{publishStatus}
         </if>
         <if test="educationTypeId != null and educationTypeId != ''">
@@ -163,7 +163,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 #{item}
             </foreach>
         </if>
-        <if test="publishStatus != null and publishStatus != ''">
+        <if test="publishStatus != null">
             AND c.publish_status = #{publishStatus}
         </if>
         <if test="educationTypeId != null and educationTypeId != ''">
@@ -181,6 +181,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="prefixName != null and prefixName != ''">
             AND c.prefix_name like concat('%', #{prefixName}, '%')
         </if>
-       
+
     </select>
 </mapper>

+ 2 - 2
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml

@@ -113,7 +113,7 @@
         <if test="courseName != null and courseName != ''">
             AND c.course_name like concat('%', #{courseName}, '%')
         </if>
-        <if test="publishStatus != null and publishStatus != ''">
+        <if test="publishStatus != null ">
             AND c.publish_status = #{publishStatus}
         </if>
         <if test="schoolId != null and schoolId != ''">
@@ -155,7 +155,7 @@
         <if test="courseName != null and courseName != ''">
             AND c.course_name like concat('%', #{courseName}, '%')
         </if>
-        <if test="publishStatus != null and publishStatus != ''">
+        <if test="publishStatus != null ">
             AND c.publish_status = #{publishStatus}
         </if>
         <if test="schoolId != null and schoolId != ''">

+ 2 - 2
zhongzheng-system/src/main/resources/mapper/modules/course/CourseModuleMapper.xml

@@ -96,7 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 #{item}
             </foreach>
         </if>
-        <if test="publishStatus != null and publishStatus != ''">
+        <if test="publishStatus != null ">
             AND c.publish_status = #{publishStatus}
         </if>
         <if test="educationTypeId != null and educationTypeId != ''">
@@ -131,7 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 #{item}
             </foreach>
         </if>
-        <if test="publishStatus != null and publishStatus != ''">
+        <if test="publishStatus != null ">
             AND c.publish_status = #{publishStatus}
         </if>
         <if test="educationTypeId != null and educationTypeId != ''">

+ 2 - 2
zhongzheng-system/src/main/resources/mapper/modules/course/CourseSectionMapper.xml

@@ -117,7 +117,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="name != null and name != ''">
             AND c.name like concat('%', #{name}, '%')
         </if>
-        <if test="publishStatus != null and publishStatus != ''">
+        <if test="publishStatus != null ">
             AND c.publish_status = #{publishStatus}
         </if>
         <if test="educationTypeId != null and educationTypeId != ''">
@@ -158,7 +158,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="name != null and name != ''">
             AND c.name like concat('%', #{name}, '%')
         </if>
-        <if test="publishStatus != null and publishStatus != ''">
+        <if test="publishStatus != null ">
             AND c.publish_status = #{publishStatus}
         </if>
         <if test="educationTypeId != null and educationTypeId != ''">