Selaa lähdekoodia

内容池交互 tag多选

wangyunpeng 1 viikko sitten
vanhempi
commit
bd64a08330

+ 3 - 1
api-module/src/main/java/com/tzld/piaoquan/api/model/param/contentplatform/VideoContentListParam.java

@@ -4,6 +4,8 @@ import com.tzld.piaoquan.api.model.param.PageParam;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.util.List;
+
 @Data
 public class VideoContentListParam extends PageParam {
 
@@ -23,7 +25,7 @@ public class VideoContentListParam extends PageParam {
     private Integer sort = 0;
 
     @ApiModelProperty(value = "标签 ")
-    private String tag;
+    private List<String> tags;
 
     @ApiModelProperty(value = "近期未使用 0-历史 1-近30天 2-近14天 3-近7天 4-近3天")
     private Integer recentNotUsed;

+ 30 - 18
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImpl.java

@@ -489,7 +489,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         String channel = getVideoContentListChannel(param.getSort(), user.getChannel());
         String strategy = param.getSort() == 3 ? "recommend" : "normal";
         // 标签筛选
-        String tagFilterSql = getVideoContentListTagFilterSql(param.getTag(), user.getId(), type, user.getChannel());
+        String tagFilterSql = getVideoContentListTagFilterSql(param.getTags(), user.getId(), type, user.getChannel());
         // 近期未使用
         Long excludeVideoRecentNotUsed = getVideoExcludeRecentNotUsed(param.getRecentNotUsed());
         List<ContentPlatformVideo> videoList = planMapperExt.getVideoList(param, dt, datastatDt, type, channel, strategy,
@@ -499,26 +499,38 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         return result;
     }
 
-    private String getVideoContentListTagFilterSql(String tag, Long accountId, String type, String channel) {
-        if (Objects.isNull(tag)) {
+    private String getVideoContentListTagFilterSql(List<String> tags, Long accountId, String type, String channel) {
+        if (CollectionUtils.isEmpty(tags)) {
             return null;
         }
-        switch (tag) {
-            case "票圈受欢迎":
-                return "videoTag.platform = 'platform'";
-            case "同类用户喜欢":
-                return "videoTag.account_id = " + accountId;
-            case "你的用户爱看":
-                return "videoTag.type = " + type;
-            case "猜TA想看":
-                return "videoTag.channel = " + channel;
-            default:
-                return null;
+        StringBuilder sql = new StringBuilder("(");
+        for (String tag : tags) {
+            String item;
+            switch (tag) {
+                case "票圈受欢迎":
+                    item = "videoTag.platform = 'platform'";
+                    break;
+                case "同类用户喜欢":
+                    item = "videoTag.account_id = " + accountId;
+                    break;
+                case "你的用户爱看":
+                    item = "videoTag.type = " + type;
+                    break;
+                case "猜TA想看":
+                    item = "videoTag.channel = " + channel;
+                    break;
+                default:
+                    item = null;
+            }
+            if (Objects.nonNull(item)) {
+                sql.append(item).append(" or ");
+            }
+        }
+        if (sql.length() > 1) {
+            sql.setLength(sql.length() - 4);
         }
-        //- 票圈受欢迎
-        //- 同类用户喜欢
-        //- 你的用户爱看
-        //- 猜TA想看
+        sql.append(")");
+        return sql.toString();
     }
 
     private Long getVideoExcludeRecentNotUsed(Integer recentNotUsed) {