Ver código fonte

update VideoPostQueryImpl

reghao 11 meses atrás
pai
commit
7bbdeb1513

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

@@ -5,6 +5,7 @@ import cn.reghao.jutil.jdk.db.Page;
 import cn.reghao.tnb.content.app.vod.model.po.VideoPostTag;
 import cn.reghao.tnb.common.db.GroupCount;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -14,7 +15,11 @@ import java.util.List;
  */
 @Mapper
 public interface VideoPostTagMapper extends BaseMapper<VideoPostTag> {
-    int countVideosByTag(String tagId);
+    void updateSetScope(@Param("videoId") String videoId, @Param("scope") int scope);
+
+    int countVideosByTag(String tagId, List<Integer> scopes);
     List<String> findVideosByPage(Page page, String tagId, List<Integer> scopes);
+
     List<String> findVideoTags(String videoId);
+    List<String> findByGroupBy();
 }

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

@@ -170,7 +170,7 @@ public class VideoPostQueryImpl implements VideoPostQuery {
         long loginUser = UserContext.getUser();
         List<Integer> userScopes = contentPermission.getUserScopes(loginUser);
         String tagId = videoTag.getTagId();
-        int total = videoPostTagMapper.countVideosByTag(tagId);
+        int total = videoPostTagMapper.countVideosByTag(tagId, userScopes);
         Page page = new Page(pn, pageSize);
         List<String> videoIds = videoPostTagMapper.findVideosByPage(page, tagId, userScopes);
         List<VideoPostCard> list = videoPostMapper.findVideoCardByVideoIds(videoIds);

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

@@ -17,6 +17,12 @@
         </foreach>
     </insert>
 
+    <update id="updateSetScope">
+        update vod_video_tags
+        set `scope`=#{scope}
+        where video_id=#{videoId}
+    </update>
+
     <select id="findAll" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPostTag">
         select *
         from vod_video_tags
@@ -25,13 +31,16 @@
     <select id="countVideosByTag" resultType="java.lang.Integer">
         select count(*)
         from vod_video_tags
-        where tag_id=#{tagId}
+        where tag_id=#{tagId} and scope in
+        <foreach collection="scopes" item="id" index="index" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
     </select>
     <select id="findVideosByPage" resultType="java.lang.String">
         select video_id
         from vod_video_tags
         where tag_id=#{tagId} and scope in
-        <foreach collection="scope" item="id" index="index" open="(" close=")" separator=",">
+        <foreach collection="scopes" item="id" index="index" open="(" close=")" separator=",">
             #{id}
         </foreach>
     </select>
@@ -40,4 +49,9 @@
         from vod_video_tags
         where video_id=#{videoId}
     </select>
+    <select id="findByGroupBy" resultType="java.lang.String">
+        select video_id
+        from vod_video_tags
+        group by video_id
+    </select>
 </mapper>