浏览代码

增加公众号计划删除

wangyunpeng 2 月之前
父节点
当前提交
961a9a2b81

+ 3 - 1
api-module/src/main/java/com/tzld/piaoquan/api/common/enums/ExceptionEnum.java

@@ -28,10 +28,12 @@ public enum ExceptionEnum {
 
     // 合作账号
     GZH_EXISTS(2000, "公众号已由别的用户授权,该用户不能再授权此公众号,请联系平台运营"),
+    GZH_DELETE_PLAN_EXISTS(2001, "公众号下存在未删除计划,无法删除"),
 
     // 公众号计划
     GZH_SCENE_PLAN_EXISTS(3000, "公众号该类型计划已存在"),
-    GZH_PLAN_VIDEO_SIZE_EXCEED(3000, "计划视频数量超过限制"),
+    GZH_PLAN_NOT_EXISTS(3001, "公众号计划不存在"),
+    GZH_PLAN_VIDEO_SIZE_EXCEED(3002, "计划视频数量超过限制"),
     ;
     private int code;
     private String msg;

+ 8 - 0
api-module/src/main/java/com/tzld/piaoquan/api/controller/contentplatform/ContentPlatformPlanController.java

@@ -1,6 +1,7 @@
 package com.tzld.piaoquan.api.controller.contentplatform;
 
 import com.tzld.piaoquan.api.job.ContentPlatformVideoJob;
+import com.tzld.piaoquan.api.model.param.IdParam;
 import com.tzld.piaoquan.api.model.param.contentplatform.*;
 import com.tzld.piaoquan.api.model.vo.contentplatform.GzhPlanItemVO;
 import com.tzld.piaoquan.api.model.vo.contentplatform.QwPlanItemVO;
@@ -38,6 +39,13 @@ public class ContentPlatformPlanController {
         return CommonResponse.success();
     }
 
+    @ApiOperation(value = "公众号计划 删除")
+    @PostMapping("/gzh/delete")
+    public CommonResponse<Void> gzhPlanDelete(@RequestBody IdParam<Long> param) {
+        planService.gzhPlanDelete(param.getId());
+        return CommonResponse.success();
+    }
+
     @ApiOperation(value = "发布内容视频列表")
     @PostMapping("/videoContentList")
     public CommonResponse<Page<VideoContentItemVO>> getVideoContentList(@RequestBody VideoContentListParam param) {

+ 11 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformGzhPlan.java

@@ -11,6 +11,8 @@ public class ContentPlatformGzhPlan {
 
     private String externalId;
 
+    private Integer status;
+
     private Long createAccountId;
 
     private Long createTimestamp;
@@ -57,6 +59,14 @@ public class ContentPlatformGzhPlan {
         this.externalId = externalId;
     }
 
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
     public Long getCreateAccountId() {
         return createAccountId;
     }
@@ -92,6 +102,7 @@ public class ContentPlatformGzhPlan {
         sb.append(", accountId=").append(accountId);
         sb.append(", scene=").append(scene);
         sb.append(", externalId=").append(externalId);
+        sb.append(", status=").append(status);
         sb.append(", createAccountId=").append(createAccountId);
         sb.append(", createTimestamp=").append(createTimestamp);
         sb.append(", updateTimestamp=").append(updateTimestamp);

+ 60 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformGzhPlanExample.java

@@ -425,6 +425,66 @@ public class ContentPlatformGzhPlanExample {
             return (Criteria) this;
         }
 
+        public Criteria andStatusIsNull() {
+            addCriterion("`status` is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusIsNotNull() {
+            addCriterion("`status` is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusEqualTo(Integer value) {
+            addCriterion("`status` =", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotEqualTo(Integer value) {
+            addCriterion("`status` <>", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusGreaterThan(Integer value) {
+            addCriterion("`status` >", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusGreaterThanOrEqualTo(Integer value) {
+            addCriterion("`status` >=", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusLessThan(Integer value) {
+            addCriterion("`status` <", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusLessThanOrEqualTo(Integer value) {
+            addCriterion("`status` <=", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusIn(List<Integer> values) {
+            addCriterion("`status` in", values, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotIn(List<Integer> values) {
+            addCriterion("`status` not in", values, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusBetween(Integer value1, Integer value2) {
+            addCriterion("`status` between", value1, value2, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotBetween(Integer value1, Integer value2) {
+            addCriterion("`status` not between", value1, value2, "status");
+            return (Criteria) this;
+        }
+
         public Criteria andCreateAccountIdIsNull() {
             addCriterion("create_account_id is null");
             return (Criteria) this;

+ 2 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/ContentPlatformPlanService.java

@@ -57,4 +57,6 @@ public interface ContentPlatformPlanService {
     List<ContentPlatformVideo> getVideoContentListByVideoIds(List<Long> videoIds);
 
     List<ContentPlatformGzhPlanVideo> getGzhPlanVideoList(List<Long> planIds);
+
+    void gzhPlanDelete(Long id);
 }

+ 4 - 7
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformCooperateAccountServiceImpl.java

@@ -156,18 +156,15 @@ public class ContentPlatformCooperateAccountServiceImpl implements ContentPlatfo
 
     @Override
     public void gzhDelete(Long id) {
+        List<ContentPlatformGzhPlan> planList = planService.getGzhPlanListByCooperateAccountId(id);
+        if (CollectionUtils.isNotEmpty(planList)) {
+            throw new CommonException(ExceptionEnum.GZH_DELETE_PLAN_EXISTS);
+        }
         ContentPlatformGzhAccount gzhAccount = new ContentPlatformGzhAccount();
         gzhAccount.setId(id);
         gzhAccount.setStatus(0);
         gzhAccount.setUpdateTimestamp(System.currentTimeMillis());
         gzhAccountMapper.updateByPrimaryKeySelective(gzhAccount);
-        // 调用aigc关闭发布计划
-        List<ContentPlatformGzhPlan> planList = planService.getGzhPlanListByCooperateAccountId(id);
-        if (CollectionUtils.isNotEmpty(planList)) {
-            for (ContentPlatformGzhPlan plan : planList) {
-                aigcApiService.closePublishPlan(plan.getExternalId());
-            }
-        }
     }
 
     @Override

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

@@ -148,6 +148,19 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         return gzhPlanVideoMapper.selectByExample(example);
     }
 
+    @Override
+    public void gzhPlanDelete(Long id) {
+        ContentPlatformGzhPlan plan = gzhPlanMapper.selectByPrimaryKey(id);
+        if (Objects.isNull(plan)) {
+            throw new CommonException(ExceptionEnum.GZH_PLAN_NOT_EXISTS);
+        }
+        plan.setStatus(0);
+        plan.setUpdateTimestamp(System.currentTimeMillis());
+        gzhPlanMapper.updateByPrimaryKeySelective(plan);
+        // 调用aigc删除发布计划
+        aigcApiService.closePublishPlan(plan.getExternalId());
+    }
+
     @Override
     public void gzhPlanSave(GzhPlanSaveParam param) {
         ContentPlatformAccount loginAccount = LoginUserContext.getUser();
@@ -275,7 +288,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
     @Override
     public List<ContentPlatformGzhPlan> getGzhPlanListByCooperateAccountId(Long accountId) {
         ContentPlatformGzhPlanExample example = new ContentPlatformGzhPlanExample();
-        example.createCriteria().andAccountIdEqualTo(accountId);
+        example.createCriteria().andAccountIdEqualTo(accountId).andStatusEqualTo(1);
         return gzhPlanMapper.selectByExample(example);
     }
 

+ 22 - 5
api-module/src/main/resources/mapper/contentplatform/ContentPlatformGzhPlanMapper.xml

@@ -7,6 +7,7 @@
     <result column="account_id" jdbcType="BIGINT" property="accountId" />
     <result column="scene" jdbcType="INTEGER" property="scene" />
     <result column="external_id" jdbcType="VARCHAR" property="externalId" />
+    <result column="status" jdbcType="INTEGER" property="status" />
     <result column="create_account_id" jdbcType="BIGINT" property="createAccountId" />
     <result column="create_timestamp" jdbcType="BIGINT" property="createTimestamp" />
     <result column="update_timestamp" jdbcType="BIGINT" property="updateTimestamp" />
@@ -70,7 +71,7 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, publish_stage, account_id, scene, external_id, create_account_id, create_timestamp, 
+    id, publish_stage, account_id, scene, external_id, `status`, create_account_id, create_timestamp, 
     update_timestamp
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlanExample" resultMap="BaseResultMap">
@@ -108,11 +109,13 @@
   </delete>
   <insert id="insert" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlan">
     insert into content_platform_gzh_plan (id, publish_stage, account_id, 
-      scene, external_id, create_account_id, 
-      create_timestamp, update_timestamp)
+      scene, external_id, `status`, 
+      create_account_id, create_timestamp, update_timestamp
+      )
     values (#{id,jdbcType=BIGINT}, #{publishStage,jdbcType=INTEGER}, #{accountId,jdbcType=BIGINT}, 
-      #{scene,jdbcType=INTEGER}, #{externalId,jdbcType=VARCHAR}, #{createAccountId,jdbcType=BIGINT}, 
-      #{createTimestamp,jdbcType=BIGINT}, #{updateTimestamp,jdbcType=BIGINT})
+      #{scene,jdbcType=INTEGER}, #{externalId,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, 
+      #{createAccountId,jdbcType=BIGINT}, #{createTimestamp,jdbcType=BIGINT}, #{updateTimestamp,jdbcType=BIGINT}
+      )
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlan">
     insert into content_platform_gzh_plan
@@ -132,6 +135,9 @@
       <if test="externalId != null">
         external_id,
       </if>
+      <if test="status != null">
+        `status`,
+      </if>
       <if test="createAccountId != null">
         create_account_id,
       </if>
@@ -158,6 +164,9 @@
       <if test="externalId != null">
         #{externalId,jdbcType=VARCHAR},
       </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
       <if test="createAccountId != null">
         #{createAccountId,jdbcType=BIGINT},
       </if>
@@ -193,6 +202,9 @@
       <if test="record.externalId != null">
         external_id = #{record.externalId,jdbcType=VARCHAR},
       </if>
+      <if test="record.status != null">
+        `status` = #{record.status,jdbcType=INTEGER},
+      </if>
       <if test="record.createAccountId != null">
         create_account_id = #{record.createAccountId,jdbcType=BIGINT},
       </if>
@@ -214,6 +226,7 @@
       account_id = #{record.accountId,jdbcType=BIGINT},
       scene = #{record.scene,jdbcType=INTEGER},
       external_id = #{record.externalId,jdbcType=VARCHAR},
+      `status` = #{record.status,jdbcType=INTEGER},
       create_account_id = #{record.createAccountId,jdbcType=BIGINT},
       create_timestamp = #{record.createTimestamp,jdbcType=BIGINT},
       update_timestamp = #{record.updateTimestamp,jdbcType=BIGINT}
@@ -236,6 +249,9 @@
       <if test="externalId != null">
         external_id = #{externalId,jdbcType=VARCHAR},
       </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=INTEGER},
+      </if>
       <if test="createAccountId != null">
         create_account_id = #{createAccountId,jdbcType=BIGINT},
       </if>
@@ -254,6 +270,7 @@
       account_id = #{accountId,jdbcType=BIGINT},
       scene = #{scene,jdbcType=INTEGER},
       external_id = #{externalId,jdbcType=VARCHAR},
+      `status` = #{status,jdbcType=INTEGER},
       create_account_id = #{createAccountId,jdbcType=BIGINT},
       create_timestamp = #{createTimestamp,jdbcType=BIGINT},
       update_timestamp = #{updateTimestamp,jdbcType=BIGINT}

+ 4 - 3
api-module/src/main/resources/mapper/contentplatform/ext/ContentPlatformPlanMapperExt.xml

@@ -13,7 +13,7 @@
     <select id="getGzhPlanCount" resultType="java.lang.Integer">
         select count(*)
         from content_platform_gzh_plan
-        where create_account_id = #{createAccountId}
+        where create_account_id = #{createAccountId} and status = 1
         <if test="param.accountId != null">
             and account_id = #{param.accountId}
         </if>
@@ -36,7 +36,7 @@
             resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlan">
         select *
         from content_platform_gzh_plan
-        where create_account_id = #{createAccountId}
+        where create_account_id = #{createAccountId} and status = 1
         <if test="param.accountId != null">
             and account_id = #{param.accountId}
         </if>
@@ -62,7 +62,7 @@
         select *
         from content_platform_gzh_plan
         where account_id = #{accountId}
-        and scene = #{scene}
+        and scene = #{scene} and status = 1
         <if test="id != null">
             and id != #{id}
         </if>
@@ -174,6 +174,7 @@
         where cpgac.gh_id = #{ghId}
           and cpgac.status = 1
           and cpgp.scene = 0
+          and cpgp.status = 1
     </select>
 
     <update id="updateVideoStatus">