فهرست منبع

app达人修复

xw 2 روز پیش
والد
کامیت
7c98ef91a8

+ 10 - 0
fs-service/src/main/java/com/fs/course/mapper/FsUserTalentFollowMapper.java

@@ -68,6 +68,16 @@ public interface FsUserTalentFollowMapper
     @Select("select ifnull(count(1),0) from fs_user_talent_follow  where talent_id =#{talentId} and user_id=#{userId}")
     int checkFollow(@Param("talentId") Long talentId, @Param("userId")long userId);
 
+    @Select("<script>" +
+            "select talent_id from fs_user_talent_follow " +
+            "where user_id = #{userId} " +
+            "and talent_id in " +
+            "<foreach item='talentId' collection='talentIds' open='(' separator=',' close=')'>" +
+            "#{talentId}" +
+            "</foreach>" +
+            "</script>")
+    List<Long> selectFollowedTalentIds(@Param("talentIds") List<Long> talentIds, @Param("userId") long userId);
+
 
     @Delete("delete from fs_user_talent_follow  where talent_id =#{talentId} and user_id=#{userId} ")
     int deleteFollow(@Param("talentId") Long talentId,@Param("userId")long userId);

+ 6 - 6
fs-service/src/main/java/com/fs/course/mapper/FsUserVideoMapper.java

@@ -132,7 +132,7 @@ public interface FsUserVideoMapper
     int minusFavorite(Long videoId);
 
     @Select({"<script> " +
-            "select v.video_id as id,v.title,v.description as msg,t.nick_name as username,t.avatar as headImg, " +
+            "select v.video_id as id,v.talent_id as talentId,t.user_id as userId,v.title,v.description as msg,t.nick_name as username,t.avatar as headImg, " +
             "v.thumbnail as cover,v.url as src,v.likes as likeNum,v.comments as smsNum,v.favorite_num," +
             "v.create_time,v.views as playNumber,v.product_id,p.img_url,p.package_name,v.upload_type,v.shares,v.add_num from fs_user_video v " +
             "left join fs_user_talent t on t.talent_id = v.talent_id " +
@@ -150,7 +150,7 @@ public interface FsUserVideoMapper
     void updateCommentCount(@Param("videoId") Long videoId, @Param("commentCount") Integer commentCount);
 
     @Select({"<script> " +
-            "select v.video_id as id,v.title,v.description as msg,t.nick_name as username,t.avatar as headImg, " +
+            "select v.video_id as id,v.talent_id as talentId,t.user_id as userId,v.title,v.description as msg,t.nick_name as username,t.avatar as headImg, " +
             "v.thumbnail as cover,v.url as src,v.likes as likeNum,v.comments as smsNum,v.favorite_num," +
             "v.create_time,v.views as playNumber,v.product_id,v.product_json,p.img_url,p.package_name,v.shares from fs_user_video_favorite f " +
             "left join fs_user_video v on v.video_id = f.video_id " +
@@ -163,7 +163,7 @@ public interface FsUserVideoMapper
 
 
     @Select({"<script> " +
-            "select v.video_id as id,v.title,v.description as msg,t.nick_name as username,t.avatar as headImg, " +
+            "select v.video_id as id,v.talent_id as talentId,t.user_id as userId,v.title,v.description as msg,t.nick_name as username,t.avatar as headImg, " +
             "v.thumbnail as cover,v.url as src,v.likes as likeNum,v.comments as smsNum,v.favorite_num," +
             "v.create_time,v.views as playNumber,v.product_id,v.product_json,p.img_url,p.package_name,v.shares from fs_user_video_like l " +
             "left join fs_user_video v on v.video_id = l.video_id " +
@@ -176,7 +176,7 @@ public interface FsUserVideoMapper
 
 
     @Select({"<script> " +
-            "select v.video_id as id,v.title,v.description as msg,t.nick_name as username,t.avatar as headImg, " +
+            "select v.video_id as id,v.talent_id as talentId,t.user_id as userId,v.title,v.description as msg,t.nick_name as username,t.avatar as headImg, " +
             "v.thumbnail as cover,v.url as src,v.likes as likeNum,v.comments as smsNum,v.favorite_num," +
             "v.create_time,v.views as playNumber,v.product_id,v.product_json,p.img_url,p.package_name,v.shares from fs_user_video_comment c " +
             "left join fs_user_video v on v.video_id = c.video_id " +
@@ -205,7 +205,7 @@ public interface FsUserVideoMapper
     int updateViews(Long videoId);
 
     @Select({"<script> " +
-            "select v.video_id as id,v.title,v.description as msg,t.nick_name as username,t.avatar as headImg, " +
+            "select v.video_id as id,v.talent_id as talentId,t.user_id as userId,v.title,v.description as msg,t.nick_name as username,t.avatar as headImg, " +
             "v.thumbnail as cover,v.url as src,v.likes as likeNum,v.comments as smsNum,v.favorite_num," +
             "v.create_time,v.views as playNumber,v.product_id,p.img_url,p.package_name,v.upload_type,v.shares from fs_user_video v " +
             "left join fs_user_talent t on t.talent_id = v.talent_id " +
@@ -252,7 +252,7 @@ public interface FsUserVideoMapper
     int countFavoriteVideos(@Param("userId") Long userId);
 
     @Select({"<script> " +
-            "select v.video_id as id,v.title,v.description as msg,t.nick_name as username,t.avatar as headImg, " +
+            "select v.video_id as id,v.talent_id as talentId,t.user_id as userId,v.title,v.description as msg,t.nick_name as username,t.avatar as headImg, " +
             "v.thumbnail as cover,v.url as src,v.likes as likeNum,v.comments as smsNum,v.favorite_num," +
             "v.create_time,v.views as playNumber,v.product_id,p.img_url,p.package_name,v.upload_type,v.shares,v.add_num,v.is_audit,v.status from fs_user_video v " +
             "left join fs_user_talent t on t.talent_id = v.talent_id " +

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

@@ -86,6 +86,8 @@ public interface IFsUserVideoService {
 
     FsUserVideoListUVO getVideoById(Long videoId);
 
+    FsUserVideoListUVO getVideoById(Long videoId, Long userId);
+
     int auditUserVideos(FsUserVideoAuditParam param);
 
     int updateFsUserVideoIsShow(Long[] videoIds, int i);

+ 0 - 1
fs-service/src/main/java/com/fs/course/service/impl/FsUserTalentServiceImpl.java

@@ -160,7 +160,6 @@ public class FsUserTalentServiceImpl implements IFsUserTalentService
         fsUserTalent.setIsAudit(1l);
         fsUserTalent.setAuditTime(new Date());
         fsUserTalent.setStatus(1l);
-        fsUserTalent.setIsDel(1l);
         fsUserTalentMapper.insertFsUserTalent(fsUserTalent);
         return 1;
     }

+ 39 - 4
fs-service/src/main/java/com/fs/course/service/impl/FsUserVideoServiceImpl.java

@@ -57,6 +57,8 @@ public class FsUserVideoServiceImpl implements IFsUserVideoService {
     @Autowired
     private FsUserVideoCommentMapper fsUserVideoCommentMapper;
     @Autowired
+    private FsUserTalentFollowMapper fsUserTalentFollowMapper;
+    @Autowired
     private IRecommendationService recommendationService;
     @Autowired
     private RedisTemplate redisTemplate;
@@ -266,10 +268,33 @@ public class FsUserVideoServiceImpl implements IFsUserVideoService {
                 }
             }
 
+            fillTalentFollowInfo(userId, list);
         }
         return list;
     }
 
+    private void fillTalentFollowInfo(Long userId, List<FsUserVideoListUVO> list) {
+        if (list == null || list.isEmpty()) {
+            return;
+        }
+        List<Long> talentIds = list.stream()
+                .map(FsUserVideoListUVO::getTalentId)
+                .filter(Objects::nonNull)
+                .distinct()
+                .collect(Collectors.toList());
+        Set<Long> followedTalentIds = Collections.emptySet();
+        if (userId != null && !talentIds.isEmpty()) {
+            followedTalentIds = new HashSet<>(fsUserTalentFollowMapper.selectFollowedTalentIds(talentIds, userId));
+        }
+        for (FsUserVideoListUVO vo : list) {
+            if (vo.getTalentId() != null && followedTalentIds.contains(vo.getTalentId())) {
+                vo.setIsFollow(1);
+            } else {
+                vo.setIsFollow(0);
+            }
+        }
+    }
+
     @Override
     public FsUserVideoPVO selectFsUserVideoPVOByVideoId(Long videoId) {
         return fsUserVideoMapper.selectFsUserVideoPVO(videoId);
@@ -282,7 +307,16 @@ public class FsUserVideoServiceImpl implements IFsUserVideoService {
 
     @Override
     public FsUserVideoListUVO getVideoById(Long videoId) {
-        return fsUserVideoMapper.selectFsUserVideoListUVOByVideoId(videoId);
+        return getVideoById(videoId, null);
+    }
+
+    @Override
+    public FsUserVideoListUVO getVideoById(Long videoId, Long userId) {
+        FsUserVideoListUVO video = fsUserVideoMapper.selectFsUserVideoListUVOByVideoId(videoId);
+        if (video != null && userId != null) {
+            selectLikesAndFavorites(userId, Collections.singletonList(video));
+        }
+        return video;
     }
 
     @Override
@@ -346,9 +380,9 @@ public class FsUserVideoServiceImpl implements IFsUserVideoService {
                     fsUserVideo.setAddNum(likeAddNum + "," + favoriteAddNum + "," + sharesAddNum);
                     updateFsUserVideo(fsUserVideo);
                 }
-                vo.setLikeNum(vo.getLikeNum() + likeAddNum);
-                vo.setFavoriteNum(vo.getFavoriteNum() + favoriteAddNum);
-                vo.setShares(vo.getShares() + sharesAddNum);
+                vo.setLikeNum((vo.getLikeNum() == null ? 0 : vo.getLikeNum()) + likeAddNum);
+                vo.setFavoriteNum((vo.getFavoriteNum() == null ? 0 : vo.getFavoriteNum()) + favoriteAddNum);
+                vo.setShares((vo.getShares() == null ? 0L : vo.getShares()) + sharesAddNum);
 
             }
         }
@@ -446,6 +480,7 @@ public class FsUserVideoServiceImpl implements IFsUserVideoService {
                 entity.setFavorite(1);
             }
         }
+        fillTalentFollowInfo(userId, list);
     }
 
     public static String updateUrlPrefix(String url) {

+ 3 - 0
fs-service/src/main/java/com/fs/course/vo/FsUserVideoListUVO.java

@@ -9,6 +9,9 @@ import java.util.List;
 @Data
 public class FsUserVideoListUVO {
     private String id; // _id
+    private Long talentId;//达人ID
+    private Long userId;//发布者用户ID
+    private Integer isFollow = 0;//是否关注达人,0未关注,1已关注
     private String username;//2.视频拥有者名称
     private String headImg;//3.发布者头像
     private String cover;//视频封面

+ 2 - 0
fs-user-app/src/main/java/com/fs/app/controller/TalentController.java

@@ -97,11 +97,13 @@ public class TalentController extends  AppBaseController{
         return getDataTable(userTalentFollowService.selectFsUserTalentFansVoList(param));
     }
 
+    @Login
     @ApiOperation("获取达人关注列表")
     @GetMapping("/getTalentFollowByUserId")
     private TableDataInfo getFollowByUserId(FsUserTalentFansParam param){
         startPage();
         param.setTalentId(null);
+        param.setUserId(Long.parseLong(getUserId()));
         return getDataTable(userTalentFollowService.selectFsUserFollowVoList(param));
     }
 

+ 1 - 1
fs-user-app/src/main/java/com/fs/app/controller/VideoController.java

@@ -65,7 +65,7 @@ public class VideoController extends  AppBaseController{
         }
         if (param.getVideoId() != null && param.getPageNum()==1) {
             // 获取该 videoId 对应的视频数据
-            FsUserVideoListUVO video = videoService.getVideoById(param.getVideoId());
+            FsUserVideoListUVO video = videoService.getVideoById(param.getVideoId(), param.getUserId());
             if (video != null) {
                 // 将视频数据放到列表的第一个位置
                 list.removeIf(v -> v.getId().equals(param.getVideoId())); // 删除原列表中的该视频

+ 1 - 1
fs-user-app/src/main/java/com/fs/app/controller/store/VideoScrmController.java

@@ -58,7 +58,7 @@ public class VideoScrmController extends AppBaseController {
         }
         if (param.getVideoId() != null && param.getPageNum()==1) {
             // 获取该 videoId 对应的视频数据
-            FsUserVideoListUVO video = videoService.getVideoById(param.getVideoId());
+            FsUserVideoListUVO video = videoService.getVideoById(param.getVideoId(), param.getUserId());
             if (video != null) {
                 // 将视频数据放到列表的第一个位置
                 list.removeIf(v -> v.getId().equals(param.getVideoId())); // 删除原列表中的该视频