Browse Source

优化部分直播课返回学员及教师名称的问题

hgw 2 years ago
parent
commit
f20c0dc1ad

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

@@ -83,6 +83,10 @@ public class CourseGroup implements Serializable {
     @ApiModelProperty(value = "预计上课人数")
     private Integer preStudentNum;
 
+    @TableField("im_group_id_")
+    @ApiModelProperty(value = "直播课成课后生成的im群id")
+    private String imGroupId;
+
     @TableField("course_start_time_")
     @ApiModelProperty(value = "课程开始时间")
     private Date courseStartTime;
@@ -224,6 +228,14 @@ public class CourseGroup implements Serializable {
         this.preStudentNum = preStudentNum;
     }
 
+    public String getImGroupId() {
+        return imGroupId;
+    }
+
+    public void setImGroupId(String imGroupId) {
+        this.imGroupId = imGroupId;
+    }
+
     public Date getCourseStartTime() {
         return courseStartTime;
     }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/ImGroupService.java

@@ -33,7 +33,7 @@ public interface ImGroupService extends IService<ImGroup> {
     * @author zx
     * @date 2022/3/22 11:17
     */
-    void autoCreate(Long courseGroupId,String courseGroupType) throws Exception;
+    String autoCreate(Long courseGroupId,String courseGroupType) throws Exception;
 
     /**
     * @description: 关闭群聊、解散

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

@@ -80,6 +80,8 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
     private TeacherFreeTimeService teacherFreeTimeService;
     @Autowired
     private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
+    @Autowired
+    private ImGroupService imGroupService;
 
     @Override
     public CourseGroupDao getDao() {
@@ -267,7 +269,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
         timeList.forEach(o -> {
             boolean checkDataTime = courseScheduleService.checkTeacherCourseTime(teacherId, startTimeFun.apply(o), endTimeFun.apply(o));
             if (checkDataTime) {
-                throw new BizException("预计安排在" + DateUtil.dateToString(startTimeFun.apply(o), "yyyy年MM月dd号 HH点mm分") + "的课程已被学员选择!");
+                throw new BizException("预计安排在" + DateUtil.dateToString(startTimeFun.apply(o), "yyyy年MM月dd号 HH点mm分") + "的课程时间存在冲突!");
             }
         });
     }
@@ -709,6 +711,11 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
             if (courseGroup.getPreStudentNum() >= courseGroup.getMixStudentNum()) {
                 //人数达标则修改课程组为进行中状态
                 courseGroup.setStatus(CourseGroupEnum.ING.getCode());
+                try {
+                //建立群组
+                String imGroupId = imGroupService.autoCreate(courseGroup.getId(), courseGroup.getType());
+                } catch (Exception ignored) {
+                }
             } else {
                 //人数未达标则修改课程组为取消状态
                 courseGroup.setStatus(CourseGroupEnum.CANCEL.getCode());

+ 11 - 10
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ImGroupServiceImpl.java

@@ -79,17 +79,17 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void autoCreate(Long courseGroupId,String courseGroupType) throws Exception {
+    public String autoCreate(Long courseGroupId, String courseGroupType) throws Exception {
         //获取课程组
         CourseGroup courseGroup = courseGroupService.getById(courseGroupId);
-        if(courseGroup.getTeacherId() == null){
-            return;
+        if (courseGroup.getTeacherId() == null) {
+            return null;
         }
         //获取学员列表
         Set<Long> studentIds = courseScheduleStudentPaymentDao.queryStudentIds(courseGroupId, courseGroupType);
         studentIds.removeAll(Collections.singleton(null));
-        if(CollectionUtils.isEmpty(studentIds)){
-            return;
+        if (CollectionUtils.isEmpty(studentIds)) {
+            return null;
         }
         Date now = new Date();
         Long teacherId = courseGroup.getTeacherId();
@@ -102,18 +102,19 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
         imGroup.setType(ImGroup.ImGroupType.COURSE);
         imGroup.setCreateTime(now);
         imGroup.setUpdateTime(now);
-        String imGroupId = UUID.randomUUID().toString() + imGroup.getType().getCode();
+        String imGroupId = UUID.randomUUID() + imGroup.getType().getCode();
         imGroup.setId(imGroupId);
         this.baseMapper.insert(imGroup);
         //保存老师学员关联的通讯录
-        imUserFriendService.saveUserFriend(teacherId,studentIds);
+        imUserFriendService.saveUserFriend(teacherId, studentIds);
         //处理本地群成员列表
         List<GroupMember> groupMembers = imGroupMemberService.initGroupMember(imGroupId, imGroup.getCreateBy(), true, ImGroupMember.ImGroupMemberRoleType.TEACHER);
-        groupMembers.addAll(imGroupMemberService.initGroupMembers(imGroupId,studentIds,ImGroupMember.ImGroupMemberRoleType.STUDENT));
+        groupMembers.addAll(imGroupMemberService.initGroupMembers(imGroupId, studentIds, ImGroupMember.ImGroupMemberRoleType.STUDENT));
         //创建融云群
-        this.rtcCreate(courseGroup.getTeacherId(),imGroupId,imGroup.getName());
+        this.rtcCreate(courseGroup.getTeacherId(), imGroupId, imGroup.getName());
         //加入融云群
-        imGroupMemberService.join(groupMembers,imGroupId);
+        imGroupMemberService.join(groupMembers, imGroupId);
+        return imGroupId;
     }
 
     //创建融云群

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/CourseGroupVo.java

@@ -70,6 +70,9 @@ public class CourseGroupVo implements Serializable {
     @ApiModelProperty(value = "最少成课人数")
     private Integer mixStudentNum;
 
+    @ApiModelProperty(value = "直播课成课后生成的im群id")
+    private String imGroupId;
+
     public Long getCourseGroupId() {
         return courseGroupId;
     }
@@ -205,4 +208,12 @@ public class CourseGroupVo implements Serializable {
     public void setMixStudentNum(Integer mixStudentNum) {
         this.mixStudentNum = mixStudentNum;
     }
+
+    public String getImGroupId() {
+        return imGroupId;
+    }
+
+    public void setImGroupId(String imGroupId) {
+        this.imGroupId = imGroupId;
+    }
 }

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/CourseStudent.java

@@ -54,6 +54,9 @@ public class CourseStudent implements Serializable {
     @ApiModelProperty(value = "头像")
     private String avatar;
 
+    @ApiModelProperty(value = "直播课成课后生成的im群id")
+    private String imGroupId;
+
     public Integer getCourseId() {
         return courseId;
     }
@@ -165,5 +168,13 @@ public class CourseStudent implements Serializable {
     public void setAvatar(String avatar) {
         this.avatar = avatar;
     }
+
+    public String getImGroupId() {
+        return imGroupId;
+    }
+
+    public void setImGroupId(String imGroupId) {
+        this.imGroupId = imGroupId;
+    }
 }
 

+ 10 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/LiveCourseGroupVo.java

@@ -17,7 +17,6 @@ import java.util.Date;
 @ApiModel("平台方 老师详情直播课列表")
 public class LiveCourseGroupVo {
 
-
     @ApiModelProperty("课程组编号")
     private Long courseGroupId;
 
@@ -52,6 +51,8 @@ public class LiveCourseGroupVo {
     @ApiModelProperty("课程简介")
     private String courseIntroduce;
 
+    @ApiModelProperty(value = "直播课成课后生成的im群id")
+    private String imGroupId;
 
     public Long getCourseNum() {
         return courseNum;
@@ -140,4 +141,12 @@ public class LiveCourseGroupVo {
     public void setStatus(CourseGroupEnum status) {
         this.status = status;
     }
+
+    public String getImGroupId() {
+        return imGroupId;
+    }
+
+    public void setImGroupId(String imGroupId) {
+        this.imGroupId = imGroupId;
+    }
 }

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/TeacherLiveCourseInfoVo.java

@@ -40,6 +40,9 @@ public class TeacherLiveCourseInfoVo implements Serializable {
     @ApiModelProperty(value = "课程图片")
     private String backgroundPic;
 
+    @ApiModelProperty(value = "直播课成课后生成的im群id")
+    private String imGroupId;
+
     public Long getCourseGroupId() {
         return courseGroupId;
     }
@@ -103,4 +106,12 @@ public class TeacherLiveCourseInfoVo implements Serializable {
     public void setBackgroundPic(String backgroundPic) {
         this.backgroundPic = backgroundPic;
     }
+
+    public String getImGroupId() {
+        return imGroupId;
+    }
+
+    public void setImGroupId(String imGroupId) {
+        this.imGroupId = imGroupId;
+    }
 }

+ 9 - 6
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseGroupMapper.xml

@@ -23,24 +23,25 @@
         <result column="updated_by_" jdbcType="INTEGER" property="updatedBy"/>
         <result column="updated_time_" jdbcType="TIMESTAMP" property="updatedTime"/>
         <result column="pre_student_num_" jdbcType="INTEGER" property="preStudentNum"/>
+        <result column="im_group_id_" jdbcType="VARCHAR" property="imGroupId"/>
     </resultMap>
 
     <sql id="Base_Column_List">
         id_
-        , 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_
+        , 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_, im_group_id_, 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_,
         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_)
+        mix_student_num_,pre_student_num_,im_group_id_, 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.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.preStudentNum},#{entity.imGroupId},#{entity.courseStartTime}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},
             #{entity.updatedTime})
         </foreach>
     </insert>
@@ -51,7 +52,7 @@
         b.name_                       as courseGroupName,
         s.name_                       as subjectName,
         b.teacher_id_                 as teacherId,
-        u.real_name_                  as teacherName,
+        u.username_                  as teacherName,
         b.course_start_time_          as courseStartTime,
         b.single_course_minutes_      as singleCourseMinutes,
         b.status_                     as `status`,
@@ -62,7 +63,8 @@
         u.avatar_ as avatar,
         b.sales_start_date_           as salesStartDate,
         b.sales_end_date_             as salesEndDate,
-        b.mix_student_num_            as mixStudentNum
+        b.mix_student_num_            as mixStudentNum,
+        b.im_group_id_              as imGroupId
         from course_group as b
         left join subject as s on b.subject_id_ = s.id_
         left join sys_user as u on b.teacher_id_ = u.id_
@@ -96,7 +98,8 @@
         cg.status_ as status,
         cg.course_num_ as courseNum,
         cg.created_time_ as createTime,
-        cg.course_introduce_ as courseIntroduce
+        cg.course_introduce_ as courseIntroduce,
+        cg.im_group_id_  as imGroupId
         from course_group cg
         left join course_schedule_student_payment cssp on cg.id_ = cssp.course_group_id_
         <if test="param.search != null and param.search != ''">

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

@@ -121,7 +121,8 @@
         a.end_time_ as endTime,
         a.status_ as `status`,
         b.pre_student_num_ as studentCount,
-        b.background_pic_ as backgroundPic
+        b.background_pic_ as backgroundPic,
+        b.im_group_id_  as imGroupId
         from course_schedule as a
         left join course_group as b on a.course_group_id_ = b.id_
         left join subject as s on b.subject_id_ = s.id_
@@ -137,6 +138,7 @@
             AND b.subject_id_ = #{param.subjectId}
         </if>
     </select>
+
     <select id="queryTeacherPracticeCourse" resultType="com.yonge.cooleshow.biz.dal.vo.MyCourseVo">
         SELECT
             u.id_ AS userId,
@@ -222,6 +224,7 @@
         <![CDATA[ AND s.class_date_  >= #{startDate} ]]>
         <![CDATA[ AND s.class_date_  <= #{endDate} ]]>
     </select>
+
     <select id="queryStudentPracticeCourse" resultType="com.yonge.cooleshow.biz.dal.vo.MyCourseVo">
         SELECT
             s.id_ AS courseId,
@@ -313,6 +316,7 @@
         AND cs.class_date_=#{param.classDate}
         ORDER BY startTime
     </select>
+
     <select id="queryCourseScheduleStudent" resultType="java.lang.String"
             parameterType="com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch">
         SELECT class_date_ FROM course_schedule
@@ -320,6 +324,7 @@
         <![CDATA[ AND class_date_  >= #{startDate} ]]>
         <![CDATA[ AND class_date_  <= #{endDate} ]]>
     </select>
+
     <select id="teacherList" resultType="com.yonge.cooleshow.biz.dal.vo.PracticeTeacherVo">
         SELECT
         t.user_id_ AS teacherId,
@@ -410,13 +415,14 @@
         cs.end_time_ AS endTime,
         cs.status_ AS `status`,
         cs.type_ AS courseType,
-        su.real_name_ AS userId,
+        su.username_ AS userId,
         CONCAT(g.name_,'-第',cs.class_num_,'课') AS name,
         IFNULL(g.pre_student_num_, 0) AS payCount,
         g.background_pic_ AS cover,
         g.subject_id_ AS subjectId,
         sb.name_ AS subjectName,
-        su.avatar_ AS avatar
+        su.avatar_ AS avatar,
+        g.im_group_id_  as imGroupId
         FROM
         course_schedule_student_payment as a
         LEFT JOIN course_schedule cs on a.course_id_ = cs.id_