Forráskód Böngészése

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	fs-service/src/main/java/com/fs/course/mapper/FsUserCourseVideoMapper.java
三七 2 napja
szülő
commit
8aac9652f3

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

@@ -246,7 +246,7 @@ public interface FsUserCourseMapper
             "        LEFT JOIN fs_user_course_period_days fcpd ON fcpd.period_id = fcp.period_id\n" +
             "        LEFT JOIN fs_user_course c ON c.course_id = fcpd.course_id\n" +
             "        WHERE\n" +
-            "        c.is_del = 0\n" +
+            "        c.is_del = 0 and fcp.del_flag = '0'\n" +
             "        AND FIND_IN_SET(#{companyId}, fcp.company_id)\n" +
             "        <if test=\"keyword != null and keyword !='' \">\n" +
             "            AND fcp.period_name LIKE concat('%',#{keyword},'%'\n" +

+ 12 - 1
fs-service/src/main/java/com/fs/course/mapper/FsUserCourseVideoMapper.java

@@ -14,6 +14,7 @@ import com.fs.course.vo.newfs.FsUserCourseVideoPageListVO;
 import com.fs.his.vo.OptionsVO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -119,7 +120,6 @@ public interface FsUserCourseVideoMapper
     @Select("select v.*  from fs_user_course_video v  " +
             "where v.is_del = 0 and v.course_id = #{courseId}  order by v.course_sort  ")
     List<FsUserCourseVideo> selectFsUserCourseListByCourseId(Long courseId);
-
     @Select({"<script> " +
             "select v.video_id, v.title, v.video_url, v.thumbnail, SEC_TO_TIME(v.duration) as duration,v.create_time, v.talent_id, v.course_id, " +
             " v.status, v.course_sort  from fs_user_course_video v  " +
@@ -202,6 +202,17 @@ public interface FsUserCourseVideoMapper
 
     FsUserCourseVideo selectByFileKey(@Param("params")String fileKey);
 
+    @Select("select * from fs_user_course_video where file_key = #{fileKey} ")
+    List<FsUserCourseVideo> selectVideoByFileKey(@Param("fileKey") String fileKey);
+
+    @Update("UPDATE fs_user_course_video " +
+            "SET line_one = #{lineOne}, " +
+            "    transcode_file_key = #{transcodeFileKey}, " +
+            "    is_transcode = 1, " +
+            "    update_time = NOW() " +  // 添加更新时间
+            "WHERE file_key = #{fileKey}")
+    void updateFsUserCourseVideoByFileKey(FsUserCourseVideo courseVideo);
+
     @Select("select title from fs_user_course_video WHERE video_id=#{videoId}")
     String selectFsUserCourseVideoByVideoForTitle(@Param("videoId") Long videoId);
 }

+ 52 - 12
fs-service/src/main/java/com/fs/course/service/impl/TencentCloudCosService.java

@@ -26,6 +26,7 @@ import com.tencentcloudapi.mps.v20190612.models.*;
 import lombok.AllArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.IOException;
@@ -159,25 +160,64 @@ public class TencentCloudCosService implements ITencentCloudCosService {
         return config;
     }
 
+//    @Override
+//    @Transactional
+//    public R updateUrl() {
+//        try {
+//            //查出已转码的视频并且没有文件key的
+//            List<FsVideoResource> videos =  videoResourceMapper.selectVideoIsTranscode();
+//            for (FsVideoResource video : videos ){
+//                String newUrl = replaceCourse(video.getLine1());
+//                FsVideoResource videoMap = new FsVideoResource();
+//                videoMap.setId(video.getId());
+//                videoMap.setLine1(newUrl);
+//                videoMap.setTranscodeFileKey(replaceCourse(video.getFileKey()));
+//                videoResourceMapper.updateById(videoMap);
+//                //更新课程管理目录的视频
+//                FsUserCourseVideo courseVideo = new FsUserCourseVideo();
+//                courseVideo.setFileKey(video.getFileKey());
+//                courseVideo.setLineOne(newUrl);
+//                courseVideo.setTranscodeFileKey(videoMap.getTranscodeFileKey());
+//                courseVideoMapper.updateFsUserCourseVideoByFileKey(courseVideo);
+//
+//            }
+//            return R.ok();
+//        }catch (Exception e){
+//            return R.error();
+//        }
+//
+//    }
+
     @Override
-    @Transactional
+    @Transactional(propagation = Propagation.REQUIRES_NEW)
     public R updateUrl() {
         try {
-            //查出已转码的视频并且没有文件key的
-            List<FsVideoResource> videos =  videoResourceMapper.selectVideoIsTranscode();
-            for (FsVideoResource video : videos ){
-                String newUrl = replaceCourse(video.getLine1());
-                FsVideoResource videoMap = new FsVideoResource();
-                videoMap.setId(video.getId());
-                videoMap.setLine1(newUrl);
-                videoMap.setTranscodeFileKey(replaceCourse(video.getFileKey()));
-                videoResourceMapper.updateById(videoMap);
+            List<FsVideoResource> videos = videoResourceMapper.selectVideoIsTranscode();
+            for (FsVideoResource video : videos) {
+                updateSingleVideo(video); // 将单个视频更新逻辑提取到方法
             }
             return R.ok();
-        }catch (Exception e){
-            return R.error();
+        } catch (Exception e) {
+            return R.error(e.getMessage());
         }
+    }
 
+    // 为每个视频更新使用独立事务
+    @Transactional(propagation = Propagation.REQUIRES_NEW)
+    public void updateSingleVideo(FsVideoResource video) {
+        String newUrl = replaceCourse(video.getLine1());
+
+        FsVideoResource videoMap = new FsVideoResource();
+        videoMap.setId(video.getId());
+        videoMap.setLine1(newUrl);
+        videoMap.setTranscodeFileKey(replaceCourse(video.getFileKey()));
+        videoResourceMapper.updateById(videoMap);
+
+        FsUserCourseVideo courseVideo = new FsUserCourseVideo();
+        courseVideo.setFileKey(video.getFileKey());
+        courseVideo.setLineOne(newUrl);
+        courseVideo.setTranscodeFileKey(videoMap.getTranscodeFileKey());
+        courseVideoMapper.updateFsUserCourseVideoByFileKey(courseVideo);
     }
 
     private byte[] getObjectInputStream() throws IOException {

+ 1 - 1
fs-service/src/main/resources/mapper/course/FsUserCourseVideoMapper.xml

@@ -248,7 +248,7 @@
         AND ccut.course_id = fcpd.course_id
         AND ccut.video_id = fcpd.video_id
         AND ccut.company_user_id = #{companyUserId}
-        where course.is_del = 0
+        where course.is_del = 0 and fcp = '0'
         AND FIND_IN_SET(#{companyId}, fcp.company_id)
         <if test="periodId != null and periodId !='' ">
             AND fcpd.period_id = #{periodId}

+ 1 - 1
fs-service/src/main/resources/mapper/his/FsUserMapper.xml

@@ -602,7 +602,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and fs_user.company_id = #{companyId}
         </if>
         GROUP BY
-        fs_user.`status`
+            fs_user.`status`
     </select>
 
     <select id="getRepeatUserNumber" resultType="int">

+ 2 - 7
fs-user-course/src/main/java/com/fs/course/controller/IndexController.java

@@ -3,14 +3,9 @@ package com.fs.course.controller;
 
 import cn.hutool.json.JSONUtil;
 import com.fs.common.core.domain.R;
-import com.fs.his.domain.*;
-import com.fs.his.param.*;
-import com.fs.his.service.*;
-import com.fs.his.vo.*;
 import com.fs.store.config.ConceptConfig;
 import com.fs.system.service.ISysConfigService;
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,7 +28,7 @@ public class IndexController extends AppBaseController {
 
 	@ApiOperation("企业理念")
 	@GetMapping("/getConcept")
-	@springfox.documentation.annotations.Cacheable("getConcept")
+	@Cacheable("getConcept")
 	public R getConcept(HttpServletRequest request){
 		String json=configService.selectConfigByKey("store.concept");
 		ConceptConfig config = JSONUtil.toBean(json, ConceptConfig.class);