Jelajahi Sumber

Merge remote-tracking branch 'origin/master'

zouxuan 3 tahun lalu
induk
melakukan
7c796c6020
33 mengubah file dengan 1207 tambahan dan 273 penghapusan
  1. 42 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/dto/UserSetReq.java
  2. 63 0
      cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/vo/UserSetVo.java
  3. 20 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysUserDao.java
  4. 19 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserService.java
  5. 12 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserServiceImpl.java
  6. 33 0
      cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/UserController.java
  7. 27 0
      cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysUserMapper.xml
  8. 103 0
      cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/StudentController.java
  9. 2 21
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/TeacherDao.java
  10. 14 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/TeacherStyleVideoDao.java
  11. 3 7
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/req/TeacherApplyDetailReq.java
  12. 2 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/req/UserSetReq.java
  13. 56 14
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/RoomInfoCache.java
  14. 83 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/RoomUserInfoCache.java
  15. 2 17
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/Student.java
  16. 112 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/TeacherStyleVideo.java
  17. 7 3
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/LiveRoomService.java
  18. 0 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/StudentService.java
  19. 3 17
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TeacherService.java
  20. 25 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TeacherStyleVideoService.java
  21. 203 68
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/LiveRoomServiceImpl.java
  22. 14 13
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherServiceImpl.java
  23. 18 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherStyleVideoServiceImpl.java
  24. 9 8
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/support/IMHelper.java
  25. 105 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/StudentHomeVo.java
  26. 1 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/TeacherHomeVo.java
  27. 33 6
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/TeacherVo.java
  28. 69 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/UserSetVo.java
  29. 0 27
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherMapper.xml
  30. 30 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherStyleVideoMapper.xml
  31. 91 43
      cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/StudentController.java
  32. 2 25
      cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherController.java
  33. 4 0
      toolset/utils/src/main/java/com/yonge/toolset/utils/date/DateUtil.java

+ 42 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/dto/UserSetReq.java

@@ -0,0 +1,42 @@
+package com.yonge.cooleshow.auth.api.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author: liweifan
+ * @Data: 2022/3/22 11:00
+ */
+@ApiModel(value = "UserSetReq对象", description = "用户设置请求对象")
+public class UserSetReq {
+    @ApiModelProperty("头像地址")
+    private String avatar;
+    @ApiModelProperty("昵称")
+    private String username;
+    @ApiModelProperty(value = "性别 0女 1男")
+    private Integer gender;
+
+    public String getAvatar() {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar) {
+        this.avatar = avatar;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public Integer getGender() {
+        return gender;
+    }
+
+    public void setGender(Integer gender) {
+        this.gender = gender;
+    }
+}

+ 63 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/vo/UserSetVo.java

@@ -0,0 +1,63 @@
+package com.yonge.cooleshow.auth.api.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ *
+ * @Author: liweifan
+ * @Data: 2022/3/24 16:28
+ */
+@ApiModel(value = "UserSetVo对象", description = "用户设置页面查询")
+public class UserSetVo {
+    @ApiModelProperty("头像地址")
+    private String avatar;
+    @ApiModelProperty("昵称")
+    private String username;
+    @ApiModelProperty(value = "性别 0女 1男")
+    private Integer gender;
+    @ApiModelProperty(value = "手机号")
+    private String phone;
+    @ApiModelProperty(value = "是否实名 0否 1是")
+    private Boolean isReal;
+
+    public String getAvatar() {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar) {
+        this.avatar = avatar;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public Integer getGender() {
+        return gender;
+    }
+
+    public void setGender(Integer gender) {
+        this.gender = gender;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public Boolean getReal() {
+        return isReal;
+    }
+
+    public void setReal(Boolean real) {
+        isReal = real;
+    }
+}

+ 20 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/dal/dao/SysUserDao.java

@@ -3,6 +3,8 @@ package com.yonge.cooleshow.auth.dal.dao;
 import java.util.List;
 
 import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
+import com.yonge.cooleshow.auth.api.dto.UserSetReq;
+import com.yonge.cooleshow.auth.api.vo.UserSetVo;
 import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
 import org.apache.ibatis.annotations.Param;
 
@@ -104,4 +106,22 @@ public interface SysUserDao extends BaseDAO<Long, SysUser> {
 	 * @return: java.lang.Integer
 	 */
 	Integer updateUserCard(@Param("param")RealnameAuthReq param,@Param("idcardInfo") IdcardInfoExtractor idcardInfo);
+
+	/***
+	 * 查询老师设置详情
+	 * @author liweifan
+	 * @param: id
+	 * @updateTime 2022/3/22 10:24
+	 * @return: com.yonge.cooleshow.biz.dal.vo.TeacherVo
+	 */
+	UserSetVo getSetDetail(@Param("id") Long id);
+
+	/***
+	 * 修改老师设置信息
+	 * @author liweifan
+	 * @param: setReq
+	 * @param: id
+	 * @updateTime 2022/3/22 11:06
+	 */
+	void updatetSetDetail(@Param("param") UserSetReq setReq, @Param("id") Long id);
 }

+ 19 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/SysUserService.java

@@ -2,7 +2,9 @@ package com.yonge.cooleshow.auth.service;
 
 import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
 import com.yonge.cooleshow.auth.api.dto.SysUserInfo;
+import com.yonge.cooleshow.auth.api.dto.UserSetReq;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.api.vo.UserSetVo;
 import com.yonge.cooleshow.common.entity.ImUserModel;
 import com.yonge.cooleshow.common.service.BaseService;
 import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
@@ -151,4 +153,21 @@ public interface SysUserService extends BaseService<Long, SysUser> {
      * @return: java.lang.Integer
      */
     void updateUserCard(RealnameAuthReq realNameAuthDto, IdcardInfoExtractor idcardInfoExtractor);
+
+    /***
+     * 用户设置页面详情
+     * @author liweifan
+     * @param: id
+     * @updateTime 2022/3/22 10:22
+     * @return: com.yonge.cooleshow.biz.dal.vo.TeacherVo
+     */
+    UserSetVo getSetDetail(Long id);
+    /***
+     * 用户设置
+     * @author liweifan
+     * @param: setReq
+     * @param: id
+     * @updateTime 2022/3/22 11:04
+     */
+    void submitSetDetail(UserSetReq setReq, Long id);
 }

+ 12 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserServiceImpl.java

@@ -4,6 +4,8 @@ import java.util.Date;
 import java.util.List;
 
 import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
+import com.yonge.cooleshow.auth.api.dto.UserSetReq;
+import com.yonge.cooleshow.auth.api.vo.UserSetVo;
 import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -187,4 +189,14 @@ public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implement
         sysUserDao.updateUserCard(realNameAuthDto, idcardInfoExtractor);
     }
 
+    @Override
+    public UserSetVo getSetDetail(Long id) {
+        return sysUserDao.getSetDetail(id);
+    }
+
+    @Override
+    public void submitSetDetail(UserSetReq setReq, Long id) {
+        sysUserDao.updatetSetDetail(setReq, id);
+    }
+
 }

+ 33 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/UserController.java

@@ -2,6 +2,8 @@ package com.yonge.cooleshow.auth.web.controller;
 
 import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
 import com.yonge.cooleshow.auth.api.dto.UpdatePasswordDto;
+import com.yonge.cooleshow.auth.api.dto.UserSetReq;
+import com.yonge.cooleshow.auth.api.vo.UserSetVo;
 import com.yonge.cooleshow.common.constant.CommonConstants;
 import com.yonge.toolset.thirdparty.user.realname.RealnameAuthenticationPlugin;
 import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
@@ -449,4 +451,35 @@ public class UserController extends BaseController {
         }
         return succeed(idcardInfoExtractor);
     }
+
+    @GetMapping("/getSetDetail")
+    @ApiOperation(value = "获取设置详情")
+    public HttpResponseResult<UserSetVo> getSetDetail() {
+        AuthUser authUser = SecurityUtils.getUser();
+        if (authUser == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        SysUser user = sysUserService.get(authUser.getUserId());
+        if (user == null) {
+            return failed("用户不存在");
+        }
+        UserSetVo detail = sysUserService.getSetDetail(user.getId());
+        return succeed(detail);
+    }
+
+    @PostMapping("/submitSetDetail")
+    @ApiOperation(value = "修改设置信息", notes = "传入teacher")
+    public HttpResponseResult<UserSetVo> submitSetDetail(@RequestBody UserSetReq setReq) {
+        AuthUser authUser = SecurityUtils.getUser();
+        if (authUser == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        SysUser user = sysUserService.get(authUser.getUserId());
+        if (user == null) {
+            return failed("用户不存在");
+        }
+        //设置
+        sysUserService.submitSetDetail(setReq, user.getId());
+        return succeed(sysUserService.getSetDetail(user.getId()));
+    }
 }

+ 27 - 0
cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysUserMapper.xml

@@ -225,4 +225,31 @@
         </set>
         WHERE id_ = #{param.userId}
     </update>
+
+    <select id="getSetDetail" resultType="com.yonge.cooleshow.auth.api.vo.UserSetVo">
+        SELECT
+            u.avatar_ as avatar,
+            u.username_ as username,
+            u.gender_ as gender,
+            u.phone_ as phone,
+            (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal
+        FROM sys_user u
+        where u.id_ = #{id}
+    </select>
+
+    <update id="updatetSetDetail">
+        UPDATE sys_user
+        <set>
+            <if test="param.avatar != null and param.avatar != ''">
+                avatar_ = #{param.avatar},
+            </if>
+            <if test="param.username != null and param.username != ''">
+                username_ = #{param.username},
+            </if>
+            <if test="param.gender != null">
+                gender_ = #{param.gender},
+            </if>
+        </set>
+        WHERE id_ = #{id}
+    </update>
 </mapper>

+ 103 - 0
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/StudentController.java

@@ -0,0 +1,103 @@
+package com.yonge.cooleshow.admin.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.Student;
+import com.yonge.cooleshow.biz.dal.entity.Teacher;
+import com.yonge.cooleshow.biz.dal.service.StudentService;
+import com.yonge.cooleshow.biz.dal.support.Condition;
+import com.yonge.cooleshow.biz.dal.support.Query;
+import com.yonge.cooleshow.biz.dal.vo.TeacherHomeVo;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.cooleshow.common.page.PageInfo;
+import com.yonge.toolset.utils.string.StringUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+
+@RestController
+@RequestMapping("/Student")
+@Api(value = "学生表", tags = "学生表")
+public class StudentController extends BaseController {
+
+    @Autowired
+    private StudentService studentService;
+
+
+	/**
+     * 查询单条
+     */
+    @GetMapping("/detail")
+    @ApiOperation(value = "详情", notes = "传入student")
+    public HttpResponseResult<Student> detail(Student student) {
+		Student detail = studentService.getOne(Condition.getQueryWrapper(student));
+		return succeed(detail);
+	}
+    
+    
+    /**
+     * 查询集合
+     */
+    @GetMapping("/list")
+    @ApiOperation(value = "查询集合", notes = "传入student")
+    public HttpResponseResult<List<Student>> list(Student student) {
+		List<Student> list = studentService.list();
+		return succeed(list);
+	}
+    
+    /**
+     * 查询分页
+     */
+    @GetMapping("/page")
+    @ApiOperation(value = "查询分页", notes = "传入student")
+    public HttpResponseResult<PageInfo<Student>> page(Student student, Query query) {
+		IPage<Student> pages = studentService.selectPage(Condition.getPage(query), student);
+        return succeed(Condition.pageInfo(pages));
+	}
+    
+    /**
+	 * 新增
+	 */
+	@PostMapping("/save")
+	@ApiOperation(value = "新增", notes = "传入student")
+	public HttpResponseResult save(@Valid @RequestBody Student student) {
+    	return status(studentService.save(student));
+	}
+    
+    /**
+	 * 修改
+	 */
+	@PostMapping("/update")
+	@ApiOperation(value = "修改", notes = "传入student")
+	public HttpResponseResult update(@Valid @RequestBody Student student) {
+        return status(studentService.updateById(student));
+	}
+    
+    /**
+	 * 新增或修改
+	 */
+    @PostMapping("/submit")
+    @ApiOperation(value = "新增或修改", notes = "传入student")
+	public HttpResponseResult submit(@RequestBody Student student) {
+        return status(studentService.saveOrUpdate(student));
+    }
+
+ 	/**
+	 * 删除
+	 */
+	@PostMapping("/remove")
+	@ApiOperation(value = "逻辑删除", notes = "传入ids")
+	public HttpResponseResult remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+        if (StringUtil.isEmpty(ids)) {
+			return failed("参数不能为空");
+		}
+		return status(studentService.removeByIds(StringUtil.toLongList(ids)));
+	}
+}

+ 2 - 21
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/TeacherDao.java

@@ -5,13 +5,12 @@ import java.util.Set;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dto.BasicUserInfo;
-import com.yonge.cooleshow.biz.dal.dto.req.TeacherSetReq;
+import com.yonge.cooleshow.biz.dal.dto.req.UserSetReq;
 import com.yonge.cooleshow.biz.dal.dto.search.TeacherSearch;
 import com.yonge.cooleshow.biz.dal.entity.Teacher;
 import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
-import io.swagger.models.auth.In;
+import com.yonge.cooleshow.biz.dal.vo.UserSetVo;
 import org.apache.ibatis.annotations.Param;
 
 public interface TeacherDao extends BaseMapper<Teacher> {
@@ -21,24 +20,6 @@ public interface TeacherDao extends BaseMapper<Teacher> {
      */
     List<TeacherVo> selectPage(@Param("page") IPage page, @Param("param") TeacherSearch teacher);
 
-    /***
-     * 查询老师设置详情
-     * @author liweifan
-     * @param: id
-     * @updateTime 2022/3/22 10:24
-     * @return: com.yonge.cooleshow.biz.dal.vo.TeacherVo
-     */
-    TeacherVo getSetDetail(@Param("id") Long id);
-
-    /***
-     * 修改老师设置信息
-     * @author liweifan
-     * @param: setReq
-     * @param: id
-     * @updateTime 2022/3/22 11:06
-     */
-    void updatetSetDetail(@Param("param") TeacherSetReq setReq, @Param("id") Long id);
-
     /**
     * @description: 获取用户基本信息
      * @param userId

+ 14 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/TeacherStyleVideoDao.java

@@ -0,0 +1,14 @@
+package com.yonge.cooleshow.biz.dal.dao;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yonge.cooleshow.biz.dal.entity.TeacherStyleVideo;
+import org.apache.ibatis.annotations.Param;
+
+public interface TeacherStyleVideoDao extends BaseMapper<TeacherStyleVideo>{
+
+    TeacherStyleVideo selectListByUserId(@Param("userId") Long userId);
+
+}

+ 3 - 7
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/req/TeacherApplyDetailReq.java

@@ -20,19 +20,15 @@ public class TeacherApplyDetailReq implements Serializable {
     @ApiModelProperty(value = "用户id")
     private Long userId;
 
-    @NotBlank(message = "用户真实姓名不能为空")
-    @ApiModelProperty(value = "用户真实姓名", required = true)
+    @ApiModelProperty(value = "用户真实姓名")
     private String realName;
 
-    @NotBlank(message = "用户身份证号不能为空")
-    @ApiModelProperty(value = "用户身份证号", required = true)
+    @ApiModelProperty(value = "用户身份证号")
     private String idCardNo;
 
-    @NotNull(message = "性别不能为空")
-    @ApiModelProperty(value = "性别(0,女  1,男)", required = true)
+    @ApiModelProperty(value = "性别(0,女  1,男)")
     private Integer gender;
 
-    @ApiModelProperty(value = "出生日期 ", required = true)
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private Date birthdate;

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/req/TeacherSetReq.java → cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/req/UserSetReq.java

@@ -7,8 +7,8 @@ import io.swagger.annotations.ApiModelProperty;
  * @Author: liweifan
  * @Data: 2022/3/22 11:00
  */
-@ApiModel(value = "TeacherSetReq对象", description = "教师设置请求对象")
-public class TeacherSetReq {
+@ApiModel(value = "UserSetReq对象", description = "用户设置请求对象")
+public class UserSetReq {
     @ApiModelProperty("头像地址")
     private String avatar;
     @ApiModelProperty("昵称")

+ 56 - 14
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/RoomSpeakerInfo.java → cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/RoomInfoCache.java

@@ -1,32 +1,50 @@
 package com.yonge.cooleshow.biz.dal.entity;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
 import java.util.Date;
 
 /**
  * @author hgw
- * Created by 2022-03-22
+ * Created by 2022年3月24日
  */
-public class RoomSpeakerInfo implements Serializable {
-    //主讲人id
+public class RoomInfoCache implements Serializable {
+    @ApiModelProperty(value = "主讲人id")
     private Long speakerId;
-    //主讲人名称
+
+    @ApiModelProperty(value = "主讲人名称")
     private String speakerName;
-    //直播状态 0在房间 1不在房间
-    private Integer state;
-    //房间uid
+
+    @ApiModelProperty(value = "主讲人 0在房间 1不在房间")
+    private Integer speakerState;
+
+    @ApiModelProperty(value = "房间uid")
     private String roomUid;
-    //房间创建时间
+
+    @ApiModelProperty(value = "直播开始时间")
+    private Date liveStartTime;
+
+    @ApiModelProperty(value = "直播结束时间")
+    private Date liveEndTime;
+
+    @ApiModelProperty(value = "房间创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date createRoomTime;
-    //进入房间时间
+
+    @ApiModelProperty(value = "结束时间后最多延迟分钟数")
+    private Integer expiredMinute;
+
+    @ApiModelProperty(value = "主讲人进入房间时间")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date joinRoomTime;
-    //退出房间时间
+
+    @ApiModelProperty(value = "主讲人退出房间时间")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date exitRoomTime;
 
+    @ApiModelProperty(value = "房间类型 RoomTypeEnum")
     private String roomType;
 
     public Long getSpeakerId() {
@@ -45,12 +63,12 @@ public class RoomSpeakerInfo implements Serializable {
         this.speakerName = speakerName;
     }
 
-    public Integer getState() {
-        return state;
+    public Integer getSpeakerState() {
+        return speakerState;
     }
 
-    public void setState(Integer state) {
-        this.state = state;
+    public void setSpeakerState(Integer speakerState) {
+        this.speakerState = speakerState;
     }
 
     public String getRoomUid() {
@@ -61,6 +79,22 @@ public class RoomSpeakerInfo implements Serializable {
         this.roomUid = roomUid;
     }
 
+    public Date getLiveStartTime() {
+        return liveStartTime;
+    }
+
+    public void setLiveStartTime(Date liveStartTime) {
+        this.liveStartTime = liveStartTime;
+    }
+
+    public Date getLiveEndTime() {
+        return liveEndTime;
+    }
+
+    public void setLiveEndTime(Date liveEndTime) {
+        this.liveEndTime = liveEndTime;
+    }
+
     public Date getCreateRoomTime() {
         return createRoomTime;
     }
@@ -69,6 +103,14 @@ public class RoomSpeakerInfo implements Serializable {
         this.createRoomTime = createRoomTime;
     }
 
+    public Integer getExpiredMinute() {
+        return expiredMinute;
+    }
+
+    public void setExpiredMinute(Integer expiredMinute) {
+        this.expiredMinute = expiredMinute;
+    }
+
     public Date getJoinRoomTime() {
         return joinRoomTime;
     }

+ 83 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/RoomUserInfoCache.java

@@ -0,0 +1,83 @@
+package com.yonge.cooleshow.biz.dal.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author hgw
+ * Created by 2022年3月24日
+ */
+public class RoomUserInfoCache implements Serializable {
+
+    @ApiModelProperty(value = "用户id")
+    private Long userId;
+
+    @ApiModelProperty(value = "用户名称")
+    private String userName;
+
+    @ApiModelProperty(value = "首次进入时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date firstJoinTime;
+
+    @ApiModelProperty(value = "动态进入房间时间  多次进入房间每次进入更新")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date dynamicJoinTime;
+
+    @ApiModelProperty(value = "最后一次退出时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date lastOutTime;
+
+    @ApiModelProperty(value = "0:在房间 1:不在房间")
+    private Integer state;
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public Date getFirstJoinTime() {
+        return firstJoinTime;
+    }
+
+    public void setFirstJoinTime(Date firstJoinTime) {
+        this.firstJoinTime = firstJoinTime;
+    }
+
+    public Date getDynamicJoinTime() {
+        return dynamicJoinTime;
+    }
+
+    public void setDynamicJoinTime(Date dynamicJoinTime) {
+        this.dynamicJoinTime = dynamicJoinTime;
+    }
+
+    public Date getLastOutTime() {
+        return lastOutTime;
+    }
+
+    public void setLastOutTime(Date lastOutTime) {
+        this.lastOutTime = lastOutTime;
+    }
+
+    public Integer getState() {
+        return state;
+    }
+
+    public void setState(Integer state) {
+        this.state = state;
+    }
+}

+ 2 - 17
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/Student.java

@@ -24,13 +24,7 @@ public class Student implements Serializable {
     @ApiModelProperty("学员声部 ")
 	@TableField(value = "subject_id_list_")
     private String subjectIdList;
-    /** 
-    * 年级 
-    */
-    @ApiModelProperty("年级 ")
-	@TableField(value = "current_grade_num_")
-    private Integer currentGradeNum;
-    /** 
+    /**
     * 会员等级 
     */
     @ApiModelProperty("会员等级 ")
@@ -91,14 +85,6 @@ public class Student implements Serializable {
         this.subjectIdList = subjectIdList;
     }
 
-    public Integer getCurrentGradeNum() {
-        return currentGradeNum;
-    }
-
-    public void setCurrentGradeNum(Integer currentGradeNum) {
-        this.currentGradeNum = currentGradeNum;
-    }
-
     public Long getMemberRankSettingId() {
         return memberRankSettingId;
     }
@@ -160,8 +146,7 @@ public class Student implements Serializable {
         return "Student{" +
 				"userId=" + userId +
 						",subjectIdList='" + subjectIdList + "'" + 
-						",currentGradeNum='" + currentGradeNum + "'" + 
-						",memberRankSettingId='" + memberRankSettingId + "'" + 
+						",memberRankSettingId='" + memberRankSettingId + "'" +
 						",membershipStartTime='" + membershipStartTime + "'" + 
 						",membershipEndTime='" + membershipEndTime + "'" + 
 						",cloudStudySequenceDays='" + cloudStudySequenceDays + "'" + 

+ 112 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/TeacherStyleVideo.java

@@ -0,0 +1,112 @@
+package com.yonge.cooleshow.biz.dal.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+
+/**
+ * 教师风采视频表
+ */
+@TableName("teacher_style_video")
+@ApiModel(value = "TeacherStyleVideo对象", description = "教师风采视频表")
+public class TeacherStyleVideo implements Serializable {
+	private static final long serialVersionUID = 1L;
+    /** 
+    * 对应user表用户编号 
+    */
+    @ApiModelProperty("对应user表用户编号 ")
+    @TableId(value = "user_id_", type = IdType.AUTO)
+    private Long userId;
+    /** 
+    * 视频地址 
+    */
+    @ApiModelProperty("视频地址 ")
+	@TableField(value = "video_url_")
+    private String videoUrl;
+    /** 
+    * 视频说明 
+    */
+    @ApiModelProperty("视频说明 ")
+	@TableField(value = "describe_")
+    private String describe;
+    /** 
+    * 视频浏览量 
+    */
+    @ApiModelProperty("视频浏览量 ")
+	@TableField(value = "browse_")
+    private Integer browse;
+	@TableField(value = "create_time_")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    private Date createTime;
+	@TableField(value = "update_time_")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    private Date updateTime;
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public String getVideoUrl() {
+        return videoUrl;
+    }
+
+    public void setVideoUrl(String videoUrl) {
+        this.videoUrl = videoUrl;
+    }
+
+    public String getDescribe() {
+        return describe;
+    }
+
+    public void setDescribe(String describe) {
+        this.describe = describe;
+    }
+
+    public Integer getBrowse() {
+        return browse;
+    }
+
+    public void setBrowse(Integer browse) {
+        this.browse = browse;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Override
+    public String toString() {
+        return "TeacherStyleVideo{" +
+				"userId=" + userId +
+						",videoUrl='" + videoUrl + "'" + 
+						",describe='" + describe + "'" + 
+						",browse='" + browse + "'" + 
+						",createTime='" + createTime + "'" + 
+						",updateTime='" + updateTime + "'" + 
+		                '}';
+    }
+	
+}

+ 7 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/LiveRoomService.java

@@ -2,10 +2,10 @@ package com.yonge.cooleshow.biz.dal.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.yonge.cooleshow.biz.dal.dao.LiveRoomDao;
-import com.yonge.cooleshow.biz.dal.entity.IMApiResultInfo;
-import com.yonge.cooleshow.biz.dal.entity.ImRoomMessage;
 import com.yonge.cooleshow.biz.dal.entity.LiveRoom;
-import com.yonge.cooleshow.biz.dal.entity.RecordNotify;
+import com.yonge.cooleshow.biz.dal.entity.RoomUserInfoCache;
+
+import java.util.List;
 
 /**
  * 直播房间与课程的关系表表(LiveRoom)表服务接口
@@ -17,9 +17,13 @@ public interface LiveRoomService extends IService<LiveRoom> {
 
     LiveRoomDao getDao();
 
+    void createCourseLiveRoom();
+
     void createTempLiveRoom(LiveRoom room);
 
+    void joinRoom(String roomUid, Long userId);
 
+    List<RoomUserInfoCache> queryRoomUserInfo(String roomUid);
 
 }
 

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

@@ -11,7 +11,6 @@ import com.yonge.cooleshow.biz.dal.entity.Student;
  */
 public interface StudentService extends IService<Student>  {
 
-
     /**
      * 自定义分页
      * @author liweifan

+ 3 - 17
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TeacherService.java

@@ -2,11 +2,12 @@ package com.yonge.cooleshow.biz.dal.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.yonge.cooleshow.biz.dal.dto.req.TeacherSetReq;
+import com.yonge.cooleshow.biz.dal.dto.req.UserSetReq;
 import com.yonge.cooleshow.biz.dal.dto.req.TeacherSubmitReq;
 import com.yonge.cooleshow.biz.dal.dto.search.TeacherSearch;
 import com.yonge.cooleshow.biz.dal.entity.Teacher;
 import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
+import com.yonge.cooleshow.biz.dal.vo.UserSetVo;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 
 /**
@@ -23,22 +24,7 @@ public interface TeacherService extends IService<Teacher>  {
  	 * @date 2022-03-18
      */
     IPage<TeacherVo> selectPage(IPage<TeacherVo> page, TeacherSearch teacher);
-    /***
-     * 查询老师设置页面详情
-     * @author liweifan
-     * @param: id
-     * @updateTime 2022/3/22 10:22
-     * @return: com.yonge.cooleshow.biz.dal.vo.TeacherVo
-     */
-    TeacherVo getSetDetail(Long id);
-    /***
-     * 设置老师详情
-     * @author liweifan
-     * @param: setReq
-     * @param: id
-     * @updateTime 2022/3/22 11:04
-     */
-    void submitSetDetail(TeacherSetReq setReq, Long id);
+
     /***
      * 开通直播
      * @author liweifan

+ 25 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TeacherStyleVideoService.java

@@ -0,0 +1,25 @@
+package com.yonge.cooleshow.biz.dal.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.yonge.cooleshow.biz.dal.entity.TeacherStyleVideo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 教师风采视频表 服务类
+ * @author liweifan
+ * @date 2022-03-24
+ */
+public interface TeacherStyleVideoService extends IService<TeacherStyleVideo>  {
+    /***
+     *
+     * @author liweifan
+     * @param: userId
+     * @updateTime 2022/3/24 14:34
+     * @return: com.yonge.cooleshow.biz.dal.entity.TeacherStyleVideo
+     */
+    List<TeacherStyleVideo> selectListByUserId(Long userId);
+
+}

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

@@ -12,18 +12,28 @@ import com.yonge.cooleshow.biz.dal.enums.RoomTypeEnum;
 import com.yonge.cooleshow.biz.dal.service.CourseGroupService;
 import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
 import com.yonge.cooleshow.biz.dal.service.LiveRoomService;
+import com.yonge.cooleshow.biz.dal.service.SysConfigService;
 import com.yonge.cooleshow.biz.dal.support.IMHelper;
 import com.yonge.cooleshow.common.exception.BizException;
 import com.yonge.toolset.utils.date.DateUtil;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.redisson.api.RBucket;
+import org.redisson.api.RMap;
 import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import static com.yonge.cooleshow.biz.dal.constant.SysConfigConstant.DESTROY_EXPIRED_LIVE_ROOM_MINUTE;
+import static com.yonge.cooleshow.biz.dal.constant.SysConfigConstant.PRE_CREATE_LIVE_ROOM_MINUTE;
 
 /**
  * 直播房间与课程的关系表表(LiveRoom)表服务实现类
@@ -45,22 +55,25 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     private CourseGroupService courseGroupService;
     @Autowired
     private CourseScheduleService courseScheduleService;
+    @Autowired
+    private SysConfigService sysConfigService;
 
     //替换的字符串
     public static final String USER_ID = "${userId}";
     public static final String ROOM_UID = "${roomUid}";
+    //缓存排头
     public static final String COOLESHOW = "COOLESHOW";
 
     //直播间累计用户信息-指只要进入到该房间的用户都要记录
     public static final String LIVE_ROOM_TOTAL_USER_LIST = COOLESHOW + ":LIVE_ROOM_TOTAL_USER_LIST:" + ROOM_UID;
-    //主讲人信息
-    public static final String LIVE_SPEAKER_INFO = COOLESHOW + ":LIVE_SPEAKER_INFO:" + USER_ID;
-    //用户对应的直播间Uid
+    //用户当前对应的直播间Uid
     public static final String LIVE_USER_ROOM = COOLESHOW + ":LIVE_ROOM_USER:" + USER_ID;
     //房间点赞数
     public static final String LIVE_ROOM_LIKE = COOLESHOW + ":LIVE_ROOM_LIKE:" + ROOM_UID;
     //生成房间UID
     public static Function<Long, String> GenRoomUid = (userId) -> COOLESHOW + "-" + userId + "-" + new Date().getTime();
+    //房间的信息
+    public static final String LIVE_ROOM_INFO = COOLESHOW + ":LIVE_ROOM_INFO:" + ROOM_UID;
 
     @Override
     public LiveRoomDao getDao() {
@@ -68,12 +81,29 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     }
 
     /**
+     * 根据课程id查询直播间信息
+     */
+    public void getLiveRoomByCourseId(Long courseId) {
+        CourseSchedule course = courseScheduleService.getById(courseId);
+        if (Objects.isNull(course)) {
+            throw new BizException("该课程没有直播间");
+        }
+    }
+
+    /**
      * 定时任务创建直播间
      */
-    public void createLiveRoom() {
+    @Override
+    public void createCourseLiveRoom() {
         Date now = new Date();
-        Date endTime = DateUtil.addMinutes(now, 30);
-        //查询课时表生成直播间 这里错了
+        //查询房间提前创建的时间
+        String preCreateRoomMinute = sysConfigService.findConfigValue(PRE_CREATE_LIVE_ROOM_MINUTE);
+        if (StringUtils.isEmpty(preCreateRoomMinute)) {
+            log.info("roomDestroy>>>> 未查询到配置:{}", PRE_CREATE_LIVE_ROOM_MINUTE);
+            return;
+        }
+        Date endTime = DateUtil.addMinutes(now, Integer.parseInt(preCreateRoomMinute));
+        //查询课时表生成直播间
         List<CourseSchedule> courseScheduleList = courseScheduleService.list(new QueryWrapper<CourseSchedule>().lambda()
                 .eq(CourseSchedule::getType, CourseScheduleTypeEnum.LIVE.getCode())
                 .eq(CourseSchedule::getLock, 0)
@@ -82,11 +112,20 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         if (CollectionUtils.isEmpty(courseScheduleList)) {
             return;
         }
+        //获取课程组名称
+        Map<Long, String> titleMap = courseScheduleList.stream()
+                .map(CourseSchedule::getCourseGroupId)
+                .distinct()
+                .map(courseGroupService::getById)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toMap(CourseGroup::getId, CourseGroup::getName));
+        //生成课程对应的房间
         courseScheduleList.forEach(c -> {
             LiveRoom room = new LiveRoom();
             room.setCourseGroupId(c.getCourseGroupId());
             room.setCourseId(c.getId());
             room.setRoomUid(GenRoomUid.apply(c.getTeacherId()));
+            room.setRoomTitle(titleMap.get(c.getCourseGroupId()));
             room.setSpeakerId(c.getTeacherId());
             room.setLiveStartTime(c.getStartTime());
             room.setLiveEndTime(c.getEndTime());
@@ -96,11 +135,16 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             room.setCreatedBy(-2L);
             room.setCreatedTime(now);
             this.save(room);
-            //生成主讲人信息
-            createSpeakerInfo(room);
-            //
-            //去融云创建房间
-            createLiveRoom(room.getRoomUid(), room.getRoomTitle());
+            try {
+                //生成主讲人信息
+                createRoomInfoCache(room);
+                //去融云创建房间
+                createLiveRoom(room.getRoomUid(), room.getRoomTitle());
+            } catch (Exception e) {
+                //为什么要删除,因为如果融云创建失败,那么就不会有房间了,需要删除
+                this.removeById(room.getId());
+                log.error("创建直播间失败", e.getCause());
+            }
         });
 
     }
@@ -108,52 +152,51 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     /**
      * 创建临时房间-直播间
      */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
     public void createTempLiveRoom(LiveRoom room) {
-        log.info("createLiveRoom>>>>>>roomUid:{}", room.getRoomUid());
-        try {
+        //查询主讲人信息
+        SysUser sysUser = getSysUser();
 
-            //临时课程没有课程组和课表
-            if (room.getType().equals(RoomTypeEnum.TEMP.getCode())) {
-                room.setCourseGroupId(0L);
-                room.setCourseId(0L);
-            }
-            //查询主讲人信息
-            SysUser sysUser = getSysUser();
-            if (Objects.isNull(sysUser)) {
-                return;
-            }
-            room.setRoomUid(GenRoomUid.apply(sysUser.getId()));
-            this.save(room);
-            //生成主讲人信息到缓存
-            createSpeakerInfo(room, sysUser);
-            //去融云创建房间
-            createLiveRoom(room.getRoomUid(), room.getRoomTitle());
-        } catch (Exception e) {
-            log.error(">>>>>>>>>> createLiveRoom error roomUid:{} msg:{}", room.getRoomUid(), e.getMessage());
-        }
+        room.setCourseGroupId(0L);
+        room.setCourseId(0L);
+        room.setType(RoomTypeEnum.TEMP.getCode());
+        room.setRoomUid(GenRoomUid.apply(sysUser.getId()));
+        this.save(room);
+        log.info("createTempLiveRoom>>>>>>room:{}", room.getRoomUid());
+        //生成主讲人信息到缓存
+        createRoomInfoCache(room, sysUser);
+        //去融云创建房间
+        createLiveRoom(room.getRoomUid(), room.getRoomTitle());
     }
 
     //生成主讲人信息
-    private void createSpeakerInfo(LiveRoom room) {
+    private void createRoomInfoCache(LiveRoom room) {
         //查询主讲人信息
         SysUser sysUser = getSysUser(room.getSpeakerId());
-        if (Objects.isNull(sysUser)) {
-            return;
-        }
-        createSpeakerInfo(room, sysUser);
+        createRoomInfoCache(room, sysUser);
     }
 
-    private void createSpeakerInfo(LiveRoom room, SysUser sysUser) {
-        RoomSpeakerInfo speakerInfo = new RoomSpeakerInfo();
-        speakerInfo.setSpeakerId(sysUser.getId());
-        speakerInfo.setSpeakerName(sysUser.getRealName());
-        speakerInfo.setCreateRoomTime(new Date());
-        speakerInfo.setRoomUid(room.getRoomUid());
-        speakerInfo.setRoomType(room.getType());
-        //写入主讲人信息
-        redissonClient.getBucket(LIVE_SPEAKER_INFO.replace(USER_ID, room.getSpeakerId().toString())).set(speakerInfo);
+    //生成主讲人信息
+    private void createRoomInfoCache(LiveRoom room, SysUser sysUser) {
+        RoomInfoCache roomCache = new RoomInfoCache();
+        roomCache.setSpeakerId(sysUser.getId());
+        roomCache.setSpeakerName(sysUser.getRealName());
+        roomCache.setSpeakerState(1);
+        roomCache.setRoomUid(room.getRoomUid());
+        roomCache.setLiveStartTime(room.getLiveStartTime());
+        roomCache.setLiveEndTime(room.getLiveEndTime());
+        roomCache.setCreateRoomTime(new Date());
+        String configValue = sysConfigService.findConfigValue(PRE_CREATE_LIVE_ROOM_MINUTE);
+        roomCache.setExpiredMinute(Integer.parseInt(configValue));
+        roomCache.setRoomType(room.getType());
+
+        //写入房间信息
+        redissonClient.getBucket(LIVE_ROOM_INFO.replace(ROOM_UID, room.getRoomUid()))
+                .set(roomCache, 2L, TimeUnit.DAYS);
         //生成0点赞
-        redissonClient.getBucket(LIVE_ROOM_LIKE.replace(ROOM_UID, room.getRoomUid())).set(0);
+        redissonClient.getBucket(LIVE_ROOM_LIKE.replace(ROOM_UID, room.getRoomUid()))
+                .set(0, 2L, TimeUnit.DAYS);
     }
 
     /**
@@ -162,20 +205,45 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
      * @param roomId   房间Uid
      * @param roomName 房间名称
      */
-    private IMApiResultInfo createLiveRoom(String roomId, String roomName) {
+    private void createLiveRoom(String roomId, String roomName) {
         IMApiResultInfo resultInfo;
         try {
             resultInfo = imHelper.createChatRoom(roomId, roomName);
         } catch (Exception e) {
-            log.error("create chatRoom error >>>", e.getCause());
-            throw new RuntimeException("创建聊天室失败!");
+            throw new BizException("创建聊天室失败!" + e.getMessage());
         }
         if (!resultInfo.isSuccess()) {
-            log.error("create chatRoom error: {}", resultInfo.getErrorMessage());
-            throw new RuntimeException("创建聊天室失败!");
+            throw new BizException("创建聊天室失败!" + resultInfo.getErrorMessage());
         }
         log.info("create chatRoom success: {}", roomId);
-        return resultInfo;
+    }
+
+    /**
+     * 定时任务-清理过期的房间
+     */
+    public void destroyExpiredLiveRoom() {
+        //查询房间过期时间
+        String expiredMinuteStr = sysConfigService.findConfigValue(DESTROY_EXPIRED_LIVE_ROOM_MINUTE);
+        if (StringUtils.isEmpty(expiredMinuteStr)) {
+            log.info("roomDestroy>>>> 未查询到配置:{}", DESTROY_EXPIRED_LIVE_ROOM_MINUTE);
+            return;
+        }
+        Date now = new Date();
+        //查询已经开始并且没有删除及销毁的直播间
+        List<LiveRoom> list = this.list(new QueryWrapper<LiveRoom>().lambda()
+                .eq(LiveRoom::getType, RoomTypeEnum.LIVE.getCode())
+                .ge(LiveRoom::getLiveEndTime, now));
+        if (CollectionUtils.isEmpty(list)) {
+            return;
+        }
+        list.forEach(room -> {
+            Date expiredDate = DateUtil.addMinutes(room.getLiveEndTime(), Integer.parseInt(expiredMinuteStr));
+            //当前时间 大于(结束播时间 + 设置的过期分钟数)
+            if (now.getTime() >= expiredDate.getTime()) {
+                //删除房间
+                destroyLiveRoom(room.getRoomUid());
+            }
+        });
     }
 
     /**
@@ -183,7 +251,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
      *
      * @param roomId 房间Uid
      */
-    private IMApiResultInfo destroyLiveRoom(String roomId) {
+    private void destroyLiveRoom(String roomId) {
         //删除服务器房间
         List<String> deleteRoomIds = new ArrayList<String>() {{
             add(roomId);
@@ -192,13 +260,58 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         try {
             resultInfo = imHelper.deleteChrm(deleteRoomIds);
         } catch (Exception e) {
-            throw new RuntimeException("关闭聊天室失败!");
+            throw new BizException("关闭聊天室失败!" + e.getMessage());
         }
         if (!resultInfo.isSuccess()) {
-            log.error("destroy chatRoom error: {}", resultInfo.getErrorMessage());
-            throw new RuntimeException("关闭聊天室失败!");
+            throw new BizException("关闭聊天室失败!" + resultInfo.getErrorMessage());
         }
-        return resultInfo;
+        log.info("destroyLiveRoom success: {}", roomId);
+    }
+
+    /**
+     * 进入房间
+     *
+     * @param roomUid 房间uid
+     * @param userId  用户id 主讲人或者用户的id
+     */
+    public void joinRoom(String roomUid, Long userId) {
+        //校验房间是否存在
+        RBucket<RoomInfoCache> roomInfoCache = redissonClient.getBucket(LIVE_ROOM_INFO.replace(ROOM_UID, roomUid));
+        RoomInfoCache roomInfo;
+        if (roomInfoCache.isExists()) {
+            roomInfo = roomInfoCache.get();
+        } else {
+            throw new BizException("房间不存在!");
+        }
+        //进入房间的是主讲人
+        if (roomInfo.getSpeakerId().equals(userId)) {
+            roomInfo.setSpeakerState(0);
+            roomInfo.setJoinRoomTime(new Date());
+            roomInfoCache.set(roomInfo, 2L, TimeUnit.DAYS);
+            return;
+        }
+        //进入房间的是学生 记录用户对应的当前房间uid
+        redissonClient.getBucket(LIVE_USER_ROOM.replace(USER_ID, userId.toString())).set(roomUid);
+        //房间累计用户信息-指只要进入到该房间的用户都要记录
+        RMap<Long, RoomUserInfoCache> roomTotalUser = redissonClient.getMap(LIVE_ROOM_TOTAL_USER_LIST.replace(ROOM_UID, roomUid));
+        //判断是否第一次进房间
+        RoomUserInfoCache userInfo;
+        Date now = new Date();
+        if (roomTotalUser.containsKey(userId)) {
+            //多次进入更新动态进入时间
+            userInfo = roomTotalUser.get(userId);
+        } else {
+            //第一次进该房间 写入用户首次进入时间
+            SysUser sysUser = getSysUser(userId);
+            userInfo = new RoomUserInfoCache();
+            userInfo.setUserId(sysUser.getId());
+            userInfo.setUserName(sysUser.getRealName());
+            userInfo.setFirstJoinTime(now);
+        }
+        userInfo.setState(0);//0 进入/在房间
+        userInfo.setDynamicJoinTime(now);
+        roomTotalUser.fastPut(userId, userInfo);
+        log.info("joinRoom>>>> userInfo: {}", JSONObject.toJSONString(userInfo));
     }
 
     /**
@@ -206,19 +319,19 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
      *
      * @param message
      */
-    private IMApiResultInfo publishRoomMessage(ImRoomMessage message) {
-        log.info("publishRoomMessage message : {}", JSONObject.toJSONString(message));
+    private void publishRoomMessage(ImRoomMessage message) {
+        String msgStr = JSONObject.toJSONString(message);
+        log.info("publishRoomMessage message : {}", msgStr);
         IMApiResultInfo resultInfo;
         try {
             resultInfo = imHelper.publishRoomMessage(message.getFromUserId(), message.getToChatroomId(), message);
         } catch (Exception e) {
-            throw new RuntimeException("消息发送失败" + e.getMessage());
+            throw new BizException("消息发送失败" + e.getMessage());
         }
         if (!resultInfo.isSuccess()) {
-            log.error("publishRoomMessage chatRoom error: {}", resultInfo.getErrorMessage());
-            throw new RuntimeException("消息发送失败!");
+            throw new BizException("消息发送失败!" + resultInfo.getErrorMessage());
         }
-        return resultInfo;
+        log.info("publishRoomMessage success: {}", msgStr);
     }
 
     /**
@@ -238,16 +351,15 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         try {
             resultInfo = imHelper.isInChartRoom(chatroomId, userId);
         } catch (Exception e) {
-            throw new RuntimeException("查询失败" + e.getMessage());
+            throw new BizException("查询失败" + e.getMessage());
         }
         if (!resultInfo.isSuccess()) {
             log.error("userExistInRoom  chatroomId : {}  userId : {}", chatroomId, userId);
-            throw new RuntimeException("查询失败!");
+            throw new BizException("查询失败!");
         }
         return resultInfo.isSuccess() && resultInfo.getInChrm();
     }
 
-
     private SysUser getSysUser(Long userId) {
         return Optional.ofNullable(userId)
                 .map(sysUserFeignService::queryUserById)
@@ -255,10 +367,33 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     }
 
     private SysUser getSysUser() {
-        //修改机构基础信息
         return Optional.ofNullable(sysUserFeignService.queryUserInfo())
                 .orElseThrow(() -> new BizException("用户不存在"));
     }
 
+    /**
+     * 查询在观看直播的用户信息
+     *
+     * @param roomUid 直播间uid
+     */
+    @Override
+    public List<RoomUserInfoCache> queryRoomUserInfo(String roomUid) {
+        List<RoomUserInfoCache> roomUserInfoVos = queryTotalRoomUserInfo(roomUid);
+        return queryRoomUserInfo(roomUserInfoVos);
+    }
+
+    private List<RoomUserInfoCache> queryRoomUserInfo(List<RoomUserInfoCache> totalUserInfo) {
+        return totalUserInfo.stream()
+                .filter(o -> Objects.nonNull(o.getState()) && o.getState() == 0)
+                .collect(Collectors.toList());
+    }
+
+    private List<RoomUserInfoCache> queryTotalRoomUserInfo(String roomUid) {
+        RMap<Integer, RoomUserInfoCache> roomTotalUser = redissonClient.getMap(LIVE_ROOM_TOTAL_USER_LIST.replace(ROOM_UID, roomUid));
+        return roomTotalUser.values().stream()
+                .filter(Objects::nonNull)
+                .collect(Collectors.toList());
+    }
+
 }
 

+ 14 - 13
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherServiceImpl.java

@@ -6,12 +6,15 @@ import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.auth.api.enums.SysUserType;
-import com.yonge.cooleshow.biz.dal.dto.req.TeacherSetReq;
+import com.yonge.cooleshow.biz.dal.dto.req.UserSetReq;
 import com.yonge.cooleshow.biz.dal.dto.req.TeacherSubmitReq;
 import com.yonge.cooleshow.biz.dal.dto.search.TeacherSearch;
+import com.yonge.cooleshow.biz.dal.entity.TeacherStyleVideo;
 import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
 import com.yonge.cooleshow.biz.dal.enums.TeacherTypeEnum;
+import com.yonge.cooleshow.biz.dal.service.TeacherStyleVideoService;
 import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
+import com.yonge.cooleshow.biz.dal.vo.UserSetVo;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.cooleshow.common.exception.BizException;
 import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
@@ -24,33 +27,25 @@ import com.yonge.cooleshow.biz.dal.service.TeacherService;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
+import java.util.List;
 
 
 @Service
 public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> implements TeacherService {
     @Autowired
     private SysUserFeignService userFeignService;
+    @Autowired
+    private TeacherStyleVideoService teacherStyleVideoService;
 
     /**
      * 分页查询
      */
     @Override
-
     public IPage<TeacherVo> selectPage(IPage<TeacherVo> page, TeacherSearch teacher) {
         return page.setRecords(baseMapper.selectPage(page, teacher));
     }
 
     @Override
-    public TeacherVo getSetDetail(Long id) {
-        return baseMapper.getSetDetail(id);
-    }
-
-    @Override
-    public void submitSetDetail(TeacherSetReq setReq, Long id) {
-        baseMapper.updatetSetDetail(setReq, id);
-    }
-
-    @Override
     public HttpResponseResult<Boolean> openLive(Long id) {
         //todo 根据老师规则,判断老师直播权限
         if (true) {
@@ -76,7 +71,13 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
 
     @Override
     public TeacherVo detail(Long userId) {
-        return baseMapper.detail(userId);
+        TeacherVo detail = baseMapper.detail(userId);
+        if(null == detail){
+            detail = new TeacherVo();
+        }
+        List<TeacherStyleVideo> teacherStyleVideos = teacherStyleVideoService.selectListByUserId(userId);
+        detail.setStyleVideo(teacherStyleVideos);
+        return detail;
     }
 
     private HttpResponseResult<Boolean> doCreate(TeacherSubmitReq teacherSubmitReq) throws BizException {

+ 18 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherStyleVideoServiceImpl.java

@@ -0,0 +1,18 @@
+package com.yonge.cooleshow.biz.dal.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+import com.yonge.cooleshow.biz.dal.entity.TeacherStyleVideo;
+import com.yonge.cooleshow.biz.dal.dao.TeacherStyleVideoDao;
+import com.yonge.cooleshow.biz.dal.service.TeacherStyleVideoService;
+
+
+@Service
+public class TeacherStyleVideoServiceImpl extends ServiceImpl<TeacherStyleVideoDao, TeacherStyleVideo> implements TeacherStyleVideoService {
+
+    @Override
+    public TeacherStyleVideo selectListByUserId(Long userId) {
+        return baseMapper.selectListByUserId(userId);
+    }
+}

+ 9 - 8
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/support/IMHelper.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.yonge.cooleshow.biz.dal.entity.BaseMessage;
 import com.yonge.cooleshow.biz.dal.entity.IMApiResultInfo;
 import com.yonge.cooleshow.biz.dal.entity.IMTokenInfo;
+import com.yonge.cooleshow.common.exception.BizException;
 import io.rong.util.GsonUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -342,11 +343,11 @@ public class IMHelper {
      */
     public IMApiResultInfo createChatRoom(String chatRoomId, String chatRoomName) throws Exception {
         if (chatRoomId == null) {
-            throw new RuntimeException("房间Uid不能为空");
+            throw new BizException("房间Uid不能为空");
         }
 
         if (chatRoomName == null) {
-            throw new RuntimeException("房间名称不能为空");
+            throw new BizException("房间名称不能为空");
         }
 
         StringBuilder sb = new StringBuilder();
@@ -376,7 +377,7 @@ public class IMHelper {
     public IMApiResultInfo deleteChrm(List<String> chatroomIds)
             throws Exception {
         if (chatroomIds == null) {
-            throw new RuntimeException("房间Uid不能为空");
+            throw new BizException("房间Uid不能为空");
         }
         StringBuilder sb = new StringBuilder();
         for (String child : chatroomIds) {
@@ -408,13 +409,13 @@ public class IMHelper {
 
     public IMApiResultInfo publishRoomMessage(String fromUserId, String[] toChatroomIds, BaseMessage message) throws Exception {
         if (StringUtils.isBlank(fromUserId)) {
-            throw new RuntimeException("发送人不能为空");
+            throw new BizException("发送人不能为空");
         }
         if (Objects.isNull(toChatroomIds)) {
-            throw new RuntimeException("房间Uid不能为空");
+            throw new BizException("房间Uid不能为空");
         }
         if (Objects.isNull(message)) {
-            throw new RuntimeException("消息不能为空");
+            throw new BizException("消息不能为空");
         }
 
         StringBuilder sb = new StringBuilder();
@@ -449,10 +450,10 @@ public class IMHelper {
      */
     public IMApiResultInfo isInChartRoom(String chatroomId, String userId) throws Exception {
         if (chatroomId == null) {
-            throw new RuntimeException("房间Uid不能为空");
+            throw new BizException("房间Uid不能为空");
         }
         if (userId == null) {
-            throw new RuntimeException("用户不能为空");
+            throw new BizException("用户不能为空");
         }
         String body = "&chatroomId=" + URLEncoder.encode(chatroomId, UTF8) +
                 "&userId=" + URLEncoder.encode(userId, UTF8);

+ 105 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/StudentHomeVo.java

@@ -0,0 +1,105 @@
+package com.yonge.cooleshow.biz.dal.vo;
+
+import com.yonge.cooleshow.biz.dal.entity.Student;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.models.auth.In;
+
+/**
+ * @Author: liweifan
+ * @Data: 2022/3/21 18:37
+ */
+@ApiModel(value = "StudentHomeVo对象", description = "学生主页基本信息返回")
+public class StudentHomeVo extends Student {
+
+    @ApiModelProperty("头像地址")
+    private String heardUrl;
+    @ApiModelProperty("学员昵称")
+    private String username;
+    @ApiModelProperty("会员剩余有效期天数")
+    private Integer membershipDays;
+    @ApiModelProperty("累计练习天数")
+    private Integer exerciseDays;
+    @ApiModelProperty("累计练习时长")
+    private Double exerciseHours;
+    @ApiModelProperty("累计评测次数")
+    private Integer testingNum;
+    @ApiModelProperty("已完成课时数")
+    private Integer finshClassHours;
+    @ApiModelProperty("剩余课时数")
+    private Integer unfinshClassHours;
+    @ApiModelProperty("关注老师数")
+    private Integer starTeacherNum;
+
+    public String getHeardUrl() {
+        return heardUrl;
+    }
+
+    public void setHeardUrl(String heardUrl) {
+        this.heardUrl = heardUrl;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public Integer getExerciseDays() {
+        return exerciseDays;
+    }
+
+    public void setExerciseDays(Integer exerciseDays) {
+        this.exerciseDays = exerciseDays;
+    }
+
+    public Double getExerciseHours() {
+        return exerciseHours;
+    }
+
+    public void setExerciseHours(Double exerciseHours) {
+        this.exerciseHours = exerciseHours;
+    }
+
+    public Integer getTestingNum() {
+        return testingNum;
+    }
+
+    public void setTestingNum(Integer testingNum) {
+        this.testingNum = testingNum;
+    }
+
+    public Integer getFinshClassHours() {
+        return finshClassHours;
+    }
+
+    public void setFinshClassHours(Integer finshClassHours) {
+        this.finshClassHours = finshClassHours;
+    }
+
+    public Integer getUnfinshClassHours() {
+        return unfinshClassHours;
+    }
+
+    public void setUnfinshClassHours(Integer unfinshClassHours) {
+        this.unfinshClassHours = unfinshClassHours;
+    }
+
+    public Integer getStarTeacherNum() {
+        return starTeacherNum;
+    }
+
+    public void setStarTeacherNum(Integer starTeacherNum) {
+        this.starTeacherNum = starTeacherNum;
+    }
+
+    public Integer getMembershipDays() {
+        return membershipDays;
+    }
+
+    public void setMembershipDays(Integer membershipDays) {
+        this.membershipDays = membershipDays;
+    }
+}

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

@@ -19,7 +19,7 @@ public class TeacherHomeVo {
     private Long userId;
     @ApiModelProperty("头像地址")
     private String heardUrl;
-    @ApiModelProperty("老师姓名")
+    @ApiModelProperty("老师昵称")
     private String username;
     @ApiModelProperty("星级")
     private Integer starGrade;

+ 33 - 6
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/TeacherVo.java

@@ -2,11 +2,13 @@ package com.yonge.cooleshow.biz.dal.vo;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.yonge.cooleshow.biz.dal.entity.Teacher;
+import com.yonge.cooleshow.biz.dal.entity.TeacherStyleVideo;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * @Author: liweifan
@@ -18,7 +20,7 @@ public class TeacherVo extends Teacher {
     private String avatar;
     @ApiModelProperty("老师昵称")
     private String username;
-    @ApiModelProperty(value = "性别0女1男")
+    @ApiModelProperty(value = "性别 0女 1男")
     private Integer gender;
     @ApiModelProperty(value = "手机号")
     private String phone;
@@ -36,7 +38,8 @@ public class TeacherVo extends Teacher {
     private Date birthdate;
     @ApiModelProperty(value = "审核人")
     private String verifyUser;
-
+    @ApiModelProperty(value = "老师风采视频")
+    private List<TeacherStyleVideo> styleVideo;
 
     public String getAvatar() {
         return avatar;
@@ -78,6 +81,14 @@ public class TeacherVo extends Teacher {
         isReal = real;
     }
 
+    public Boolean getBank() {
+        return isBank;
+    }
+
+    public void setBank(Boolean bank) {
+        isBank = bank;
+    }
+
     public String getRealName() {
         return realName;
     }
@@ -94,11 +105,27 @@ public class TeacherVo extends Teacher {
         this.idCardNo = idCardNo;
     }
 
-    public Boolean getBank() {
-        return isBank;
+    public Date getBirthdate() {
+        return birthdate;
     }
 
-    public void setBank(Boolean bank) {
-        isBank = bank;
+    public void setBirthdate(Date birthdate) {
+        this.birthdate = birthdate;
+    }
+
+    public String getVerifyUser() {
+        return verifyUser;
+    }
+
+    public void setVerifyUser(String verifyUser) {
+        this.verifyUser = verifyUser;
+    }
+
+    public List<TeacherStyleVideo> getStyleVideo() {
+        return styleVideo;
+    }
+
+    public void setStyleVideo(List<TeacherStyleVideo> styleVideo) {
+        this.styleVideo = styleVideo;
     }
 }

+ 69 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/UserSetVo.java

@@ -0,0 +1,69 @@
+package com.yonge.cooleshow.biz.dal.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.yonge.cooleshow.biz.dal.entity.TeacherStyleVideo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ *
+ * @Author: liweifan
+ * @Data: 2022/3/24 16:28
+ */
+@ApiModel(value = "UserSetVo对象", description = "用户设置页面查询")
+public class UserSetVo {
+    @ApiModelProperty("头像地址")
+    private String avatar;
+    @ApiModelProperty("昵称")
+    private String username;
+    @ApiModelProperty(value = "性别 0女 1男")
+    private Integer gender;
+    @ApiModelProperty(value = "手机号")
+    private String phone;
+    @ApiModelProperty(value = "是否实名 0否 1是")
+    private Boolean isReal;
+
+    public String getAvatar() {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar) {
+        this.avatar = avatar;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public Integer getGender() {
+        return gender;
+    }
+
+    public void setGender(Integer gender) {
+        this.gender = gender;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public Boolean getReal() {
+        return isReal;
+    }
+
+    public void setReal(Boolean real) {
+        isReal = real;
+    }
+}

+ 0 - 27
cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherMapper.xml

@@ -73,34 +73,7 @@
         </where>
     </select>
 
-    <select id="getSetDetail" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherVo">
-        SELECT
-        <include refid="baseColumns"/>,
-        u.avatar_ as avatar,
-        u.username_ as username,
-        u.gender_ as gender,
-        u.phone_ as phone,
-        (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal
-        FROM teacher t
-        left join sys_user u on t.user_id_ = u.id_
-        where t.user_id_ = #{id}
-    </select>
 
-    <update id="updatetSetDetail">
-        UPDATE sys_user
-        <set>
-            <if test="param.avatar != null and param.avatar != ''">
-                avatar_ = #{param.avatar},
-            </if>
-            <if test="param.username != null and param.username != ''">
-                username_ = #{param.username},
-            </if>
-            <if test="param.gender != null">
-                gender_ = #{param.gender},
-            </if>
-        </set>
-        WHERE id_ = #{id}
-    </update>
 
 	<resultMap id="BasicUserInfo" type="com.yonge.cooleshow.biz.dal.dto.BasicUserInfo">
 		<result property="userId" column="user_id_"/>

+ 30 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherStyleVideoMapper.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE  mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.yonge.cooleshow.biz.dal.dao.TeacherStyleVideoDao">
+	<resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.TeacherStyleVideo">
+            <result column="user_id_" property="userId" />
+	        <result column="video_url_" property="videoUrl" />
+	        <result column="describe_" property="describe" />
+	        <result column="browse_" property="browse" />
+	        <result column="create_time_" property="createTime" />
+	        <result column="update_time_" property="updateTime" />
+		</resultMap>  
+    
+    <!-- 表字段 -->
+    <sql id="baseColumns">
+         t.user_id_ as "userId"
+        , t.video_url_ as "videoUrl"
+        , t.describe_ as "describe"
+        , t.browse_ as "browse"
+        , t.create_time_ as "createTime"
+        , t.update_time_ as "updateTime"
+        </sql> 
+    
+    <!-- 根据老师id查询 -->
+    <select id="selectListByUserId" resultMap="BaseResultMap">
+		SELECT         
+        	<include refid="baseColumns" />
+		FROM teacher_style_video t
+		WHERE t.user_id_ = #{userId}
+	</select>
+</mapper>

+ 91 - 43
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/StudentController.java

@@ -1,18 +1,30 @@
 package com.yonge.cooleshow.student.controller;
 
+import java.util.Date;
 import java.util.List;
+
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.dto.req.UserSetReq;
+import com.yonge.cooleshow.biz.dal.entity.Teacher;
 import com.yonge.cooleshow.biz.dal.support.Condition;
 import com.yonge.cooleshow.biz.dal.support.Query;
+import com.yonge.cooleshow.biz.dal.vo.StudentHomeVo;
+import com.yonge.cooleshow.biz.dal.vo.TeacherHomeVo;
+import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.cooleshow.common.page.PageInfo;
+import com.yonge.toolset.utils.date.DateUtil;
 import com.yonge.toolset.utils.string.StringUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.apache.commons.beanutils.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
@@ -27,74 +39,110 @@ public class StudentController extends BaseController {
 
     @Autowired
     private StudentService studentService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    @ApiOperation(value = "查询学员")
+    @GetMapping("/queryUser")
+    public HttpResponseResult<Student> queryUser() throws Exception {
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (user == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        Student student = studentService.getById(user.getId());
+        return succeed(student);
+    }
+
+    @ApiOperation(value = "查询学员基本信息")
+    @GetMapping("/queryUserInfo")
+    public HttpResponseResult<StudentHomeVo> queryUserInfo() throws Exception {
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (user == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        Student student = studentService.getById(user.getId());
+        StudentHomeVo studentHomeVo = new StudentHomeVo();
+        BeanUtils.copyProperties(studentHomeVo, student);
+
+        studentHomeVo.setHeardUrl(user.getAvatar());
+        studentHomeVo.setUsername(user.getUsername());
+        int num = DateUtil.daysBetween(new Date(), student.getMembershipEndTime());
+        studentHomeVo.setMembershipDays(num < 0 ? 0 : num);
+        //todo 学员我的-统计数据
+        return succeed(studentHomeVo);
+    }
+
+
 
-	/**
+    /**
+     * 修改
+     */
+    @PostMapping("/update")
+    @ApiOperation(value = "修改", notes = "传入student")
+    public HttpResponseResult update(@Valid @RequestBody Student student) {
+        return status(studentService.updateById(student));
+    }
+
+
+    /**
      * 查询单条
      */
     @GetMapping("/detail")
     @ApiOperation(value = "详情", notes = "传入student")
     public HttpResponseResult<Student> detail(Student student) {
-		Student detail = studentService.getOne(Condition.getQueryWrapper(student));
-		return succeed(detail);
-	}
-    
-    
+        Student detail = studentService.getOne(Condition.getQueryWrapper(student));
+        return succeed(detail);
+    }
+
+
     /**
      * 查询集合
      */
     @GetMapping("/list")
     @ApiOperation(value = "查询集合", notes = "传入student")
     public HttpResponseResult<List<Student>> list(Student student) {
-		List<Student> list = studentService.list();
-		return succeed(list);
-	}
-    
+        List<Student> list = studentService.list();
+        return succeed(list);
+    }
+
     /**
      * 查询分页
      */
     @GetMapping("/page")
     @ApiOperation(value = "查询分页", notes = "传入student")
     public HttpResponseResult<PageInfo<Student>> page(Student student, Query query) {
-		IPage<Student> pages = studentService.selectPage(Condition.getPage(query), student);
+        IPage<Student> pages = studentService.selectPage(Condition.getPage(query), student);
         return succeed(Condition.pageInfo(pages));
-	}
-    
-    /**
-	 * 新增
-	 */
-	@PostMapping("/save")
-	@ApiOperation(value = "新增", notes = "传入student")
-	public HttpResponseResult save(@Valid @RequestBody Student student) {
-    	return status(studentService.save(student));
-	}
-    
+    }
+
     /**
-	 * 修改
-	 */
-	@PostMapping("/update")
-	@ApiOperation(value = "修改", notes = "传入student")
-	public HttpResponseResult update(@Valid @RequestBody Student student) {
-        return status(studentService.updateById(student));
-	}
-    
+     * 新增
+     */
+    @PostMapping("/save")
+    @ApiOperation(value = "新增", notes = "传入student")
+    public HttpResponseResult save(@Valid @RequestBody Student student) {
+        return status(studentService.save(student));
+    }
+
+
     /**
-	 * 新增或修改
-	 */
+     * 新增或修改
+     */
     @PostMapping("/submit")
     @ApiOperation(value = "新增或修改", notes = "传入student")
-	public HttpResponseResult submit(@RequestBody Student student) {
+    public HttpResponseResult submit(@RequestBody Student student) {
         return status(studentService.saveOrUpdate(student));
     }
 
- 	/**
-	 * 删除
-	 */
-	@PostMapping("/remove")
-	@ApiOperation(value = "逻辑删除", notes = "传入ids")
-	public HttpResponseResult remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+    /**
+     * 删除
+     */
+    @PostMapping("/remove")
+    @ApiOperation(value = "逻辑删除", notes = "传入ids")
+    public HttpResponseResult remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
         if (StringUtil.isEmpty(ids)) {
-			return failed("参数不能为空");
-		}
-		return status(studentService.removeByIds(StringUtil.toLongList(ids)));
-	}
+            return failed("参数不能为空");
+        }
+        return status(studentService.removeByIds(StringUtil.toLongList(ids)));
+    }
 }

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

@@ -1,8 +1,9 @@
 package com.yonge.cooleshow.teacher.controller;
 
-import com.yonge.cooleshow.biz.dal.dto.req.TeacherSetReq;
+import com.yonge.cooleshow.biz.dal.dto.req.UserSetReq;
 import com.yonge.cooleshow.biz.dal.vo.TeacherHomeVo;
 import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
+import com.yonge.cooleshow.biz.dal.vo.UserSetVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
@@ -63,28 +64,4 @@ public class TeacherController extends BaseController {
         }
         return  teacherService.openLive(user.getId());
     }
-
-    @GetMapping("/getSetDetail")
-    @ApiOperation(value = "获取设置详情")
-    public HttpResponseResult<TeacherVo> getSetDetail() {
-        SysUser user = sysUserFeignService.queryUserInfo();
-        if (user == null) {
-            return failed(HttpStatus.FORBIDDEN, "请登录");
-        }
-        TeacherVo detail = teacherService.getSetDetail(user.getId());
-        return succeed(detail);
-    }
-
-    @PostMapping("/submitSetDetail")
-    @ApiOperation(value = "修改设置信息", notes = "传入teacher")
-    public HttpResponseResult<TeacherVo> submitSetDetail(@RequestBody TeacherSetReq setReq) {
-        SysUser user = sysUserFeignService.queryUserInfo();
-        if (user == null) {
-            return failed(HttpStatus.FORBIDDEN, "请登录");
-        }
-        //设置
-        teacherService.submitSetDetail(setReq,user.getId());
-        return succeed(teacherService.getSetDetail(user.getId()));
-    }
-
 }

+ 4 - 0
toolset/utils/src/main/java/com/yonge/toolset/utils/date/DateUtil.java

@@ -541,12 +541,16 @@ public class DateUtil {
 
 	/**
 	 * 计算两个日期之间相差的天数。如果第一个日期在第二个日期之前,则返回正,反之返回负。
+	 * 若两个参数有空值,则返回0
 	 *
 	 * @param early 第一个日期
 	 * @param late 第二个日期
 	 * @return 两个日期之间相差的天数
 	 */
 	public static int daysBetween(Date early, Date late) {
+		if(null == early || null == late){
+			return 0;
+		}
 		Calendar c1 = Calendar.getInstance();
 		Calendar c2 = Calendar.getInstance();
 		c1.setTime(early);