Kaynağa Gözat

对应新项目 tnbm 中的字段要求进行修改

reghao 1 ay önce
ebeveyn
işleme
1213e9b6e1

+ 2 - 2
content/content-api/src/main/java/cn/reghao/tnb/content/api/dto/VideoCard.java

@@ -22,9 +22,9 @@ public class VideoCard implements Serializable {
     private boolean horizontal;
     private boolean cached;
     private String pubDateStr;
-    private UserCard user;
     private int view;
     private int comment;
+    private UserCard user;
 
     public VideoCard(VideoPostCard videoPostCard, String durationStr, boolean cached, String pubDateStr, UserCard user) {
         this.videoId = videoPostCard.getVideoId();
@@ -34,8 +34,8 @@ public class VideoCard implements Serializable {
         this.horizontal = videoPostCard.isHorizontal();
         this.cached = cached;
         this.pubDateStr = pubDateStr;
-        this.user = user;
         this.view = videoPostCard.getView();
         this.comment = videoPostCard.getComment();
+        this.user = user;
     }
 }

+ 5 - 1
content/content-api/src/main/java/cn/reghao/tnb/content/api/dto/VideoRecordCard.java

@@ -20,9 +20,11 @@ public class VideoRecordCard {
     private String coverUrl;
     private int duration;
     private String publishAt;
+    private String durationStr;
+    private String progress;
     private UserCard user;
 
-    public VideoRecordCard(VideoRecord videoRecord, UserCard user) {
+    public VideoRecordCard(VideoRecord videoRecord, String durationStr, String progress, UserCard user) {
         this.id = videoRecord.getCreateAt();
         this.currentTime = videoRecord.getCurrentTime();
         this.createAt = DateTimeConverter.format(videoRecord.getCreateAt());
@@ -31,6 +33,8 @@ public class VideoRecordCard {
         this.coverUrl = videoRecord.getCoverUrl();
         this.duration = videoRecord.getDuration();
         this.publishAt = DateTimeConverter.format(videoRecord.getPublishAt());
+        this.durationStr = durationStr;
+        this.progress = progress;
         this.user = user;
     }
 }

+ 1 - 2
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/db/mapper/BannerVideoMapper.java

@@ -2,7 +2,6 @@ package cn.reghao.tnb.content.app.vod.db.mapper;
 
 import cn.reghao.jutil.jdk.web.db.BaseMapper;
 import cn.reghao.tnb.content.app.vod.model.po.BannerVideo;
-import cn.reghao.tnb.content.app.vod.model.vo.BannerVideoVO;
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
@@ -13,5 +12,5 @@ import java.util.List;
  */
 @Mapper
 public interface BannerVideoMapper extends BaseMapper<BannerVideo> {
-    List<BannerVideoVO> findBannerVideos();
+    List<String> findBannerVideos();
 }

+ 19 - 0
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/model/vo/BannerVideoVO.java

@@ -1,16 +1,35 @@
 package cn.reghao.tnb.content.app.vod.model.vo;
 
+import cn.reghao.tnb.common.util.StringUtil;
+import cn.reghao.tnb.content.api.dto.VideoPostCard;
+import cn.reghao.tnb.user.api.dto.UserCard;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import lombok.Setter;
 
 /**
  * @author reghao
  * @date 2025-05-24 00:01:56
  */
+@NoArgsConstructor
 @Setter
 @Getter
 public class BannerVideoVO {
     private String videoId;
     private String title;
     private String coverUrl;
+    private String pubDateStr;
+    private int view;
+    private int comment;
+    private UserCard user;
+
+    public BannerVideoVO(VideoPostCard videoPostCard, UserCard user) {
+        this.videoId = videoPostCard.getVideoId();
+        this.title = videoPostCard.getTitle();
+        this.coverUrl = videoPostCard.getCoverUrl();
+        this.pubDateStr = StringUtil.getPubDateStr(videoPostCard.getPublishAt());
+        this.view = videoPostCard.getView();
+        this.comment = videoPostCard.getComment();
+        this.user = user;
+    }
 }

+ 4 - 2
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/service/AlbumService.java

@@ -22,6 +22,7 @@ import cn.reghao.tnb.content.app.vod.model.po.VideoPost;
 import cn.reghao.tnb.content.app.vod.model.query.AlbumQuery;
 import cn.reghao.tnb.content.app.vod.model.vo.AlbumInfo;
 import cn.reghao.tnb.content.app.vod.model.vo.AlbumItem;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
 
@@ -32,6 +33,7 @@ import java.util.stream.Collectors;
  * @author reghao
  * @date 2024-10-31 14:03:30
  */
+@Slf4j
 @Service
 public class AlbumService {
     @DubboReference(check = false)
@@ -119,7 +121,7 @@ public class AlbumService {
                         String signedUrl = ossService.getSignedUrl(objectId, null);
                         postAlbum.setCoverUrl(signedUrl);
                     } catch (Exception e) {
-                        e.printStackTrace();
+                        log.error("{}", e.getMessage());
                     }
                 }
             }
@@ -155,7 +157,7 @@ public class AlbumService {
                         String signedUrl = ossService.getSignedUrl(objectId, null);
                         postAlbum.setCoverUrl(signedUrl);
                     } catch (Exception e) {
-                        e.printStackTrace();
+                        log.error("{}", e.getMessage());
                     }
                 }
             }

+ 9 - 1
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/service/impl/VideoPlayServiceImpl.java

@@ -1,6 +1,7 @@
 package cn.reghao.tnb.content.app.vod.service.impl;
 
 import cn.reghao.file.api.iface.OssService;
+import cn.reghao.tnb.common.util.StringUtil;
 import cn.reghao.tnb.content.app.vod.model.dto.VideoUrlDto;
 import cn.reghao.tnb.common.auth.UserContext;
 import cn.reghao.tnb.common.db.PageScroll;
@@ -176,7 +177,14 @@ public class VideoPlayServiceImpl implements VideoPlayService {
         List<VideoRecordCard> list1 = list.stream().map(videoRecord -> {
             long publishBy = videoRecord.getPublishBy();
             UserCard userCard = userService.getUserAvatar(publishBy);
-            return new VideoRecordCard(videoRecord, userCard);
+            int duration = videoRecord.getDuration();
+            int currentTime = videoRecord.getCurrentTime();
+            String durationStr = StringUtil.getTimeStr(duration);
+            String progress = "0%";
+            if (duration > 0) {
+                progress = String.format("%.0f%%", (currentTime * 100.0) / duration);
+            }
+            return new VideoRecordCard(videoRecord, durationStr, progress, userCard);
         }).collect(Collectors.toList());
 
         long nextId1;

+ 10 - 2
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/service/impl/VideoPostQueryImpl.java

@@ -17,6 +17,7 @@ import cn.reghao.tnb.content.api.dto.VideoPostCard;
 import cn.reghao.tnb.content.app.vod.db.mapper.BannerVideoMapper;
 import cn.reghao.tnb.content.app.vod.db.mapper.VideoPostMapper;
 import cn.reghao.tnb.content.app.vod.db.repository.VideoRepository;
+import cn.reghao.tnb.content.app.vod.model.po.BannerVideo;
 import cn.reghao.tnb.content.app.vod.model.po.PostCategory;
 import cn.reghao.tnb.content.app.vod.model.po.VideoPost;
 import cn.reghao.tnb.content.app.vod.model.po.VideoStatistic;
@@ -260,8 +261,15 @@ public class VideoPostQueryImpl implements VideoPostQuery {
     }
 
     public List<BannerVideoVO> getBannerVideos() {
-        List<BannerVideoVO> list = bannerVideoMapper.findBannerVideos();
-        return list;
+        List<String> list = bannerVideoMapper.findBannerVideos();
+        List<VideoPostCard> list1 = videoPostMapper.findVideoCardByVideoIds(list);
+        return list1.stream()
+                .map(videoPostCard -> {
+                    long publishBy = videoPostCard.getPublishBy();
+                    UserCard userCard = userService.getUserAvatar(publishBy);
+                    return new BannerVideoVO(videoPostCard, userCard);
+                })
+                .collect(Collectors.toList());
     }
 
     @Override

+ 2 - 2
content/content-service/src/main/resources/mapper/vod/BannerVideoMapper.xml

@@ -17,8 +17,8 @@
         </foreach>
     </insert>
 
-    <select id="findBannerVideos" resultType="cn.reghao.tnb.content.app.vod.model.vo.BannerVideoVO">
-        select video_id,title,cover_url
+    <select id="findBannerVideos" resultType="java.lang.String">
+        select video_id
         from vod_banner_video
         limit 10
     </select>

+ 1 - 0
content/content-service/src/main/resources/mapper/vod/PostItemMapper.xml

@@ -47,5 +47,6 @@
         select *
         from vod_post_item
         where url=#{url}
+        limit 1
     </select>
 </mapper>