Selaa lähdekoodia

1、加盟商系统增加应用管理模块各项接口
2、加盟商系统增加渠道管理模块各项接口

marxjaw 5 kuukautta sitten
vanhempi
commit
810cfeb92d
25 muutettua tiedostoa jossa 413 lisäystä ja 104 poistoa
  1. 8 2
      yt-advertise/advertise-feign/src/main/java/com/ytpm/feign/AdvertiseFeign.java
  2. 15 4
      yt-advertise/advertise-service/src/main/java/com/ytpm/controller/AdvertiseController.java
  3. 12 8
      yt-advertise/advertise-service/src/main/java/com/ytpm/service/TakuApiService.java
  4. 28 16
      yt-advertise/advertise-service/src/main/java/com/ytpm/service/impl/TakuApiServiceImpl.java
  5. 4 2
      yt-agent/agent-service/src/main/java/com/ytpm/controller/AgentChannelController.java
  6. 33 14
      yt-agent/agent-service/src/main/java/com/ytpm/controller/AppController.java
  7. 4 3
      yt-agent/agent-service/src/main/java/com/ytpm/dao/AgentAppMapper.java
  8. 16 0
      yt-agent/agent-service/src/main/java/com/ytpm/dao/AppMapper.java
  9. 13 8
      yt-agent/agent-service/src/main/java/com/ytpm/service/AgentAppService.java
  10. 2 1
      yt-agent/agent-service/src/main/java/com/ytpm/service/ChannelService.java
  11. 64 36
      yt-agent/agent-service/src/main/java/com/ytpm/service/impl/AgentAppServiceImpl.java
  12. 6 1
      yt-agent/agent-service/src/main/java/com/ytpm/service/impl/ChannelServiceImpl.java
  13. 21 3
      yt-agent/agent-service/src/main/resources/mapper/AgentAppMapper.xml
  14. 44 2
      yt-agent/agent-service/src/main/resources/mapper/AppMapper.xml
  15. 1 1
      yt-agent/agent-service/src/main/resources/mapper/ChannelMapper.xml
  16. 16 0
      yt-common/src/main/java/com/ytpm/advertise/param/AddAppParam.java
  17. 23 0
      yt-common/src/main/java/com/ytpm/advertise/param/RelativeChannelParam.java
  18. 2 2
      yt-common/src/main/java/com/ytpm/agent/model/YtApp.java
  19. 18 0
      yt-common/src/main/java/com/ytpm/agent/param/AppListParam.java
  20. 25 1
      yt-common/src/main/java/com/ytpm/agent/param/AppParam.java
  21. 19 0
      yt-common/src/main/java/com/ytpm/agent/param/ChannelListParam.java
  22. 2 0
      yt-common/src/main/java/com/ytpm/agent/param/ChannelParam.java
  23. 34 0
      yt-common/src/main/java/com/ytpm/agent/view/AgentAppView.java
  24. 2 0
      yt-common/src/main/java/com/ytpm/agent/view/AgentChannelView.java
  25. 1 0
      yt-common/src/main/java/com/ytpm/general/RepMessage.java

+ 8 - 2
yt-advertise/advertise-feign/src/main/java/com/ytpm/feign/AdvertiseFeign.java

@@ -1,14 +1,20 @@
 package com.ytpm.feign;
 
 import com.ytpm.advertise.param.AddAppParam;
+import com.ytpm.advertise.param.RelativeChannelParam;
 import com.ytpm.advertise.view.AddAppResponse;
 import com.ytpm.general.Result;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 
 @FeignClient(name = "advertise-service")
 public interface AdvertiseFeign {
-    @PostMapping("/advertise/addApp")
-    Result<AddAppResponse> addApp(@RequestBody AddAppParam param);
+    @PostMapping("/advertise/saveApp")
+    Result<AddAppResponse> saveApp(@RequestBody AddAppParam param);
+    @PostMapping("/advertise/delApp")
+    Result<?> delApp(@Param("appId") String appId);
+    @PostMapping("/advertise/relativePlatform")
+    Result<?> relativePlatform(@RequestBody RelativeChannelParam channelParam);
 }

+ 15 - 4
yt-advertise/advertise-service/src/main/java/com/ytpm/controller/AdvertiseController.java

@@ -1,6 +1,7 @@
 package com.ytpm.controller;
 
 import com.ytpm.advertise.param.AddAppParam;
+import com.ytpm.advertise.param.RelativeChannelParam;
 import com.ytpm.advertise.view.AddAppResponse;
 import com.ytpm.advertise.view.AppV1View;
 import com.ytpm.agent.param.ChannelParam;
@@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.GetMapping;
 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;
 
 @Api("Taku广告聚合管理模块")
@@ -29,7 +31,7 @@ public class AdvertiseController {
      */
     @ApiOperation("Taku应用关联广告平台")
     @PostMapping("/relativePlatform")
-    public Result<?> relativePlatform(@RequestBody ChannelParam channelParam) {
+    public Result<?> relativePlatform(@RequestBody RelativeChannelParam channelParam) {
         return takuApiService.relativePlatform(channelParam);
     }
 
@@ -46,8 +48,17 @@ public class AdvertiseController {
      * 新增应用
      */
     @ApiOperation("新增应用")
-    @PostMapping("/addApp")
-    public Result<AddAppResponse> addApp(@RequestBody AddAppParam param) {
-        return takuApiService.addApps(param);
+    @PostMapping("/saveApp")
+    public Result<AddAppResponse> saveApp(@RequestBody AddAppParam param) {
+        return takuApiService.saveApp(param);
+    }
+
+    /**
+     * 删除应用
+     */
+    @ApiOperation("删除应用")
+    @GetMapping("/delApp")
+    public Result<AddAppResponse> delApp(@RequestParam("appId")String appId) {
+        return takuApiService.delApp(appId);
     }
 }

+ 12 - 8
yt-advertise/advertise-service/src/main/java/com/ytpm/service/TakuApiService.java

@@ -2,6 +2,7 @@ package com.ytpm.service;
 
 import com.ytpm.advertise.param.AddPlacementParam;
 import com.ytpm.advertise.param.Network;
+import com.ytpm.advertise.param.RelativeChannelParam;
 import com.ytpm.advertise.param.UnitsListParam;
 import com.ytpm.advertise.param.UnitsParam;
 import com.ytpm.advertise.view.AddAppResponse;
@@ -18,22 +19,25 @@ import java.util.List;
 
 public interface TakuApiService {
     /**
-     * 新增应用
+     * 保存应用
      */
-    Result<AddAppResponse> addApps(AddAppParam param);
+    Result<AddAppResponse> saveApp(AddAppParam param);
+    /**
+     * 查询应用列表
+     */
+    ResultTable<AppV1View> getAppList();
+    /**
+     * 删除应用
+     */
+    Result<AddAppResponse> delApp(String appId);
     /**
      * Taku应用关联广告平台
      */
-    Result<?> relativePlatform(ChannelParam channelParam);
+    Result<?> relativePlatform(RelativeChannelParam channelParam);
     /**
      * 获取广告平台信息
      */
     ResultTable<Network> getNetworks();
-
-    /**
-     * 查询应用列表
-     */
-    ResultTable<AppV1View> getAppList();
     /**
      * 新增广告位
      */

+ 28 - 16
yt-advertise/advertise-service/src/main/java/com/ytpm/service/impl/TakuApiServiceImpl.java

@@ -9,6 +9,7 @@ import com.ytpm.advertise.param.AppAuthContent;
 import com.ytpm.advertise.param.AuthContent;
 import com.ytpm.advertise.param.Network;
 import com.ytpm.advertise.param.NetworkAppInfo;
+import com.ytpm.advertise.param.RelativeChannelParam;
 import com.ytpm.advertise.param.UnitsListParam;
 import com.ytpm.advertise.param.UnitsParam;
 import com.ytpm.advertise.view.AddAppResponse;
@@ -44,7 +45,7 @@ public class TakuApiServiceImpl implements TakuApiService {
      * 新增或修改应用
      */
     @Override
-    public Result<AddAppResponse> addApps(AddAppParam param) {
+    public Result<AddAppResponse> saveApp(AddAppParam param) {
         //API支持多个添加,我们这里只添加一个
         JSONObject object = new JSONObject();
         object.put("items",Collections.singletonList(param));
@@ -54,25 +55,46 @@ public class TakuApiServiceImpl implements TakuApiService {
         return Result.resultOk(RepMessage.SAVE_SUCCESS,response);
     }
 
+    /**
+     * 查询应用列表
+     */
+    @Override
+    public ResultTable<AppV1View> getAppList() {
+        String res = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V1+"/apps", null);
+        List<AppV1View> v1View = JSONArray.parseArray(res, AppV1View.class);
+        return ResultTable.resultTableOk(new PageInfo<>(v1View));
+    }
+
+    /**
+     * 删除应用
+     */
+    @Override
+    public Result<AddAppResponse> delApp(String appId) {
+        JSONObject object = new JSONObject();
+        object.put("app_ids",Collections.singletonList(appId));
+        TakuRequestUtil.doRequest(HttpPost.METHOD_NAME, API_VERSION_V1+"/del_apps", object.toJSONString());
+        return Result.resultOk(RepMessage.DELETE_SUCCESS);
+    }
+
     /**
      * Taku应用关联广告平台
      */
     @Override
-    public Result<?> relativePlatform(ChannelParam channelParam) {
+    public Result<?> relativePlatform(RelativeChannelParam channelParam) {
         Network network = new Network();
         network.setNw_firm_id(channelParam.getAdPlatformType());
         network.setIs_open_report(OpenReportEnum.TRUE.getCode());
         //设置广告平台API认证信息  目前只有优量汇
         AuthContent authContent = new AuthContent();
-        authContent.setAccount_id("902040320340");
-        authContent.setSecret_key("vSMkNOUWea13A>MN=1J0F0N&jb984kv9");
+        authContent.setAccount_id(channelParam.getChannelAccount());
+        authContent.setSecret_key(channelParam.getApiSecret());
         network.setAuth_content(authContent);
         //设置Taku应用ID
         NetworkAppInfo networkAppInfo = new NetworkAppInfo();
-        networkAppInfo.setApp_id("a1ghj1ek3bd7kp");
+        networkAppInfo.setApp_id(channelParam.getAppId());
         //设置广告平台应用信息
         AppAuthContent appAuthContent = new AppAuthContent();
-        appAuthContent.setApp_id("1210935703");
+        appAuthContent.setApp_id(channelParam.getNetworkAppId());
         networkAppInfo.setApp_auth_content(appAuthContent);
         network.setNetwork_app_info(Collections.singletonList(networkAppInfo));
         String res = TakuRequestUtil.doRequest(HttpPost.METHOD_NAME, API_VERSION_V1+"/set_networks", JSONObject.toJSONString(network));
@@ -90,16 +112,6 @@ public class TakuApiServiceImpl implements TakuApiService {
         return ResultTable.resultTableOk(new PageInfo<>(JSON.parseArray(res, Network.class)));
     }
 
-    /**
-     * 查询应用列表
-     */
-    @Override
-    public ResultTable<AppV1View> getAppList() {
-        String res = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V1+"/apps", null);
-        List<AppV1View> v1View = JSONArray.parseArray(res, AppV1View.class);
-        return ResultTable.resultTableOk(new PageInfo<>(v1View));
-    }
-
     /**
      * 新增或修改广告位
      */

+ 4 - 2
yt-agent/agent-service/src/main/java/com/ytpm/controller/AgentChannelController.java

@@ -1,5 +1,6 @@
 package com.ytpm.controller;
 
+import com.ytpm.agent.param.ChannelListParam;
 import com.ytpm.agent.param.ChannelParam;
 import com.ytpm.agent.view.AgentChannelView;
 import com.ytpm.general.Result;
@@ -9,6 +10,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.GetMapping;
 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;
@@ -28,8 +30,8 @@ public class AgentChannelController {
      */
     @ApiOperation("获取广告渠道列表")
     @PostMapping("/list")
-    public ResultTable<AgentChannelView> list(){
-        return channelService.channelList();
+    public ResultTable<AgentChannelView> list(@RequestBody ChannelListParam param) {
+        return channelService.channelList(param);
     }
 
     /**

+ 33 - 14
yt-agent/agent-service/src/main/java/com/ytpm/controller/AppController.java

@@ -1,17 +1,17 @@
 package com.ytpm.controller;
 
-import com.ytpm.advertise.param.AddAppParam;
+import com.ytpm.advertise.param.RelativeChannelParam;
+import com.ytpm.agent.param.AppListParam;
 import com.ytpm.agent.param.AppParam;
-import com.ytpm.agent.param.ChannelParam;
+import com.ytpm.agent.view.AgentAppView;
 import com.ytpm.agent.view.AgentEnableAppView;
 import com.ytpm.agent.view.AgentUserInfo;
-import com.ytpm.app.view.YtAppListView;
 import com.ytpm.general.Result;
 import com.ytpm.general.ResultTable;
 import com.ytpm.service.AgentAppService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.checkerframework.checker.units.qual.A;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.security.core.annotation.AuthenticationPrincipal;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -40,20 +40,39 @@ public class AppController {
     }
 
     /**
-     * 新增应用
+     * 查询应用列表
      */
-    @ApiOperation("新增应用")
-    @PostMapping("/addApp")
-    public Result<?> addApp(@RequestBody AppParam param, @ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo) {
-        return agentAppService.addApp(param,userInfo.getUserId());
+    @ApiOperation("查询应用列表")
+    @PostMapping("/searchApps")
+    public ResultTable<AgentAppView> searchAll(@RequestBody AppListParam appListParam, @ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo) {
+        appListParam.setUserId(userInfo.getUserId());
+        return agentAppService.searchAppList(appListParam);
     }
 
     /**
-     * 新增广告渠道
+     * 保存应用
      */
-    @ApiOperation("新增广告渠道")
-    @PostMapping("/addChannel")
-    public Result<?> addChannel(@RequestBody ChannelParam param, @ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo) {
-        return agentAppService.addChannel(param,userInfo.getUserId());
+    @ApiOperation("保存应用,新增修改共用")
+    @PostMapping("/saveApp")
+    public Result<?> saveApp(@RequestBody AppParam param, @ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo) {
+        return agentAppService.saveApp(param,userInfo.getUserId());
+    }
+
+    /**
+     * 删除应用
+     */
+    @ApiOperation("删除应用")
+    @GetMapping("/delApp")
+    public Result<?> delApp(@ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo, @Param("appId")String appId) {
+        return agentAppService.delApp(appId,userInfo.getUserId());
+    }
+
+    /**
+     * 应用关联广告平台 & 广告平台应用
+     */
+    @ApiOperation("应用关联广告平台 & 广告平台应用")
+    @PostMapping("/relativeChannel")
+    public Result<?> relativeChannel(@RequestBody RelativeChannelParam param){
+        return agentAppService.relativeChannel(param);
     }
 }

+ 4 - 3
yt-agent/agent-service/src/main/java/com/ytpm/dao/AgentAppMapper.java

@@ -1,7 +1,8 @@
 package com.ytpm.dao;
 
+import com.ytpm.agent.param.AppListParam;
+import com.ytpm.agent.view.AgentAppView;
 import com.ytpm.agent.view.AgentEnableAppView;
-import com.ytpm.app.view.YtAppListView;
 import org.apache.ibatis.annotations.Param;
 import org.mapstruct.Mapper;
 
@@ -15,7 +16,7 @@ public interface AgentAppMapper {
     List<AgentEnableAppView> getEnabledList(@Param("userId") String userId);
 
     /**
-     *
+     * 查询应用列表
      */
-    List<YtAppListView> searchAppList();
+    List<AgentAppView> searchAppList(AppListParam appListParam);
 }

+ 16 - 0
yt-agent/agent-service/src/main/java/com/ytpm/dao/AppMapper.java

@@ -2,6 +2,7 @@ package com.ytpm.dao;
 
 import com.ytpm.agent.model.YtApp;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 @Mapper
 public interface AppMapper {
@@ -9,4 +10,19 @@ public interface AppMapper {
      * 新增应用信息
      */
     void insertOne(YtApp app);
+
+    /**
+     * 主键查询
+     */
+    YtApp selectPrimary(@Param("appId") String appId);
+
+    /**
+     * 保存应用
+     */
+    void updateOne(YtApp app);
+
+    /**
+     * 删除应用
+     */
+    void deleteApp(String appId);
 }

+ 13 - 8
yt-agent/agent-service/src/main/java/com/ytpm/service/AgentAppService.java

@@ -1,10 +1,10 @@
 package com.ytpm.service;
 
-import com.ytpm.advertise.param.AddAppParam;
+import com.ytpm.advertise.param.RelativeChannelParam;
+import com.ytpm.agent.param.AppListParam;
 import com.ytpm.agent.param.AppParam;
-import com.ytpm.agent.param.ChannelParam;
+import com.ytpm.agent.view.AgentAppView;
 import com.ytpm.agent.view.AgentEnableAppView;
-import com.ytpm.app.view.YtAppListView;
 import com.ytpm.general.Result;
 import com.ytpm.general.ResultTable;
 
@@ -17,15 +17,20 @@ public interface AgentAppService {
     /**
      * 查询应用列表
      */
-    ResultTable<YtAppListView> searchAppList();
+    ResultTable<AgentAppView> searchAppList(AppListParam appListParam);
 
     /**
-     * 新增应用
+     * 保存应用
      */
-    Result<?> addApp(AppParam param, String userId);
+    Result<?> saveApp(AppParam param, String userId);
 
     /**
-     * 新增广告渠道
+     * 删除应用
      */
-    Result<?> addChannel(ChannelParam param, String userId);
+    Result<?> delApp(String appId, String userId);
+
+    /**
+     * 应用关联广告平台 & 广告平台应用
+     */
+    Result<?> relativeChannel(RelativeChannelParam param);
 }

+ 2 - 1
yt-agent/agent-service/src/main/java/com/ytpm/service/ChannelService.java

@@ -1,5 +1,6 @@
 package com.ytpm.service;
 
+import com.ytpm.agent.param.ChannelListParam;
 import com.ytpm.agent.param.ChannelParam;
 import com.ytpm.agent.view.AgentChannelView;
 import com.ytpm.general.Result;
@@ -9,7 +10,7 @@ public interface ChannelService {
     /**
      * 获取渠道商列表
      */
-    ResultTable<AgentChannelView> channelList();
+    ResultTable<AgentChannelView> channelList(ChannelListParam param);
 
     /**
      * 新增广告渠道

+ 64 - 36
yt-agent/agent-service/src/main/java/com/ytpm/service/impl/AgentAppServiceImpl.java

@@ -1,29 +1,29 @@
 package com.ytpm.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.StrUtil;
+import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import com.ytpm.advertise.enums.AdPlatformTypeEnum;
 import com.ytpm.advertise.param.AddAppParam;
+import com.ytpm.advertise.param.RelativeChannelParam;
 import com.ytpm.advertise.view.AddAppResponse;
 import com.ytpm.agent.model.YtApp;
-import com.ytpm.agent.model.YtChannel;
+import com.ytpm.agent.param.AppListParam;
 import com.ytpm.agent.param.AppParam;
-import com.ytpm.agent.param.ChannelParam;
+import com.ytpm.agent.view.AgentAppView;
 import com.ytpm.agent.view.AgentEnableAppView;
-import com.ytpm.app.view.YtAppListView;
 import com.ytpm.dao.AgentAppMapper;
 import com.ytpm.dao.AppMapper;
-import com.ytpm.dao.ChannelMapper;
 import com.ytpm.feign.AdvertiseFeign;
 import com.ytpm.general.RepMessage;
 import com.ytpm.general.Result;
 import com.ytpm.general.ResultTable;
 import com.ytpm.service.AgentAppService;
-import org.checkerframework.checker.units.qual.A;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.Objects;
+
 
 @Service
 public class AgentAppServiceImpl implements AgentAppService {
@@ -34,8 +34,6 @@ public class AgentAppServiceImpl implements AgentAppService {
     private AdvertiseFeign advertiseFeign;
     @Resource
     private AppMapper appMapper;
-    @Resource
-    private ChannelMapper channelMapper;
 
     /**
      * 查询渠道启用的应用列表
@@ -50,45 +48,75 @@ public class AgentAppServiceImpl implements AgentAppService {
      * 查询应用列表
      */
     @Override
-    public ResultTable<YtAppListView> searchAppList() {
-        return ResultTable.resultTableOk(new PageInfo<>(agentAppMapper.searchAppList()));
+    public ResultTable<AgentAppView> searchAppList(AppListParam appListParam) {
+        PageHelper.startPage(appListParam.getPage(), appListParam.getLimit());
+        return ResultTable.resultTableOk(new PageInfo<>(agentAppMapper.searchAppList(appListParam)));
     }
 
     /**
      * 新增应用
      */
     @Override
-    public Result<?> addApp(AppParam param, String userId) {
+    public Result<?> saveApp(AppParam param, String userId) {
+        //构造API对象
+        AddAppParam addAppParam = new AddAppParam(param);
         //调用广告平台API 增加应用
-        Result<AddAppResponse> result = advertiseFeign.addApp(param);
-        //数据库存储应用信息
-        AddAppResponse data = result.getData();
+        Result<AddAppResponse> result = advertiseFeign.saveApp(addAppParam);
+        //数据库操作,有appId为修改, 没有时为新增
+        changeDataAction(param,result,userId);
+        return Result.resultOk(RepMessage.SAVE_SUCCESS);
+    }
+
+    /**
+     * 处理数据库数据变更操作
+     */
+    private void changeDataAction(AppParam param, Result<AddAppResponse> result, String userId) {
         YtApp app = new YtApp();
-        app.setAppId(data.getUuid());
-        app.setAppKey(data.getApp_key());
-        app.setAppName(param.getName());
-        app.setAppType(param.getPlatform());
-        app.setUserId(userId);
-        app.setEnabled(1);
-        app.setApkUrl(param.getApkUrl());
-        app.setQrCode(param.getQrCode());
-        app.setVersionCode(param.getVersionCode());
-        app.setUpdateTips(param.getUpdateTips());
-        //前端上传apk后返回链接,链接生成二维码图片后上传返回二维码链接
-        appMapper.insertOne(app);
-        return Result.resultOk(RepMessage.ADD_SUCCESS);
+        BeanUtil.copyProperties(param, app);
+        if(StrUtil.isNotBlank(param.getAppId())){
+            appMapper.updateOne(app);
+        }else{
+            AddAppResponse data = result.getData();
+            BeanUtil.copyProperties(param, app);
+            app.setAppId(data.getUuid());
+            app.setAppKey(data.getApp_key());
+            app.setUserId(userId);
+            app.setEnabled(1);
+            appMapper.insertOne(app);
+        }
     }
 
     /**
-     * 新增广告渠道
+     * 删除应用
      */
     @Override
-    public Result<?> addChannel(ChannelParam param, String userId) {
-        YtChannel channel = new YtChannel();
-        BeanUtil.copyProperties(param, channel);
-        channel.setChannelId(IdUtil.fastSimpleUUID());
-        channel.setChannelName(AdPlatformTypeEnum.getDesc(param.getAdPlatformType()));
-        channelMapper.insert(channel);
-        return Result.resultOk(RepMessage.ADD_SUCCESS);
+    public Result<?> delApp(String appId, String userId) {
+        YtApp ytApp = appMapper.selectPrimary(appId);
+        if(Objects.isNull(ytApp)|| !userId.equals(ytApp.getUserId())){
+            Result.resultErr(RepMessage.NOT_PERMIT);
+        }
+        advertiseFeign.delApp(appId);
+        appMapper.deleteApp(appId);
+        return Result.resultOk(RepMessage.DELETE_SUCCESS);
+    }
+
+    /**
+     * 应用关联广告平台 & 广告平台应用
+     */
+    @Override
+    public Result<?> relativeChannel(RelativeChannelParam param) {
+        //根据应用ID查询应用信息
+        YtApp ytApp = appMapper.selectPrimary(param.getAppId());
+        if(Objects.isNull(ytApp)){
+            Result.resultErr(RepMessage.OBJECT_NOT_EXIST);
+        }
+        advertiseFeign.relativePlatform(param);
+        YtApp app = new YtApp();
+        app.setAppId(param.getAppId());
+        app.setChannelId(param.getChannelId());
+        app.setChannelName(param.getChannelName());
+        app.setNetworkAppId(param.getNetworkAppId());
+        appMapper.updateOne(app);
+        return Result.resultOk(RepMessage.RELATIVE_SUCCESS);
     }
 }

+ 6 - 1
yt-agent/agent-service/src/main/java/com/ytpm/service/impl/ChannelServiceImpl.java

@@ -1,8 +1,11 @@
 package com.ytpm.service.impl;
 
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.ytpm.advertise.enums.AdPlatformTypeEnum;
 import com.ytpm.agent.model.YtChannel;
+import com.ytpm.agent.param.ChannelListParam;
 import com.ytpm.agent.param.ChannelParam;
 import com.ytpm.agent.view.AgentChannelView;
 import com.ytpm.dao.ChannelMapper;
@@ -25,7 +28,8 @@ public class ChannelServiceImpl implements ChannelService {
      * 获取渠道商列表
      */
     @Override
-    public ResultTable<AgentChannelView> channelList() {
+    public ResultTable<AgentChannelView> channelList(ChannelListParam param) {
+        PageHelper.startPage(param.getPage(), param.getLimit());
         return ResultTable.resultTableOk(new PageInfo<AgentChannelView>(channelMapper.channelList()));
     }
 
@@ -38,6 +42,7 @@ public class ChannelServiceImpl implements ChannelService {
         BeanUtils.copyProperties(param, channel);
         channel.setChannelId(IdWorker.get32UUID());
         channel.setEnabled(1);
+        channel.setChannelName(AdPlatformTypeEnum.getDesc(param.getAdPlatformType()));
         channelMapper.insert(channel);
         return Result.resultOk(RepMessage.SAVE_SUCCESS);
     }

+ 21 - 3
yt-agent/agent-service/src/main/resources/mapper/AgentAppMapper.xml

@@ -9,7 +9,7 @@
             ya.user_id,
             ya.channel_id,
             ya.app_type,
-            ya.parent_id,
+            ya.network_app_id,
             ya.apk_url,
             ya.qr_code,
             ya.version_code,
@@ -24,7 +24,25 @@
             ya.enabled = 1
           AND ya.user_id = #{userId}
     </select>
-    <select id="searchAppList" resultType="com.ytpm.app.view.YtAppListView">
-
+    <select id="searchAppList" resultType="com.ytpm.agent.view.AgentAppView">
+        SELECT
+            ya.app_id,
+            ya.app_key,
+            ya.app_name,
+            ya.user_id,
+            ya.channel_id,
+            ya.app_type,
+            ya.network_app_id,
+            ya.apk_url,
+            ya.qr_code,
+            ya.version_code,
+            ya.update_tips,
+            yc.channel_name,
+            ya.enabled
+        FROM
+            yt_app ya
+                LEFT JOIN yt_channel yc ON ya.channel_id = yc.channel_id
+        WHERE
+            ya.user_id = #{userId}
     </select>
 </mapper>

+ 44 - 2
yt-agent/agent-service/src/main/resources/mapper/AppMapper.xml

@@ -12,7 +12,7 @@
          channel_name,
          user_id,
          app_type,
-         parent_id,
+         network_app_id,
          apk_url,
          qr_code,
          version_code,
@@ -27,11 +27,53 @@
          #{channelName},
          #{userId},
          #{appType},
-         #{parentId},
+         #{networkAppId},
          #{apkUrl},
          #{qrCode},
          #{versionCode},
          #{updateTips}
         )
     </insert>
+    <update id="updateOne">
+        update yt_app
+        <set>
+            <if test="appKey != null">
+                app_key = #{appKey},
+            </if>
+            <if test="appName != null">
+                app_name = #{appName},
+            </if>
+            <if test="channelId != null">
+                channel_id = #{channelId},
+            </if>
+            <if test="channelName != null">
+                channel_name = #{channelName},
+            </if>
+            <if test="appType != null">
+                app_type = #{appType},
+            </if>
+            <if test="networkAppId != null">
+                network_app_id = #{networkAppId},
+            </if>
+            <if test="versionCode != null">
+                version_code = #{versionCode},
+            </if>
+            <if test="updateTips != null">
+                update_tips = #{updateTips},
+            </if>
+            <if test="enabled != null">
+                enabled = #{enabled}
+            </if>
+        </set>
+        where app_id = #{appId}
+    </update>
+    <delete id="deleteApp">
+        delete from yt_app where app_id = #{appId}
+    </delete>
+    <select id="selectPrimary" resultType="com.ytpm.agent.model.YtApp">
+        select
+            app_id, app_key, app_name, channel_id, channel_name, user_id, app_type, network_app_id, apk_url, qr_code, version_code, update_tips, enabled
+        from yt_app
+        where app_id = #{appId}
+    </select>
 </mapper>

+ 1 - 1
yt-agent/agent-service/src/main/resources/mapper/ChannelMapper.xml

@@ -51,7 +51,7 @@
 
     <select id="channelList" resultType="com.ytpm.agent.view.AgentChannelView">
         select
-            channel_id, channel_name, login_type, channel_account, channel_pwd, channel_status, api_key, api_secret, remark
+            channel_id, channel_name, login_type, channel_account, channel_pwd, channel_status, api_key, api_secret, remark, enabled
         from yt_channel
         where enabled = 1
     </select>

+ 16 - 0
yt-common/src/main/java/com/ytpm/advertise/param/AddAppParam.java

@@ -1,5 +1,6 @@
 package com.ytpm.advertise.param;
 
+import com.ytpm.agent.param.AppParam;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -29,4 +30,19 @@ public class AddAppParam {
     private Integer ccpa;
     @ApiModelProperty(value = "应用ID",required = false, notes = "修改时传新增时不传")
     private String uuid;
+
+    public AddAppParam(AppParam param) {
+        this.platform = param.getAppType();
+        this.name = param.getAppName();
+        this.store_on_sale = param.getStore_on_sale();
+        this.store_type = param.getStore_type();
+        this.store_url = param.getStore_url();
+        this.package_name = param.getPackage_name();
+        this.category = param.getCategory();
+        this.sub_category = param.getSub_category();
+        this.screen_orientation = param.getScreen_orientation();
+        this.coppa = param.getCoppa();
+        this.ccpa = param.getCcpa();
+        this.uuid = param.getAppId();
+    }
 }

+ 23 - 0
yt-common/src/main/java/com/ytpm/advertise/param/RelativeChannelParam.java

@@ -0,0 +1,23 @@
+package com.ytpm.advertise.param;
+
+import com.ytpm.agent.param.ChannelParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("关联广告平台入参")
+public class RelativeChannelParam extends ChannelParam {
+    /** 测试应用 a1ghj1ek3bd7kp 天王盖地虎 */
+    @ApiModelProperty("应用ID(Taku)")
+    private String appId;
+    /** 测试应用 优量汇 好运答题王 */
+    @ApiModelProperty("绑定的广告平台应用ID")
+    private String networkAppId;
+}

+ 2 - 2
yt-common/src/main/java/com/ytpm/agent/model/YtApp.java

@@ -18,8 +18,8 @@ public class YtApp {
     private String userId;
     /** 应用类型 1-Android 2-IOS */
     private Integer appType;
-    /** 父级应用包ID */
-    private String parentId;
+    /** 广告渠道应用ID */
+    private String networkAppId;
     /** 安装包链接 */
     private String apkUrl;
     /** 二维码 */

+ 18 - 0
yt-common/src/main/java/com/ytpm/agent/param/AppListParam.java

@@ -0,0 +1,18 @@
+package com.ytpm.agent.param;
+
+import com.ytpm.general.PageMeta;
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("应用列表入参")
+public class AppListParam extends PageMeta {
+    private String appName;
+    private String userId;
+}

+ 25 - 1
yt-common/src/main/java/com/ytpm/agent/param/AppParam.java

@@ -13,7 +13,31 @@ import lombok.NoArgsConstructor;
 @NoArgsConstructor
 @AllArgsConstructor
 @ApiModel("新增应用参数")
-public class AppParam extends AddAppParam {
+public class AppParam {
+    @ApiModelProperty(value = "1-安卓 2-IOS",required = true)
+    private Integer appType;
+    @ApiModelProperty(value = "应用ID",required = false, notes = "修改时传新增时不传")
+    private String appId;
+    @ApiModelProperty(value = "应用名称",required = true)
+    private String appName;
+    @ApiModelProperty(value = "是否应用商店上架 1-否 2-是 ",required = true)
+    private Integer store_on_sale;
+    @ApiModelProperty(value = "应用商店类型 ",required = false)
+    private Integer store_type;
+    @ApiModelProperty(value = "应用商店链接",required  = false)
+    private String store_url;
+    @ApiModelProperty(value = "应用包名",required = true)
+    private String package_name;
+    @ApiModelProperty(value = "一级分类", required = true)
+    private String category;
+    @ApiModelProperty(value = "二级分类",required = true)
+    private String sub_category;
+    @ApiModelProperty(value = "屏幕方向 1-竖屏 2-横屏 3-所有",required = true)
+    private Integer screen_orientation;
+    @ApiModelProperty(value = "是否遵守COPPA协议 1-否 2-是", required = true)
+    private Integer coppa;
+    @ApiModelProperty(value = "是否遵守CCPA协议 1-否 2-是", required = true)
+    private Integer ccpa;
     @ApiModelProperty("二维码链接")
     private String qrCode;
     @ApiModelProperty("apk应用包地址")

+ 19 - 0
yt-common/src/main/java/com/ytpm/agent/param/ChannelListParam.java

@@ -0,0 +1,19 @@
+package com.ytpm.agent.param;
+
+import com.ytpm.general.PageMeta;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("广告渠道列表入参")
+public class ChannelListParam extends PageMeta {
+    @ApiModelProperty("广告渠道名称")
+    private String channelName;
+}

+ 2 - 0
yt-common/src/main/java/com/ytpm/agent/param/ChannelParam.java

@@ -13,6 +13,7 @@ public class ChannelParam {
     private String channelName;
     @ApiModelProperty("登录类型 1-账号密码 2-微信")
     private Integer loginType;
+    /** 优量汇 902040320340 */
     @ApiModelProperty("渠道账号")
     private String channelAccount;
     @ApiModelProperty("渠道密码")
@@ -21,6 +22,7 @@ public class ChannelParam {
     private Integer channelStatus;
     @ApiModelProperty("请求秘钥")
     private String apiKey;
+    /** 优量汇 vSMkNOUWea13A>MN=1J0F0N&jb984kv9 */
     @ApiModelProperty("请求密令")
     private String apiSecret;
     @ApiModelProperty("备注")

+ 34 - 0
yt-common/src/main/java/com/ytpm/agent/view/AgentAppView.java

@@ -0,0 +1,34 @@
+package com.ytpm.agent.view;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel("应用管理视图")
+public class AgentAppView {
+    @ApiModelProperty("应用ID")
+    private String appId;
+    @ApiModelProperty("应用key")
+    private String appKey;
+    @ApiModelProperty("应用名称")
+    private String appName;
+    @ApiModelProperty("渠道ID")
+    private String channelId;
+    @ApiModelProperty("渠道名称")
+    private String channelName;
+    @ApiModelProperty("加盟商用户ID")
+    private String userId;
+    @ApiModelProperty("应用类型")
+    private Integer appType;
+    @ApiModelProperty("apk安装包地址")
+    private String apkUrl;
+    @ApiModelProperty("二维码链接")
+    private String qrCode;
+    @ApiModelProperty("版本号")
+    private String versionCode;
+    @ApiModelProperty("更新提示")
+    private String updateTips;
+    @ApiModelProperty("是否启用")
+    private Integer enabled;
+}

+ 2 - 0
yt-common/src/main/java/com/ytpm/agent/view/AgentChannelView.java

@@ -25,4 +25,6 @@ public class AgentChannelView {
     private String apiSecret;
     @ApiModelProperty("备注")
     private String remark;
+    @ApiModelProperty("广告平台类型 1-穿山甲 2-腾讯广告 3-百度联盟 4-快手 5-Sigmob")
+    private Integer adPlatformType;
 }

+ 1 - 0
yt-common/src/main/java/com/ytpm/general/RepMessage.java

@@ -31,4 +31,5 @@ public class RepMessage {
     public static final String SERVICE_UNAVAILABLE = "服务暂时不可用,请稍后重试";
     public static final String OBJECT_NOT_EXIST = "查询对象不存在";
     public static final String CURRENT_USER_RISKING = "当前用户处于风控中";
+    public static final String NOT_PERMIT = "当前用户无权限操作";
 }