Bladeren bron

fix: agent应用删除同步修改ios服务渠道表记录

hidewnd 1 week geleden
bovenliggende
commit
19b9f9060e

+ 1 - 0
yt-agent/agent-service/src/main/java/com/ytpm/service/impl/AgentAppServiceImpl.java

@@ -127,6 +127,7 @@ public class AgentAppServiceImpl implements AgentAppService {
             appMapper.insertOne(app);
             //新增APP时要生成 app_default_config
             generateDefaultConfig(param,app);
+            // ios应用同步生成渠道表
             if (param.getAppType() == 2){
                 saveDitch(app);
             }

+ 21 - 2
yt-agent/agent-service/src/main/java/com/ytpm/service/impl/AgentDitchServiceImpl.java

@@ -1,17 +1,22 @@
 package com.ytpm.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.ytpm.agent.model.YtApp;
 import com.ytpm.agent.model.YtDitch;
+import com.ytpm.agent.model.YtPlatformUserApp;
 import com.ytpm.agent.param.DitchListParam;
 import com.ytpm.agent.view.AgentDitchView;
+import com.ytpm.dao.AgentAppMapper;
 import com.ytpm.dao.AgentDitchMapper;
 import com.ytpm.dao.AppMapper;
 import com.ytpm.general.RepMessage;
 import com.ytpm.general.Result;
 import com.ytpm.general.ResultTable;
 import com.ytpm.service.AgentDitchService;
+import com.ytpm.utils.FeignClientInvoker;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -20,15 +25,18 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
 
+@Slf4j
 @Service
 public class AgentDitchServiceImpl implements AgentDitchService {
 
     @Resource
     private AgentDitchMapper agentDitchMapper;
-
     @Resource
     private AppMapper appMapper;
-
+    @Resource
+    private FeignClientInvoker feignInvoker;
+    @Resource
+    private AgentAppMapper agentAppMapper;
 
     @Override
     public ResultTable<AgentDitchView> ditchList(DitchListParam param) {
@@ -74,6 +82,17 @@ public class AgentDitchServiceImpl implements AgentDitchService {
             List<String> ids = Collections.singletonList(ytApp.getAppId());
             appMapper.deleteAppIds(ids);
             appMapper.deleteRisks(ids);
+            // ios应用 feign调用更新子库 记录
+            if (ytApp.getAppType() == 2 && StrUtil.isNotEmpty(ytApp.getSuperiorId())) {
+                try {
+                    YtPlatformUserApp superior = agentAppMapper.selectByPrimaryKey(ytApp.getSuperiorId());
+                    if (superior != null) {
+                        feignInvoker.invoke(superior.getServiceName(), "delDitchByAppId", ytApp.getAppId());
+                    }
+                }catch (Exception ignored){
+                    log.error("同步 ditch删除失败, appId:{}", ytApp.getAppId());
+                }
+            }
         }
         return Result.resultOk(RepMessage.DELETE_SUCCESS);
     }

+ 4 - 0
yt-ios-lemon/lemon-ios-feign/src/main/java/com/ytpm/lemonios/feign/base/BaseFeign.java

@@ -19,6 +19,7 @@ import com.ytpm.general.ResultTable;
 import com.ytpm.middle.view.DashboardRankingListVO;
 import com.ytpm.middle.view.DashboardRevenueVO;
 import com.ytpm.middle.view.DashboardRiskVO;
+import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -94,6 +95,9 @@ public interface BaseFeign {
     @PostMapping("/ditch/addDitch")
     Result<?> addDitch(@RequestBody YtApp app);
 
+    @DeleteMapping("/ditch/delDitch")
+    Result<?> delDitchByAppId(@RequestParam(name = "appId") String appId);
+
     @PostMapping("/user/queryTodayBanned")
     List<YtDyzUser> queryTodayBanned(@RequestBody AppUserTodayBannedParam appUserTodayBannedParam);
 

+ 16 - 4
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/controller/DitchController.java

@@ -1,9 +1,8 @@
 package com.ytpm.lemonios.controller;
 
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageInfo;
 import com.ytpm.agent.model.YtApp;
-import com.ytpm.agent.model.YtDitch;
-import com.ytpm.agent.param.AppParam;
 import com.ytpm.agent.param.DitchListForIosParam;
 import com.ytpm.agent.param.DitchListParam;
 import com.ytpm.agent.view.AgentDitchView;
@@ -13,10 +12,14 @@ import com.ytpm.general.ResultTable;
 import com.ytpm.lemonios.service.DitchService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
-import java.util.Date;
 import java.util.List;
 
 @Api(tags = "渠道类型管理模块")
@@ -57,4 +60,13 @@ public class DitchController {
     public Result<?> add(@RequestBody YtApp app) {
         return Result.resultOk(RepMessage.SAVE_SUCCESS, agentDitchService.save(app));
     }
+
+    @ApiOperation("删除渠道")
+    @DeleteMapping("/delDitch")
+    public Result<?> delDitch(@RequestParam(name = "appId") String appId) {
+        if (StrUtil.isNotEmpty(appId)) {
+            agentDitchService.deleteByAppId(appId);
+        }
+        return Result.resultOk(RepMessage.SAVE_SUCCESS);
+    }
 }

+ 2 - 0
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/controller/WxController.java

@@ -375,6 +375,8 @@ public class WxController {
         List<WxDefaultConfig> dyzConfig = appUserMapper.getConfigByIds(appId);
         if(CollUtil.isNotEmpty(dyzConfig)){
             appUserMapper.delByAppId(appId);
+            // 同步删除渠道记录
+            ditchMapper.deleteByAppId(appId);
         }
     }
 }

+ 5 - 0
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/dao/DitchMapper.java

@@ -15,4 +15,9 @@ public interface DitchMapper {
     Integer insertOne(YtDitch ytDitch);
 
     YtDitch selectById(@Param("ditchId") Long ditchId);
+
+    /**
+     * 逻辑删除渠道记录
+     */
+    void deleteByAppId(@Param("appId") String appId);
 }

+ 3 - 2
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/service/DitchService.java

@@ -1,8 +1,6 @@
 package com.ytpm.lemonios.service;
 
 import com.ytpm.agent.model.YtApp;
-import com.ytpm.agent.model.YtDitch;
-import com.ytpm.agent.param.AppParam;
 import com.ytpm.agent.param.DitchListParam;
 import com.ytpm.agent.view.AgentDitchView;
 
@@ -23,4 +21,7 @@ public interface DitchService {
      * @return
      */
     Integer save(YtApp app);
+
+
+    void deleteByAppId(String appId);
 }

+ 6 - 0
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/service/impl/DitchServiceImpl.java

@@ -37,4 +37,10 @@ public class DitchServiceImpl implements DitchService {
         ytDitch.setCreateTime(new Date());
         return agentDitchMapper.insertOne(ytDitch);
     }
+
+    @Override
+    public void deleteByAppId(String appId) {
+        // 逻辑删除
+        agentDitchMapper.deleteByAppId(appId);
+    }
 }

+ 3 - 3
yt-ios-lemon/lemon-ios-service/src/main/resources/bootstrap.yml

@@ -4,8 +4,8 @@ spring:
   main:
     allow-bean-definition-overriding: true
   application:
-    name: gollumios-service
-    name-zh: '咕噜记账IOS'
+    name: lemonios-service
+    name-zh: '青柠檬IOS'
   profiles:
     active: local
 yt:
@@ -14,7 +14,7 @@ yt:
   # 本地环境
   local:
     addr: 127.0.0.1
-    namespace: 059740b0-1325-454c-8d86-5208d036caba
+    namespace: 1aff43c9-b617-4d0b-8c3a-9d8b44a8beae
   # 测试环境
   dev:
     addr: 127.0.0.1

+ 8 - 7
yt-ios-lemon/lemon-ios-service/src/main/resources/mapper/DitchMapper.xml

@@ -23,14 +23,15 @@
                 #{createTime}
             )
     </insert>
+    <delete id="deleteByAppId">
+        update yt_ditch set is_delete = 1 where app_id = #{appId}
+    </delete>
     <select id="ditchList" resultType="com.ytpm.agent.view.AgentDitchView">
-        select
-        ditch_id, ditch_name, create_time
+        select ditch_id,
+               ditch_name,
+               create_time
         from yt_ditch
-        <where>
-            user_id = #{userId}
-            and is_delete=0
-        </where>
+        where user_id = #{userId} and is_delete = 0
     </select>
     <select id="ditchListForIos" resultType="com.ytpm.agent.view.AgentDitchView">
         select
@@ -47,6 +48,6 @@
         select
             ditch_id, ditch_name, user_id, app_id, app_type, is_delete, create_time
         from yt_ditch
-        where ditch_id = #{ditchId}
+        where is_delete = 0 and ditch_id = #{ditchId}
     </select>
 </mapper>