Browse Source

新增可通过配置侧边栏仅查询用户当天课程数据

lmx 3 days ago
parent
commit
c08d6b090e

+ 34 - 0
fs-qwhook-sop/src/main/java/com/fs/app/controller/ApisFsUserCourseVideoController.java

@@ -1,9 +1,11 @@
 package com.fs.app.controller;
 
+import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.annotation.RepeatSubmit;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.R;
+import com.fs.course.config.CourseConfig;
 import com.fs.course.domain.FsUserCourse;
 import com.fs.course.param.FsCourseLinkCreateParam;
 import com.fs.course.param.FsCourseLinkMiniParam;
@@ -17,11 +19,15 @@ import com.fs.course.param.FsCourseListBySidebarParam;
 import com.fs.course.vo.FsCourseListBySidebarVO;
 import com.fs.course.vo.FsCourseVideoListBySidebarVO;
 import com.fs.course.vo.newfs.FsUserCourseVideoPageListVO;
+import com.fs.his.config.FsSysConfig;
+import com.fs.his.utils.ConfigUtil;
 import com.fs.qw.domain.QwUser;
 import com.fs.qw.service.IQwExternalContactService;
+import com.fs.system.service.ISysConfigService;
 import com.fs.voice.utils.StringUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.hc.openapi.tool.util.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -52,6 +58,8 @@ public class ApisFsUserCourseVideoController extends BaseController {
     @Autowired
     private IFsCourseLinkService courseLinkService;
 
+    @Autowired
+    private ISysConfigService configService;
 
 
     @ApiOperation("课程视频详情")
@@ -72,6 +80,19 @@ public class ApisFsUserCourseVideoController extends BaseController {
         }
         param.setCompanyId(qwUser.getCompanyId());
 
+        String json = configService.selectConfigByKey("course.config");
+        if(null == json || StringUtils.isBlank(json)){
+            return R.error("未配置课程信息");
+        }
+        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
+        //配置仅展示当天的课程
+        if(null != config && config.isSidebarOnlyShowTodayCourse()){
+            PageHelper.startPage(param.getPageNum(), param.getPageSize());
+            List<FsCourseListBySidebarVO> fsCourseListBySidebar = fsUserCourseService.getFsCourseListBySidebarToday(param);
+            PageInfo<FsCourseListBySidebarVO> result = new PageInfo<>(fsCourseListBySidebar);
+            return R.ok().put("data", result);
+        }
+
         PageHelper.startPage(param.getPageNum(), param.getPageSize());
         List<FsCourseListBySidebarVO> fsCourseListBySidebar = fsUserCourseService.getFsCourseListBySidebar(param);
         PageInfo<FsCourseListBySidebarVO> result = new PageInfo<>(fsCourseListBySidebar);
@@ -86,6 +107,19 @@ public class ApisFsUserCourseVideoController extends BaseController {
             return R.error("课程id不能为空");
         }
 
+        String json = configService.selectConfigByKey("course.config");
+        if(null == json || StringUtils.isBlank(json)){
+            return R.error("未配置课程信息");
+        }
+        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
+        //配置仅展示当天的课程
+        if(null != config && config.isSidebarOnlyShowTodayCourse()){
+            PageHelper.startPage(param.getPageNum(), param.getPageSize());
+            List<FsCourseVideoListBySidebarVO> videoListBySidebar = fsUserCourseVideoService.getFsCourseVideoListBySidebarToday(param);
+            PageInfo<FsCourseVideoListBySidebarVO> result = new PageInfo<>(videoListBySidebar);
+            return R.ok().put("data", result);
+        }
+
         PageHelper.startPage(param.getPageNum(), param.getPageSize());
         List<FsCourseVideoListBySidebarVO> videoListBySidebar = fsUserCourseVideoService.getFsCourseVideoListBySidebar(param);
         PageInfo<FsCourseVideoListBySidebarVO> result = new PageInfo<>(videoListBySidebar);

+ 5 - 0
fs-service/src/main/java/com/fs/course/config/CourseConfig.java

@@ -41,6 +41,11 @@ public class CourseConfig implements Serializable {
     private Integer delayEnd;
     private Integer isNegative;//是否为负数 0、不允许,1、允许
 
+    /**
+     * 侧边栏是否仅展示当天课程
+     */
+    private boolean sidebarOnlyShowTodayCourse;
+
     /**
      * 小程序授权头像昵称方式(目前仅会员看课有效)
      * 1:小程序原生授权 2:跳转H5服务号授权

+ 28 - 0
fs-service/src/main/java/com/fs/course/mapper/FsUserCourseMapper.java

@@ -3,6 +3,8 @@ package com.fs.course.mapper;
 import java.util.List;
 import java.util.Map;
 
+import com.fs.common.annotation.DataSource;
+import com.fs.common.enums.DataSourceType;
 import com.fs.course.domain.FsUserCourse;
 import com.fs.course.param.FsCourseListBySidebarParam;
 import com.fs.course.param.FsUserCourseAddStudyCourseParam;
@@ -274,6 +276,32 @@ public interface FsUserCourseMapper
             "</script> ")
     List<FsCourseListBySidebarVO> getFsCourseListBySidebar(@Param("data") FsCourseListBySidebarParam param);
 
+    @Select("<script> " +
+            " select  course_id,course_name,title,img_url from fs_user_course where is_del=0  and is_private = 1  " +
+            "  <if test=\"courseIds != null \">\n" +
+            " and course_id in " +
+            "<foreach collection='courseIds'  item='item' index='index'  open='(' separator=',' close=')'>" +
+            " #{item} " +
+            " </foreach> " +
+            "        </if>" +
+            "</script> ")
+    List<FsCourseListBySidebarVO> getFsCourseListBySidebarFilterCourseId(@Param("courseIds")  List<Long> courseIds);
+
+    @DataSource(DataSourceType.SOP)
+    @Select(" select  " +
+            "l.start_time,\n" +
+            "qstd.day_num,\n" +
+            "MAX(qstr.course_id) AS course_id,\n" +
+            "MAX(qstr.video_id) AS video_id\n" +
+            "FROM sop_user_logs_info i\n" +
+            " inner join sop_user_logs l  on l.id = i.user_logs_id \n" +
+            "inner join qw_sop qs on qs.id = l.sop_id AND qs.`status` IN (2,3,4)\n" +
+            "left join qw_sop_temp_day qstd on qs.temp_id = qstd.temp_id AND qstd.day_num = DATEDIFF(CURRENT_DATE, l.start_time) + 1 \n" +
+            "LEFT JOIN qw_sop_temp_rules qstr ON qstd.id = qstr.day_id  AND qstr.content_type = 2 \n" +
+            "where i.external_contact_id = #{externalUserId} \n" +
+            "GROUP BY qstd.id, l.start_time ")
+    List<SidebarTodayCourseVO> getFsCourseListBySidebarTodayList(@Param("externalUserId") String externalUserId);
+
     List<FsUserCourseParticipationRecordVO> getParticipationRecordByMap(@Param("params") Map<String, Object> params);
 
     /**

+ 17 - 0
fs-service/src/main/java/com/fs/course/mapper/FsUserCourseVideoMapper.java

@@ -199,6 +199,23 @@ public interface FsUserCourseVideoMapper
             "</script>")
     List<FsCourseVideoListBySidebarVO> getFsCourseVideoListBySidebar(@Param("data") FsCourseListBySidebarParam param);
 
+    @Select("<script> " +
+            "select v.video_id,v.course_id,v.title,v.video_url,v.thumbnail,v.duration,v.create_time from fs_user_course_video v " +
+            "left join fs_user_course c on c.course_id = v.course_id " +
+            "where c.is_private = 1 and v.is_del = 0 and v.course_id=#{data.courseId} " +
+            "  <if test=\"data.videoIds != null  \">\n" +
+            "   and v.video_id in " +
+            "       <foreach collection='data.videoIds'  item='item' index='index'  open='(' separator=',' close=')'> " +
+            "       #{item} " +
+            "       </foreach> " +
+            "  </if>" +
+            "    <if test=\"data.keyword != null and data.keyword !='' \">\n" +
+            "       AND v.title LIKE concat('%',#{data.keyword},'%')\n" +
+            "    </if>" +
+            "order by v.video_id asc " +
+            "</script>")
+    List<FsCourseVideoListBySidebarVO> getFsCourseVideoListBySidebarFilter(@Param("data") FsCourseListBySidebarParam param);
+
     List<FsUserCourseVideoPageListVO> selectFsUserCourseVideoListByMap(@Param("params") Map<String, Object> params);
 
     FsUserCourseVideo selectByFileKey(@Param("params")String fileKey);

+ 6 - 0
fs-service/src/main/java/com/fs/course/param/FsCourseListBySidebarParam.java

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.List;
 
 @Data
 @ApiModel
@@ -35,4 +36,9 @@ public class FsCourseListBySidebarParam implements Serializable {
     * 客户信息的长字符串id
     */
     private String externalUserId;
+
+    /**
+     * 用于过滤用户当日应该看课的视频id
+     */
+    private List<Long> videoIds;
 }

+ 2 - 0
fs-service/src/main/java/com/fs/course/service/IFsUserCourseService.java

@@ -113,6 +113,8 @@ public interface IFsUserCourseService
 
     List<FsCourseListBySidebarVO> getFsCourseListBySidebar(FsCourseListBySidebarParam param);
 
+    List<FsCourseListBySidebarVO> getFsCourseListBySidebarToday(FsCourseListBySidebarParam param);
+
     List<FsUserCourseParticipationRecordVO> getParticipationRecordByMap(Map<String, Object> params);
 
     R createCourseSortLink(FsCourseLinkCreateParam fsCourseLinkCreateParam);

+ 7 - 0
fs-service/src/main/java/com/fs/course/service/IFsUserCourseVideoService.java

@@ -158,6 +158,13 @@ public interface IFsUserCourseVideoService
 
     List<FsCourseVideoListBySidebarVO> getFsCourseVideoListBySidebar(FsCourseListBySidebarParam param);
 
+    /**
+     * 只查询用户当天课程章节数据
+     * @param param
+     * @return
+     */
+    List<FsCourseVideoListBySidebarVO> getFsCourseVideoListBySidebarToday(FsCourseListBySidebarParam param);
+
     R createMiniLink(FsCourseLinkMiniParam param);
     R createCartLink(FsCourseLinkMiniParam param);
 

+ 9 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseServiceImpl.java

@@ -518,6 +518,15 @@ public class FsUserCourseServiceImpl implements IFsUserCourseService
         return  fsUserCourseMapper.getFsCourseListBySidebar(param);
     }
 
+    @Override
+    public List<FsCourseListBySidebarVO> getFsCourseListBySidebarToday(FsCourseListBySidebarParam param) {
+
+        List<SidebarTodayCourseVO> list = fsUserCourseMapper.getFsCourseListBySidebarTodayList(param.getExternalUserId());
+        List<Long> courseIds = list.stream().map(SidebarTodayCourseVO::getCourseId).collect(Collectors.toList());
+        List<FsCourseListBySidebarVO> fsCourseListBySidebarFilterCourseId = fsUserCourseMapper.getFsCourseListBySidebarFilterCourseId(courseIds);
+        return fsCourseListBySidebarFilterCourseId;
+    }
+
     @Override
     public List<FsUserCourseParticipationRecordVO> getParticipationRecordByMap(Map<String, Object> params) {
         List<FsUserCourseParticipationRecordVO> list = fsUserCourseMapper.getParticipationRecordByMap(params);

+ 16 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -2503,6 +2503,22 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         return fsUserCourseVideoMapper.getFsCourseVideoListBySidebar(param);
     }
 
+    /**
+     * 只查询用户当天课程章节数据
+     * @param param
+     * @return
+     */
+    @Override
+    public List<FsCourseVideoListBySidebarVO> getFsCourseVideoListBySidebarToday(FsCourseListBySidebarParam param){
+
+        //得到当前能看的videoIds
+        List<SidebarTodayCourseVO> list = fsUserCourseMapper.getFsCourseListBySidebarTodayList(param.getExternalUserId());
+        List<Long> videoIds = list.stream().map(SidebarTodayCourseVO::getVideoId).collect(Collectors.toList());
+        param.setVideoIds(videoIds);
+        List<FsCourseVideoListBySidebarVO> fsCourseVideoListBySidebarFilter = fsUserCourseVideoMapper.getFsCourseVideoListBySidebarFilter(param);
+        return fsCourseVideoListBySidebarFilter;
+    }
+
     @Override
     public R createMiniLink(FsCourseLinkMiniParam param) {
 

+ 22 - 0
fs-service/src/main/java/com/fs/course/vo/SidebarTodayCourseVO.java

@@ -0,0 +1,22 @@
+package com.fs.course.vo;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author MixLiu
+ * @date 2025/10/23 下午3:53)
+ */
+@Data
+public class SidebarTodayCourseVO {
+
+    private Date startTime;
+
+    private Integer dayNum;
+
+    private Long courseId;
+
+    private Long videoId;
+
+}