ソースを参照

Merge branch 'master' of http://git.dayaedu.com/yonge/cooleshow

liujunchi 3 年 前
コミット
f7d917f10b

+ 15 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/CheckLiveCourseTimeDto.java → cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/CheckCourseTimeDto.java

@@ -4,6 +4,7 @@ import com.yonge.cooleshow.biz.dal.entity.CourseTimeEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.util.List;
@@ -12,8 +13,8 @@ import java.util.List;
  * @author hgw
  * Created by 2022-03-30
  */
-@ApiModel(value = "创建直播课组验校时间接收类")
-public class CheckLiveCourseTimeDto implements Serializable {
+@ApiModel(value = "创建课程组验校时间接是否可用参数类")
+public class CheckCourseTimeDto implements Serializable {
 
     @NotNull(message = "老师Id不能为空")
     @ApiModelProperty(value = "老师Id")
@@ -23,6 +24,10 @@ public class CheckLiveCourseTimeDto implements Serializable {
     @ApiModelProperty(value = "是否需要循环 0:不需要 1:需要")
     private Integer loop;
 
+    @NotBlank(message = "课程类型不能为空")
+    @ApiModelProperty(value = "PRACTICE:陪练课,LIVE:直播课")
+    private String  courseType;
+
     @NotNull(message = "课程数不能为空")
     @ApiModelProperty(value = "课程数")
     private Integer courseNum;
@@ -62,4 +67,12 @@ public class CheckLiveCourseTimeDto implements Serializable {
     public void setTimeList(List<CourseTimeEntity> timeList) {
         this.timeList = timeList;
     }
+
+    public String getCourseType() {
+        return courseType;
+    }
+
+    public void setCourseType(String courseType) {
+        this.courseType = courseType;
+    }
 }

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/CourseGroup.java

@@ -47,6 +47,10 @@ public class CourseGroup implements Serializable {
     @ApiModelProperty(value = "课程数")
     private Integer courseNum;
 
+    @TableField("complete_course_num_")
+    @ApiModelProperty(value = "已上完课的课程数")
+    private Integer completeCourseNum;
+
     @TableField("course_introduce_")
     @ApiModelProperty(value = "课程介绍")
     private String courseIntroduce;
@@ -260,5 +264,12 @@ public class CourseGroup implements Serializable {
         this.updatedTime = updatedTime;
     }
 
+    public Integer getCompleteCourseNum() {
+        return completeCourseNum;
+    }
+
+    public void setCompleteCourseNum(Integer completeCourseNum) {
+        this.completeCourseNum = completeCourseNum;
+    }
 }
 

+ 8 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/CourseScheduleEnum.java

@@ -36,9 +36,15 @@ public enum CourseScheduleEnum implements BaseEnum<String,CourseScheduleEnum> {
      * @param code   code
      * @param errMsg 错误异常
      */
-    public static void existCourseType(String code, String errMsg) {
+    public static CourseScheduleEnum existCourseType(String code, String errMsg) {
         CourseScheduleEnum[] values = {PRACTICE, LIVE};
         existCourse(values, code, errMsg);
+        //陪练课-校验学生时间是否交集
+        if (code.equals(CourseScheduleEnum.PRACTICE.getCode())) {
+            return CourseScheduleEnum.PRACTICE;
+        } else {
+            return CourseScheduleEnum.LIVE;
+        }
     }
 
     /**
@@ -52,7 +58,7 @@ public enum CourseScheduleEnum implements BaseEnum<String,CourseScheduleEnum> {
         existCourse(values, code, errMsg);
     }
 
-    private static void existCourse(CourseScheduleEnum[] values,String code,String errMsg){
+    private static void existCourse(CourseScheduleEnum[] values, String code, String errMsg) {
         List<String> collect = Arrays.stream(values).map(CourseScheduleEnum::getCode).collect(Collectors.toList());
         boolean typeFlag = collect.contains(code);
         if (!typeFlag) {

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseGroupService.java

@@ -2,7 +2,7 @@ package com.yonge.cooleshow.biz.dal.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.yonge.cooleshow.biz.dal.dao.CourseGroupDao;
-import com.yonge.cooleshow.biz.dal.dto.CheckLiveCourseTimeDto;
+import com.yonge.cooleshow.biz.dal.dto.CheckCourseTimeDto;
 import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto;
 import com.yonge.cooleshow.biz.dal.entity.CourseGroup;
 import com.yonge.cooleshow.biz.dal.entity.CourseTimeEntity;
@@ -47,7 +47,7 @@ public interface CourseGroupService extends IService<CourseGroup> {
     /**
      * 创建直播课程组时将课时写到缓存当作锁定的时间
      */
-    List<CourseTimeEntity> lockCourseToCache(CheckLiveCourseTimeDto dto);
+    List<CourseTimeEntity> lockCourseToCache(CheckCourseTimeDto dto);
 
     /**
      * 创建直播课程组-解除锁定课程时间-删除写到缓存当作锁定的课时

+ 8 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseScheduleService.java

@@ -121,6 +121,14 @@ public interface CourseScheduleService extends IService<CourseSchedule> {
     List<CourseCalendarEntity> createLiveCourseCalendar(Map<String, Object> param);
 
     /**
+     * 根据年份获取当年节假日
+     *
+     * @param year 年
+     * @return 年月日
+     */
+    List<String> getHoliday(int year);
+
+    /**
      * 生成陪练课日历-用于学生购买指定老师陪练课
      *
      * @param param 传入参数

+ 60 - 17
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseGroupServiceImpl.java

@@ -1,30 +1,29 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.constant.CourseConstant;
 import com.yonge.cooleshow.biz.dal.constant.LiveRoomConstant;
-import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.biz.dal.dao.CourseGroupDao;
-import com.yonge.cooleshow.biz.dal.dto.CheckLiveCourseTimeDto;
+import com.yonge.cooleshow.biz.dal.dto.CheckCourseTimeDto;
 import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto;
 import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto.CoursePlanDto;
-import com.yonge.cooleshow.biz.dal.entity.CourseGroup;
-import com.yonge.cooleshow.biz.dal.entity.CoursePlan;
-import com.yonge.cooleshow.biz.dal.entity.CourseSchedule;
-import com.yonge.cooleshow.biz.dal.entity.CourseTimeEntity;
+import com.yonge.cooleshow.biz.dal.entity.*;
 import com.yonge.cooleshow.biz.dal.enums.CourseGroupEnum;
 import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
 import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.biz.dal.support.PageUtil;
 import com.yonge.cooleshow.biz.dal.vo.CourseGroupVo;
 import com.yonge.cooleshow.biz.dal.vo.LiveCourseInfoVo;
+import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.common.exception.BizException;
 import com.yonge.cooleshow.common.page.PageInfo;
 import com.yonge.toolset.utils.date.DateUtil;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.redisson.api.RMap;
 import org.redisson.api.RedissonClient;
@@ -34,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDate;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -67,7 +67,8 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
     private SubjectService subjectService;
     @Autowired
     private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
-
+    @Autowired
+    private TeacherFreeTimeService teacherFreeTimeService;
 
     @Override
     public CourseGroupDao getDao() {
@@ -201,9 +202,11 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
     }
 
     /**
-     * 创建直播课程组时将课时写到缓存当作锁定时间
+     * 创建课时写到缓存锁定时间
      */
-    public List<CourseTimeEntity> lockCourseToCache(CheckLiveCourseTimeDto dto) {
+    public List<CourseTimeEntity> lockCourseToCache(CheckCourseTimeDto dto) {
+        //获取课程类型
+        CourseScheduleEnum courseType = CourseScheduleEnum.existCourseType(dto.getCourseType(), "课程类型不正确!");
         //先自校验传入时间是否交集
         List<CourseTimeEntity> timeList = dto.getTimeList();
         if (timeList.size() > 1) {
@@ -228,7 +231,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
         //需要自动补全课时
         if (dto.getLoop() == 1) {
             //自动排课,获取排课后所有的课程时间
-            List<CourseTimeEntity> allCourseTime = teacherAutoPlanningLiveCourseTime(dto.getTeacherId(), dto.getCourseNum(), timeList);
+            List<CourseTimeEntity> allCourseTime = autoPlanningLiveCourseTime(dto.getTeacherId(), dto.getCourseNum(), timeList, courseType);
             allCourseTime.sort(Comparator.comparing(CourseTimeEntity::getStartTime));
             //替换掉原有的课时
             dto.setTimeList(allCourseTime);
@@ -255,7 +258,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
     }
 
     /**
-     * 老师创建直播课自动排课
+     * 自动排课
      * <p>自动排课规则及场景:总5节课,填入2节,需要自动补3节
      * <p>1.把前面2节课的时间循环+1周直到填满5节课为止
      * <p>2.如果自动排课时的时间和未来课程时间有冲突则继续往后面延续一周
@@ -263,9 +266,24 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
      * @param teacherId      老师id
      * @param totalCourseNum 总课程数量
      * @param paramTimeList  当前课程的时间段
+     * @param courseType     PRACTICE陪练课  LIVE直播课
      * @return 自动排课后的全部课时
      */
-    private List<CourseTimeEntity> teacherAutoPlanningLiveCourseTime(Long teacherId, int totalCourseNum, List<CourseTimeEntity> paramTimeList) {
+    private List<CourseTimeEntity> autoPlanningLiveCourseTime(Long teacherId, int totalCourseNum, List<CourseTimeEntity> paramTimeList, CourseScheduleEnum courseType) {
+        //是否跳过节假日  0:不跳过 1跳过
+        boolean skipHoliday = false;
+        //true 陪练课
+        boolean courseTypeFlag = courseType.equals(CourseScheduleEnum.PRACTICE);
+        if (courseTypeFlag) {
+            //查询老师陪练课设置
+            TeacherFreeTime teacherTime = teacherFreeTimeService.getOne(Wrappers.<TeacherFreeTime>lambdaQuery()
+                    .eq(TeacherFreeTime::getDefaultFlag, true)
+                    .eq(TeacherFreeTime::getTeacherId, teacherId)
+            );
+            Optional.ofNullable(teacherTime).orElseThrow(() -> new BizException("未查询到老师陪练课设置!"));
+            skipHoliday = teacherTime.getSkipHolidayFlag();
+        }
+
         //获取当前课程
         int nowCourseNum = paramTimeList.size();
         //获取总课程数量 - 获取当前选择的课程数量 = 要自动排课的课程数量
@@ -276,16 +294,19 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
                 .collect(Collectors.toList());
         //获取最大排课周
         String maxWeekStr = sysConfigService.findConfigValue(SysConfigConstant.AUTO_PLANNING_COURSE_MAX_WEEK);
-        int maxWeek = 26;//默认 26周
+        int maxWeek = 26;//自动生成课时最大的生成周数  默认 26周
         if (StringUtils.isBlank(maxWeekStr)) {
             maxWeek = Integer.parseInt(maxWeekStr);
         }
+        //从第index课程开始生成时间
         int index = 0;
-        //自动补全课时
+        //节假日缓存数据,避免多次查询
+        Map<Integer, List<String>> holidayMap = new HashMap<>();
+        //开始自动补全课时
         for (int i = 0; i < diffCourse; i++) {
             //需要增加的周数
             AtomicInteger week = new AtomicInteger(1);
-            //是否要一直生成课程 true 一直增加周数并生成到不冲突的时间为止
+            //是否要一直生成课程 true一直增加周数并生成到不冲突的时间为止
             AtomicBoolean flag = new AtomicBoolean(true);
             //生成课程
             while (flag.get()) {
@@ -301,7 +322,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
                 Date autoStartDate = DateUtil.addWeeks(timeDto.getStartTime(), week.get());
                 Date autoEndDate = DateUtil.addWeeks(timeDto.getEndTime(), week.get());
 
-                //true  flag = true 并且 周数+1
+                //传入 ->true :周数+1   ->false:停止生成时间
                 Consumer<Boolean> con = (check) -> {
                     //check = true ,有交集延续1周后继续生成时间
                     if (check) {
@@ -312,8 +333,30 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
                     }
                 };
 
-                boolean checkTime;
+                //是否跳过节假日
+                if (skipHoliday) {
+                    //将自动生成的开始日期转换为字符串
+                    String dateStr = DateUtil.dateToString(autoStartDate);
+                    //取年份
+                    int calendarYear = LocalDate.parse(dateStr).getYear();
+                    //获取节假日信息
+                    List<String> holiday = Optional.of(calendarYear)
+                            .map(holidayMap::get)
+                            .filter(CollectionUtils::isNotEmpty)
+                            .orElseGet(() -> {
+                                List<String> list = courseScheduleService.getHoliday(calendarYear);
+                                holidayMap.put(calendarYear, list);
+                                return list;
+                            });
 
+                    //如果生成的日期是节假日 则跳过当前日期
+                    con.accept(holiday.contains(dateStr));
+                    if (flag.get()) {
+                        continue;
+                    }
+                }
+
+                boolean checkTime;
                 //若:传入时间是1号10点和8号10点,然后1号10点自动生成的课时是8号10点那么就和传入的8号10点冲突了,这种情况需要继续往后延续1周
                 checkTime = courseScheduleService.checkCourseTime(resultCourseTime, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime, autoStartDate, autoEndDate);
                 con.accept(checkTime);

+ 22 - 17
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -86,16 +86,19 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      *              <p> - subjectId 声部id
      */
     public PageInfo<TeacherLiveCourseInfoVo> queryTeacherLiveCourse(Map<String, Object> param) {
-        String status = WrapperUtil.toStr(param, "status", "课程状态不能为空!");
-        CourseScheduleEnum.existCourseState(status, "查询条件错误,课程状态不正确");
+        String status = WrapperUtil.toStr(param, "status");
+        if (StringUtils.isNotBlank(status)) {
+            CourseScheduleEnum.existCourseState(status, "查询条件错误,课程状态不正确");
+        }
+        param.put("status",status);
         String classDate = WrapperUtil.toStr(param, "classDate", "查询时间不能为空!");
-        String[] classDateSp = classDate.split("-");
         //本月的第一天
         LocalDate firstDay;
         try {
+            String[] classDateSp = classDate.split("-");
             firstDay = LocalDate.of(Integer.parseInt(classDateSp[0]), Integer.parseInt(classDateSp[1]), 1);
         } catch (Exception e) {
-            throw new BizException("查询时间格式不正确 ["+classDate+"]");
+            throw new BizException("查询时间格式不正确 [" + classDate + "]");
         }
         //本月的最后一天
         LocalDate lastDay = firstDay.with(TemporalAdjusters.lastDayOfMonth());
@@ -305,7 +308,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
             int calendarYear = LocalDate.parse(calendarEntity.getDate()).getYear();
             List<String> holiday = Optional.of(calendarYear)
                     .map(holidayMap::get)
-                    .filter(Objects::nonNull)
+                    .filter(CollectionUtils::isNotEmpty)
                     .orElseGet(() -> {
                         List<String> list = getHoliday(calendarYear);
                         holidayMap.put(calendarYear, list);
@@ -409,7 +412,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      * @param year 年
      * @return 年月日
      */
-    private List<String> getHoliday(int year) {
+    @Override
+    public List<String> getHoliday(int year) {
         HolidaysFestivals holidaysFestivals = holidaysFestivalsService.queryByYear(year);
         if (Objects.isNull(holidaysFestivals)) {
             return Collections.emptyList();
@@ -614,16 +618,16 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 
     /**
      * 老师端-首页-我的课程-陪练课
-     *      search:{"classMonth":"2022-03","status":"COMPLETE","subjectId":1}
-     *
+     * search:{"classMonth":"2022-03","status":"COMPLETE","subjectId":1}
+     * <p>
      * 老师端-首页-课后评价
-     *      search:{"classMonth":"2022-03","replied":0,"studentName":"测试王"}
-     *
+     * search:{"classMonth":"2022-03","replied":0,"studentName":"测试王"}
+     * <p>
      * 老师端-我的-我的主页
-     *      search:{"classMonth":"2022-03"}
-     *
+     * search:{"classMonth":"2022-03"}
+     * <p>
      * 老师端-课表
-     *      search:{"classDate":"2022-03-27"}
+     * search:{"classDate":"2022-03-27"}
      *
      * @Description: 根据老师id查询购课学员
      * @Author: cy
@@ -631,17 +635,17 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      */
     public IPage<MyCourseVo> queryTeacherPracticeCourse(IPage<MyCourseVo> page, MyCourseSearch search) {
         //查询所有已评价学生id
-        List<Long> studentList=repliedDao.selectAll();
+        List<Long> studentList = repliedDao.selectAll();
 
         Integer replied = search.getReplied();
-        if (replied!=null){
+        if (replied != null) {
             //按评价筛选 0:未评价 1:已评价
             if (replied == 0) {
                 //查询所有购课用户
-                List<Long> userList=paymentDao.selectAll();
+                List<Long> userList = paymentDao.selectAll();
                 //取差集
                 userList.removeAll(studentList);
-                if (userList.isEmpty()){
+                if (userList.isEmpty()) {
                     return page.setRecords(new ArrayList<>());
                 }
                 search.setRepliedIds(userList);
@@ -684,6 +688,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         CourseSchedule courseSchedule = this.getById(courseId);
         return teacherId.equals(courseSchedule.getTeacherId());
     }
+
     /**
      * @Description: 查询学生约课日历
      * @Author: cy

+ 17 - 23
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/LiveRoomServiceImpl.java

@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dao.LiveRoomDao;
-import com.yonge.cooleshow.biz.dal.dto.CheckLiveCourseTimeDto;
+import com.yonge.cooleshow.biz.dal.dto.CheckCourseTimeDto;
 import com.yonge.cooleshow.biz.dal.entity.*;
 import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
 import com.yonge.cooleshow.biz.dal.enums.RoomTypeEnum;
@@ -407,29 +407,23 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     }
 
     /**
-     * 查询用户是否在聊天室-不是实时的
+     * 学生购买直播课程
      *
-     * @param chatroomId 要查询的聊天室 ID(必传)
-     * @param userId     要查询的用户 ID(必传)
-     * @return true 在聊天室,false 不在聊天室
-     * <p>注意:有可能出现已退出聊天室后使用该功能查询,得到的结果是未退出聊天室
-     * <p>触发融云退出聊天室机制:
-     * <p>1.聊天室中用户在离线 30 秒后有新消息产生时状态改变为退出聊天室
-     * <p>2.离线后聊天室中产生 30 条消息时状态时状态改变为退出聊天室
+     * @param param 传入参数
+     *              <p> - groupId    直播课程组id
+     *              <p> - studentId    学员id
+     *              <p> - price 价格
      */
-    private boolean userExistInRoom(String chatroomId, String userId) {
-        log.info("userExistInRoom chatroomId : {}  userId : {}", chatroomId, userId);
-        IMApiResultInfo resultInfo;
-        try {
-            resultInfo = imHelper.isInChartRoom(chatroomId, userId);
-        } catch (Exception e) {
-            throw new BizException("查询失败" + e.getMessage());
-        }
-        if (!resultInfo.isSuccess()) {
-            log.error("userExistInRoom  chatroomId : {}  userId : {}", chatroomId, userId);
-            throw new BizException("查询失败!");
-        }
-        return resultInfo.isSuccess() && resultInfo.getInChrm();
+    public void buyLiveCourse(Map<String, Object> param) {
+        //锁定课程时间
+
+    }
+
+    /**
+     * 学生购买直播课程成功-回调成功
+     */
+    public void buyLiveCourseSuccess() {
+
     }
 
     private SysUser getSysUser(Long userId) {
@@ -503,7 +497,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         //result
         Map<String, Object> result = new HashMap<>();
         //模拟排课数据 测试用
-        CheckLiveCourseTimeDto dto = new CheckLiveCourseTimeDto();
+        CheckCourseTimeDto dto = new CheckCourseTimeDto();
         dto.setTeacherId(99L);
         dto.setCourseNum(6);
         dto.setLoop(1);

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/support/WrapperUtil.java

@@ -37,8 +37,8 @@ public class WrapperUtil {
                 .orElse(null);
     }
 
-    public static <S,O> Long toLong(Map<S, O> map, S str,String exMsg){
-       return Optional.ofNullable(map.get(str))
+    public static <S, O> Long toLong(Map<S, O> map, S str, String exMsg) {
+        return Optional.ofNullable(map.get(str))
                 .map(String::valueOf)
                 .map(Long::parseLong)
                 .orElseThrow(() -> new BizException(exMsg));

+ 4 - 3
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseGroupMapper.xml

@@ -9,6 +9,7 @@
         <result column="subject_id_" jdbcType="INTEGER" property="subjectId"/>
         <result column="single_course_minutes_" jdbcType="INTEGER" property="singleCourseMinutes"/>
         <result column="course_num_" jdbcType="INTEGER" property="courseNum"/>
+        <result column="complete_course_num_" jdbcType="INTEGER" property="completeCourseNum"/>
         <result column="course_introduce_" jdbcType="VARCHAR" property="courseIntroduce"/>
         <result column="course_price_" jdbcType="VARCHAR" property="coursePrice"/>
         <result column="status_" jdbcType="VARCHAR" property="status"/>
@@ -26,18 +27,18 @@
 
     <sql id="Base_Column_List">
         id_
-        , type_, teacher_id_, name_, subject_id_, single_course_minutes_, course_num_, course_introduce_, course_price_, status_, sales_start_date_, sales_end_date_, background_pic_, mix_student_num_,pre_student_num_, course_start_time_, created_by_, created_time_, updated_by_, updated_time_
+        , type_, teacher_id_, name_, subject_id_, single_course_minutes_, course_num_, complete_course_num_, course_introduce_, course_price_, status_, sales_start_date_, sales_end_date_, background_pic_, mix_student_num_,pre_student_num_, course_start_time_, created_by_, created_time_, updated_by_, updated_time_
     </sql>
 
     <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
             parameterType="com.yonge.cooleshow.biz.dal.entity.CourseGroup">
         insert into course_group(type_, teacher_id_, name_, subject_id_, single_course_minutes_, course_num_,
-        course_introduce_, course_price_, status_, sales_start_date_, sales_end_date_, background_pic_,
+        complete_course_num_, course_introduce_, course_price_, status_, sales_start_date_, sales_end_date_, background_pic_,
         mix_student_num_,pre_student_num_, course_start_time_, created_by_, created_time_, updated_by_, updated_time_)
         values
         <foreach collection="entities" item="entity" separator=",">
             (#{entity.type}, #{entity.teacherId}, #{entity.name}, #{entity.subjectId}, #{entity.singleCourseMinutes},
-            #{entity.courseNum}, #{entity.courseIntroduce}, #{entity.coursePrice}, #{entity.status},
+            #{entity.courseNum}, #{entity.completeCourseNum}, #{entity.courseIntroduce}, #{entity.coursePrice}, #{entity.status},
             #{entity.salesStartDate}, #{entity.salesEndDate}, #{entity.backgroundPic}, #{entity.mixStudentNum},
             #{entity.preStudentNum},#{entity.courseStartTime}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},
             #{entity.updatedTime})

+ 5 - 3
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -126,11 +126,13 @@
         left join course_group as b on a.course_group_id_ = b.id_
         left join subject as s on b.subject_id_ = s.id_
         where b.teacher_id_ = #{param.teacherId}
-        and a.lock_ = 0
-        and a.status_ = #{param.status}
-        and a.type_ = #{param.type}
+        AND a.lock_ = 0
+        AND a.type_ = #{param.type}
         <![CDATA[ AND a.class_date_  >= #{param.startDate} ]]>
         <![CDATA[ AND a.class_date_  <= #{param.endDate} ]]>
+        <if test="param.status !=null and param.status !=''">
+            AND a.status_ = #{param.status}
+        </if>
         <if test="param.subjectId != null">
             AND b.subject_id_ = #{param.subjectId}
         </if>

+ 36 - 38
cooleshow-user/user-biz/src/main/resources/config/mybatis/SubjectMapper.xml

@@ -19,16 +19,17 @@
 
     <!-- 根据主键查询一条记录 -->
     <select id="get" resultMap="Subject">
-		SELECT * FROM subject WHERE id_ = #{id}
+		SELECT * FROM subject WHERE del_flag_ = 0 and id_ = #{id}
 	</select>
 
     <!-- 全查询 -->
     <select id="findAll" resultMap="Subject">
-		SELECT * FROM subject ORDER BY id_
+		SELECT * FROM subject where del_flag_ = 0 ORDER BY id_
 	</select>
 
     <!-- 向数据库增加一条记录 -->
-    <insert id="insert" parameterType="com.yonge.cooleshow.biz.dal.entity.Subject" useGeneratedKeys="true" keyColumn="id"
+    <insert id="insert" parameterType="com.yonge.cooleshow.biz.dal.entity.Subject" useGeneratedKeys="true"
+            keyColumn="id"
             keyProperty="id">
         INSERT INTO subject (id_,name_,code_,parent_subject_id_,img_,create_time_,update_time_,desc_)
         VALUES(#{id},#{name},#{code},#{parentSubjectId},#{img},now(),now(),#{desc})
@@ -68,6 +69,10 @@
         UPDATE `subject` SET del_flag_ = 1 WHERE id_ = #{id} OR parent_subject_id_ = #{id}
 	</update>
 
+    <delete id="deleteById">
+		update subject set del_flag_ = 1 where id_ = #{id} or parent_subject_id_ = #{id}
+	</delete>
+
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="Subject" parameterType="map">
         SELECT * FROM subject
@@ -78,39 +83,35 @@
 
     <!-- 查询当前表的总记录数 -->
     <select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM subject <include refid="querySubPageSql"/>
-	</select>
+        SELECT COUNT(*) FROM subject
+        <include refid="querySubPageSql"/>
+    </select>
 
     <select id="findByParentId" resultMap="Subject">
         SELECT * FROM subject
-        <where>
-            <if test="parentId != null">
-                AND parent_subject_id_ = #{parentId}
-            </if>
-            <if test="delFlag != null">
-                AND del_flag_ = #{delFlag}
-            </if>
-        </where>
+        where del_flag_ = 0
+        <if test="parentId != null">
+            AND parent_subject_id_ = #{parentId}
+        </if>
     </select>
 
     <sql id="querySubPageSql">
-        <where>
-            <if test="parentId != null">
-                AND parent_subject_id_ = #{parentId}
-            </if>
-            <if test="delFlag != null">
-                AND del_flag_ = #{delFlag}
-            </if>
-            <if test="search != null and search != ''">
-                AND (id_ like concat('%',#{search},'%') or name_ like concat('%',#{search},'%'))
-            </if>
-            <if test="queryType != null and queryType == 'category'">
-            	and (parent_subject_id_ = 0 or parent_subject_id_ is null)
-            </if>
-            <if test="queryType != null and queryType == 'list'">
-            	and parent_subject_id_ > 0
-            </if>
-        </where>
+        where del_flag_ = 0
+        <if test="parentId != null">
+            AND parent_subject_id_ = #{parentId}
+        </if>
+        <if test="delFlag != null">
+            AND del_flag_ = #{delFlag}
+        </if>
+        <if test="search != null and search != ''">
+            AND (id_ like concat('%',#{search},'%') or name_ like concat('%',#{search},'%'))
+        </if>
+        <if test="queryType != null and queryType == 'category'">
+            and (parent_subject_id_ = 0 or parent_subject_id_ is null)
+        </if>
+        <if test="queryType != null and queryType == 'list'">
+            and parent_subject_id_ > 0
+        </if>
     </sql>
 
     <select id="findBySubjectByIdList" resultMap="Subject">
@@ -118,17 +119,14 @@
     </select>
 
     <select id="findBySubjectIds" resultMap="Subject">
-      SELECT * FROM subject WHERE id_ IN
-      <foreach collection="subjectIds" item="subjectId" separator="," open="(" close=")">
-          #{subjectId}
-      </foreach>
+        SELECT * FROM subject WHERE del_flag_ = 0 and id_ IN
+        <foreach collection="subjectIds" item="subjectId" separator="," open="(" close=")">
+            #{subjectId}
+        </foreach>
     </select>
     <select id="selectSubjectById" resultType="com.yonge.cooleshow.biz.dal.entity.Subject"
             parameterType="java.lang.String">
-        SELECT * FROM subject WHERE id_=#{lessonSubject}
+        SELECT * FROM subject WHERE del_flag_ = 0 and id_=#{lessonSubject}
     </select>
 
-    <delete id="deleteById">
-		update subject set del_flag_ = 1 where id_ = #{id} or parent_subject_id_ = #{id}
-	</delete>
 </mapper>

+ 2 - 2
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/CourseGroupController.java

@@ -1,7 +1,7 @@
 package com.yonge.cooleshow.teacher.controller;
 
 
-import com.yonge.cooleshow.biz.dal.dto.CheckLiveCourseTimeDto;
+import com.yonge.cooleshow.biz.dal.dto.CheckCourseTimeDto;
 import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto;
 import com.yonge.cooleshow.biz.dal.entity.CourseTimeEntity;
 import com.yonge.cooleshow.biz.dal.service.CourseGroupService;
@@ -60,7 +60,7 @@ public class CourseGroupController extends BaseController {
 
     @ApiOperation("创建直播课程组-锁定课程时间-将课时写到缓存当作锁定的时间")
     @PostMapping("/lockCourseToCache")
-    public HttpResponseResult<List<CourseTimeEntity>> lockCourseToCache(@RequestBody CheckLiveCourseTimeDto dto) {
+    public HttpResponseResult<List<CourseTimeEntity>> lockCourseToCache(@RequestBody CheckCourseTimeDto dto) {
         return succeed(courseGroupService.lockCourseToCache(dto));
     }