Pārlūkot izejas kodu

Merge branch 'dev-xym-update-3rd' of Server/long-article-recommend into master

xueyiming 7 mēneši atpakaļ
vecāks
revīzija
406c1dfe09

+ 32 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/StrategyStatusEnum.java

@@ -0,0 +1,32 @@
+package com.tzld.longarticle.recommend.server.common.enums;
+
+import java.util.Objects;
+
+public enum StrategyStatusEnum {
+
+    DEFAULT(0, "保底视频"),
+    STRATEGY(1, "策略视频");
+
+    StrategyStatusEnum(Integer status, String name) {
+        this.status = status;
+        this.name = name;
+    }
+
+    public final Integer status;
+
+    public final String name;
+
+
+    public static String getStrategyStatusName(Integer status) {
+        if (status == null) {
+            return null;
+        }
+        for (StrategyStatusEnum strategyStatusEnum : StrategyStatusEnum.values()) {
+            if (Objects.equals(strategyStatusEnum.status, status)) {
+                return strategyStatusEnum.name;
+            }
+        }
+        return null;
+    }
+
+}

+ 7 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/GhDetailVo.java

@@ -3,6 +3,7 @@ package com.tzld.longarticle.recommend.server.model.vo;
 import lombok.Data;
 
 import java.util.Date;
+import java.util.List;
 
 @Data
 public class GhDetailVo {
@@ -26,4 +27,10 @@ public class GhDetailVo {
     private String updateTime;
 
     private String channel;
+
+    private List<Long> videoIds;
+
+    private Integer strategyStatus;
+
+    private String strategyStatusName;
 }

+ 16 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/StrategyStatusVo.java

@@ -0,0 +1,16 @@
+package com.tzld.longarticle.recommend.server.model.vo;
+
+import lombok.Data;
+
+@Data
+public class StrategyStatusVo {
+
+    private Integer status;
+
+    private String name;
+
+    public StrategyStatusVo(Integer status, String name) {
+        this.status = status;
+        this.name = name;
+    }
+}

+ 20 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/model/GhDetail.java

@@ -23,6 +23,10 @@ public class GhDetail {
 
     private String channel;
 
+    private String videoIds;
+
+    private Integer strategyStatus;
+
     public Long getId() {
         return id;
     }
@@ -102,4 +106,20 @@ public class GhDetail {
     public void setChannel(String channel) {
         this.channel = channel == null ? null : channel.trim();
     }
+
+    public String getVideoIds() {
+        return videoIds;
+    }
+
+    public void setVideoIds(String videoIds) {
+        this.videoIds = videoIds == null ? null : videoIds.trim();
+    }
+
+    public Integer getStrategyStatus() {
+        return strategyStatus;
+    }
+
+    public void setStrategyStatus(Integer strategyStatus) {
+        this.strategyStatus = strategyStatus;
+    }
 }

+ 131 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/model/GhDetailExample.java

@@ -765,6 +765,137 @@ public class GhDetailExample {
             addCriterion("channel not between", value1, value2, "channel");
             return (Criteria) this;
         }
+
+        public Criteria andVideoIdsIsNull() {
+            addCriterion("video_ids is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdsIsNotNull() {
+            addCriterion("video_ids is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdsEqualTo(String value) {
+            addCriterion("video_ids =", value, "videoIds");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdsNotEqualTo(String value) {
+            addCriterion("channel <>", value, "videoIds");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdsGreaterThan(String value) {
+            addCriterion("video_ids >", value, "videoIds");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdsGreaterThanOrEqualTo(String value) {
+            addCriterion("video_ids >=", value, "videoIds");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdsLessThan(String value) {
+            addCriterion("video_ids <", value, "videoIds");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdsLessThanOrEqualTo(String value) {
+            addCriterion("video_ids <=", value, "videoIds");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdsLike(String value) {
+            addCriterion("video_ids like", value, "videoIds");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdsNotLike(String value) {
+            addCriterion("video_ids not like", value, "videoIds");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdsIn(List<String> values) {
+            addCriterion("video_ids in", values, "videoIds");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdsNotIn(List<String> values) {
+            addCriterion("video_ids not in", values, "videoIds");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdsBetween(String value1, String value2) {
+            addCriterion("video_ids between", value1, value2, "videoIds");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdsNotBetween(String value1, String value2) {
+            addCriterion("video_ids not between", value1, value2, "videoIds");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyStatusIsNull() {
+            addCriterion("strategy_status is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyStatusIsNotNull() {
+            addCriterion("strategy_status is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyStatusEqualTo(Integer value) {
+            addCriterion("strategy_status =", value, "strategyStatus");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyStatusNotEqualTo(Integer value) {
+            addCriterion("strategy_status <>", value, "strategyStatus");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyStatusGreaterThan(Integer value) {
+            addCriterion("strategy_status >", value, "strategyStatus");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyStatusGreaterThanOrEqualTo(Integer value) {
+            addCriterion("strategy_status >=", value, "strategyStatus");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyStatusLessThan(Integer value) {
+            addCriterion("strategy_status <", value, "strategyStatus");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyStatusLessThanOrEqualTo(Integer value) {
+            addCriterion("strategy_status <=", value, "strategyStatus");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyStatusIn(List<Integer> values) {
+            addCriterion("strategy_status in", values, "strategyStatus");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyStatusNotIn(List<Integer> values) {
+            addCriterion("strategy_status not in", values, "strategyStatus");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyStatusBetween(Integer value1, Integer value2) {
+            addCriterion("strategy_status between", value1, value2, "strategyStatus");
+            return (Criteria) this;
+        }
+
+        public Criteria andStrategyStatusNotBetween(Integer value1, Integer value2) {
+            addCriterion("strategy_status not between", value1, value2, "strategyStatus");
+            return (Criteria) this;
+        }
+
     }
 
     public static class Criteria extends GeneratedCriteria {

+ 25 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/exterior/impl/GhDetailServiceImpl.java

@@ -3,6 +3,7 @@ package com.tzld.longarticle.recommend.server.service.exterior.impl;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.longarticle.recommend.server.common.enums.GhTypeEnum;
+import com.tzld.longarticle.recommend.server.common.enums.StrategyStatusEnum;
 import com.tzld.longarticle.recommend.server.common.response.CommonResponse;
 import com.tzld.longarticle.recommend.server.mapper.growth.GhDetailMapper;
 import com.tzld.longarticle.recommend.server.model.vo.GhDetailVo;
@@ -65,6 +66,11 @@ public class GhDetailServiceImpl implements GhDetailService {
                 ghDetailVo.setCreateTime(DateUtils.getDateString(ghDetail.getCreateTime().getTime(), "yyyy-MM-dd HH:mm:ss"));
                 ghDetailVo.setUpdateTime(DateUtils.getDateString(ghDetail.getUpdateTime().getTime(), "yyyy-MM-dd HH:mm:ss"));
                 ghDetailVo.setChannel(ghDetail.getChannel());
+                if (StringUtils.isNotEmpty(ghDetail.getVideoIds())) {
+                    List<Long> videoIds = JSONObject.parseArray(ghDetail.getVideoIds(), Long.class);
+                    ghDetailVo.setVideoIds(videoIds);
+                }
+                ghDetailVo.setStrategyStatusName(StrategyStatusEnum.getStrategyStatusName(ghDetail.getStrategyStatus()));
                 ghDetailVos.add(ghDetailVo);
             }
         }
@@ -84,12 +90,20 @@ public class GhDetailServiceImpl implements GhDetailService {
         }
 
         try {
-            ghDetailVo.setAccountId(ghDetailVo.getAccountId().trim());
             GhDetail ghDetail = new GhDetail();
             BeanUtils.copyProperties(ghDetailVo, ghDetail);
+            if (StringUtils.isNotEmpty(ghDetailVo.getAccountId())) {
+                ghDetail.setGhId(ghDetailVo.getAccountId().trim());
+            }
+            if (StringUtils.isNotEmpty(ghDetailVo.getAccountName())) {
+                ghDetail.setGhName(ghDetailVo.getAccountName());
+            }
             ghDetail.setGhId(ghDetailVo.getAccountId());
             ghDetail.setGhName(ghDetailVo.getAccountName());
-            ghDetailMapper.insert(ghDetail);
+            if (!CollectionUtils.isEmpty(ghDetailVo.getVideoIds())) {
+                ghDetail.setVideoIds(JSONObject.toJSONString(ghDetailVo.getVideoIds()));
+            }
+            ghDetailMapper.insertSelective(ghDetail);
             return CommonResponse.success();
         } catch (Exception e) {
             log.error("addGhDetail error", e);
@@ -100,11 +114,19 @@ public class GhDetailServiceImpl implements GhDetailService {
     @Override
     public CommonResponse<Void> updateDetail(GhDetailVo ghDetailVo) {
         try {
-            ghDetailVo.setAccountId(ghDetailVo.getAccountId().trim());
             GhDetail ghDetail = new GhDetail();
             BeanUtils.copyProperties(ghDetailVo, ghDetail);
+            if (StringUtils.isNotEmpty(ghDetailVo.getAccountId())) {
+                ghDetail.setGhId(ghDetailVo.getAccountId().trim());
+            }
+            if (StringUtils.isNotEmpty(ghDetailVo.getAccountName())) {
+                ghDetail.setGhName(ghDetailVo.getAccountName());
+            }
             ghDetail.setGhId(ghDetailVo.getAccountId());
             ghDetail.setGhName(ghDetailVo.getAccountName());
+            if (!CollectionUtils.isEmpty(ghDetailVo.getVideoIds())) {
+                ghDetail.setVideoIds(JSONObject.toJSONString(ghDetailVo.getVideoIds()));
+            }
             ghDetailMapper.updateByPrimaryKeySelective(ghDetail);
             return CommonResponse.success();
         } catch (Exception e) {

+ 9 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/AccountDetailController.java

@@ -2,9 +2,11 @@ package com.tzld.longarticle.recommend.server.web;
 
 
 import com.tzld.longarticle.recommend.server.common.enums.GhTypeEnum;
+import com.tzld.longarticle.recommend.server.common.enums.StrategyStatusEnum;
 import com.tzld.longarticle.recommend.server.common.response.CommonResponse;
 import com.tzld.longarticle.recommend.server.model.vo.GhDetailVo;
 import com.tzld.longarticle.recommend.server.model.vo.GhTypeVo;
+import com.tzld.longarticle.recommend.server.model.vo.StrategyStatusVo;
 import com.tzld.longarticle.recommend.server.service.exterior.GhDetailService;
 import com.tzld.longarticle.recommend.server.util.page.Page;
 import lombok.extern.slf4j.Slf4j;
@@ -58,4 +60,11 @@ public class AccountDetailController {
                 .map(ghTypeEnum -> new GhTypeVo(ghTypeEnum.type, ghTypeEnum.name))
                 .collect(Collectors.toList()));
     }
+
+    @GetMapping("/strategyStatus")
+    public CommonResponse<List<StrategyStatusVo>> getAllStrategyStatus() {
+        return CommonResponse.success(Arrays.stream(StrategyStatusEnum.values())
+                .map(strategyStatusEnum -> new StrategyStatusVo(strategyStatusEnum.status, strategyStatusEnum.name))
+                .collect(Collectors.toList()));
+    }
 }

+ 36 - 5
long-article-recommend-service/src/main/resources/mapper/growth/GhDetailMapper.xml

@@ -12,6 +12,8 @@
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
     <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
     <result column="channel" jdbcType="VARCHAR" property="channel" />
+    <result column="video_ids" jdbcType="VARCHAR" property="videoIds" />
+    <result column="strategy_status" jdbcType="INTEGER" property="strategyStatus" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <where>
@@ -72,7 +74,7 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, gh_id, gh_name, type, category1, category2, is_delete, create_time, update_time, channel
+    id, gh_id, gh_name, type, category1, category2, is_delete, create_time, update_time, channel, video_ids, strategy_status
   </sql>
   <select id="selectByExample" parameterType="com.tzld.longarticle.recommend.server.repository.model.GhDetailExample" resultMap="BaseResultMap">
     select
@@ -113,10 +115,11 @@
     </selectKey>
     insert into gh_detail (gh_id, gh_name, `type`,
       category1, category2,
-      create_time, update_time, channel)
+      create_time, update_time, channel, video_ids, strategy_status)
     values (#{ghId,jdbcType=VARCHAR}, #{ghName,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, 
       #{category1,jdbcType=VARCHAR}, #{category2,jdbcType=VARCHAR},
-      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{channel,jdbcType=VARCHAR})
+      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{channel,jdbcType=VARCHAR}
+    #{videoIds,jdbcType=VARCHAR}, #{strategyStatus,jdbcType=INTEGER})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.longarticle.recommend.server.repository.model.GhDetail">
     <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
@@ -151,6 +154,12 @@
       <if test="channel != null">
         channel,
       </if>
+      <if test="videoIds != null">
+        video_ids,
+      </if>
+      <if test="strategyStatus != null">
+        strategy_status,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="ghId != null">
@@ -180,6 +189,12 @@
       <if test="channel != null">
         #{channel,jdbcType=VARCHAR},
       </if>
+      <if test="videoIds != null">
+        #{videoIds,jdbcType=VARCHAR},
+      </if>
+      <if test="strategyStatus != null">
+        #{strategyStatus,jdbcType=INTEGER},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.tzld.longarticle.recommend.server.repository.model.GhDetailExample" resultType="java.lang.Long">
@@ -221,6 +236,12 @@
       <if test="row.channel != null">
         channel = #{row.channel,jdbcType=VARCHAR},
       </if>
+      <if test="row.videoIds != null">
+        video_ids = #{row.videoIds,jdbcType=VARCHAR},
+      </if>
+      <if test="row.strategyStatus != null">
+        strategyStatus = #{row.strategyStatus,jdbcType=INTEGER},
+      </if>
     </set>
     <if test="example != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -237,7 +258,9 @@
       is_delete = #{row.isDelete,jdbcType=INTEGER},
       create_time = #{row.createTime,jdbcType=TIMESTAMP},
       update_time = #{row.updateTime,jdbcType=TIMESTAMP},
-      channel = #{row.channel,jdbcType=VARCHAR}
+      channel = #{row.channel,jdbcType=VARCHAR},
+      video_ids = #{row.videoIds,jdbcType=VARCHAR},
+      strategy_status = #{row.strategyStatus,jdbcType=INTEGER}
     <if test="example != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -272,6 +295,12 @@
       <if test="channel != null">
         channel = #{channel,jdbcType=VARCHAR},
       </if>
+      <if test="videoIds != null">
+        video_ids = #{videoIds,jdbcType=VARCHAR},
+      </if>
+      <if test="strategyStatus != null">
+        strategy_status = #{strategyStatus,jdbcType=INTEGER},
+      </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -285,7 +314,9 @@
       is_delete = #{isDelete,jdbcType=INTEGER},
       create_time = #{createTime,jdbcType=TIMESTAMP},
       update_time = #{updateTime,jdbcType=TIMESTAMP},
-      channel = #{channel,jdbcType=VARCHAR}
+      channel = #{channel,jdbcType=VARCHAR},
+      video_ids = #{videoIds,jdbcType=VARCHAR},
+      strategy_status = #{strategyStatus,jdbcType=INTEGER}
     where id = #{id,jdbcType=BIGINT}
   </update>
 </mapper>