Browse Source

增加ghDetail字段

xueyiming 7 months ago
parent
commit
608a590213

+ 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;
+    }
+
+}

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

@@ -31,4 +31,6 @@ public class GhDetailVo {
     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;
+    }
+}

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

@@ -65,6 +65,10 @@ 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);
+                }
                 ghDetailVos.add(ghDetailVo);
             }
         }
@@ -89,6 +93,9 @@ public class GhDetailServiceImpl implements GhDetailService {
             BeanUtils.copyProperties(ghDetailVo, ghDetail);
             ghDetail.setGhId(ghDetailVo.getAccountId());
             ghDetail.setGhName(ghDetailVo.getAccountName());
+            if (!CollectionUtils.isEmpty(ghDetailVo.getVideoIds())) {
+                ghDetail.setVideoIds(JSONObject.toJSONString(ghDetailVo.getVideoIds()));
+            }
             ghDetailMapper.insert(ghDetail);
             return CommonResponse.success();
         } catch (Exception e) {
@@ -105,6 +112,9 @@ public class GhDetailServiceImpl implements GhDetailService {
             BeanUtils.copyProperties(ghDetailVo, ghDetail);
             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()));
+    }
 }