Explorar o código

Merge remote-tracking branch 'origin/master'

liweifan %!s(int64=3) %!d(string=hai) anos
pai
achega
cac4a0a0b3

+ 21 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/constant/SysConfigConstant.java

@@ -150,4 +150,25 @@ public interface SysConfigConstant {
      * 琴房学员解绑未上课天数
      */
     String PIANO_ROOM_UNBIND_DAYS = "piano_room_unbind_days";
+    
+    /**
+     * @Description: 琴房课最大学员容量
+     * @Author: cy
+     * @Date: 2022/6/1
+     */
+    String PIANO_ROOM_MAX_STUDENTS = "piano_room_max_students";
+    
+    /**
+     * @Description: 提前XX分钟创建/进入琴房课房间时间
+     * @Author: cy
+     * @Date: 2022/6/1
+     */
+    String PRE_CREATE_PIANO_ROOM_MINUTE = "pre_create_piano_room_minute";
+    
+    /**
+     * @Description: 琴房课结束后,XX分钟关闭房间
+     * @Author: cy
+     * @Date: 2022/6/1
+     */
+    String DESTROY_EXPIRED_PIANO_ROOM_MINUTE = "destroy_expired_piano_room_minute";
 }

+ 1 - 0
cooleshow-gateway/gateway-web/src/main/java/com/yonge/gateway/web/config/SwaggerDocumentConfig.java

@@ -26,6 +26,7 @@ public class SwaggerDocumentConfig implements SwaggerResourcesProvider {
 		resources.add(swaggerResource("ADMIN服务", "/admin-server/v2/api-docs", "2.0"));
 		resources.add(swaggerResource("MALL_ADMIN服务", "/mall-admin-server/v2/api-docs", "2.0"));
 		resources.add(swaggerResource("MALL_PORTAL服务", "/mall-portal-server/v2/api-docs", "2.0"));
+		resources.add(swaggerResource("网络教室", "/classroom-server/v2/api-docs", "2.0"));
 		return resources;
 	}
 

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

@@ -100,6 +100,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
     private UserBindingTeacherDao userBindingTeacherDao;
     @Autowired
     private CourseScheduleRecordDao recordDao;
+    @Autowired
+    private ImGroupService imGroupService;
 
     @Override
     public CourseScheduleDao getDao() {
@@ -1609,6 +1611,11 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         List<CourseTimeEntity> timeList = arrangeCourseVo.getTimeList();//选课时间
         Integer consumeTime = arrangeCourseVo.getConsumeTime();
 
+        Integer configValue = Integer.valueOf(sysConfigService.findConfigValue(SysConfigConstant.PIANO_ROOM_MAX_STUDENTS));
+        if (studentIds.size()>configValue){
+            throw new BizException("成课学员人数超过房间最大容量{}",configValue);
+        }
+
         //校验课时
         if (timeList.size() != classNum) {
             throw new BizException("课时数与排课数不符");
@@ -1621,6 +1628,9 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 
         //校验上下课时间
         for (int i = 0; i < timeList.size(); i++) {
+            if (timeList.get(i).getStartTime().before(new Date())){
+                throw new BizException("上课时间必须大于当前时间");
+            }
             if (!DateUtil.offsetMinute(timeList.get(i).getStartTime(), singleClssTime).equals(timeList.get(i).getEndTime())) {
                 throw new BizException("第{}节课结束时间计算错误", i + 1);
             }
@@ -1719,6 +1729,14 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         roomTime.setRemainTime(remainTime - consumTime);
         roomTime.setFrozenTime(frozenTime + consumTime);
         pianoRoomTimeDao.update(roomTime, Wrappers.<PianoRoomTime>lambdaQuery().eq(PianoRoomTime::getTeacherId, teacherId));
+
+        //创建群聊
+        try {
+            imGroupService.autoCreate(courseGroup.getId(),CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
+        } catch (Exception e) {
+            log.error("琴房课程组id:{},创建群聊失败:{}",courseGroup.getId(),e);
+            e.printStackTrace();
+        }
     }
 
     /**
@@ -1815,8 +1833,15 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         //更新组课程数
         Long groupId = schedule.getCourseGroupId();
         Integer count = baseMapper.selectCount(Wrappers.<CourseSchedule>lambdaQuery().eq(CourseSchedule::getCourseGroupId, groupId));
-        if (count == 0) {
+        if (count == 0) {//组内课程为0,删除课程组
             courseGroupService.getDao().deleteById(groupId);
+
+            //解散群聊
+            try {
+                imGroupService.dismiss(String.valueOf(groupId));
+            } catch (Exception e) {
+                log.error("琴房课程组id:{},关闭群聊失败:{}",groupId,e);
+            }
         } else {
             courseGroupService.update(null, Wrappers.<CourseGroup>lambdaUpdate()
                     .eq(CourseGroup::getId, groupId)
@@ -1843,6 +1868,10 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         courseTime.setEndTime(endTime);
         List<CourseTimeEntity> timeList = Arrays.asList(courseTime);
 
+        if (startTime.before(new Date())){
+            throw new BizException("上课时间必须大于当前时间");
+        }
+
         CourseSchedule courseSchedule = baseMapper.selectOne(Wrappers.<CourseSchedule>lambdaQuery()
                 .eq(CourseSchedule::getId, courseId)
                 .eq(CourseSchedule::getTeacherId, teacherId)
@@ -1890,6 +1919,12 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         Long teacherId = WrapperUtil.toLong(param, "teacherId", "老师id不能为空!");
         List<Integer> studentIdsList = (List<Integer>) param.get("studentIds");
         List<Long> studentIds = JSONArray.parseArray(studentIdsList.toString(), Long.class);
+
+        Integer configValue = Integer.valueOf(sysConfigService.findConfigValue(SysConfigConstant.PIANO_ROOM_MAX_STUDENTS));
+        if (studentIds.size()>configValue){
+            throw new BizException("成课学员人数超过房间最大容量{}",configValue);
+        }
+
         if (CollectionUtils.isEmpty(studentIds)) {
             throw new BizException("学生id不能为空");
         }