Эх сурвалжийг харах

app新增和删除接口修改

小杜 4 сар өмнө
parent
commit
157e04547b

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

@@ -18,8 +18,8 @@ import org.springframework.web.bind.annotation.RequestParam;
 public interface AdvertiseFeign {
     @PostMapping("/advertise/saveApp")
     Result<AddAppResponse> saveApp(@RequestBody AddAppParam param);
-    @PostMapping("/advertise/delApp")
-    Result<?> delApp(@Param("appId") String appId);
+    @GetMapping("/advertise/delApp")
+    Result<?> delApp(@RequestParam("appId") String appId);
     @PostMapping("/advertise/relativePlatform")
     Result<?> relativePlatform(@RequestBody RelativeChannelParam channelParam);
     @PostMapping("/advertise/savePlacement")

+ 27 - 3
yt-advertise/advertise-service/src/main/java/com/ytpm/service/impl/TakuApiServiceImpl.java

@@ -51,9 +51,33 @@ public class TakuApiServiceImpl implements TakuApiService {
         JSONObject object = new JSONObject();
         object.put("items",Collections.singletonList(param));
         //若添加成功,API返回应用uuid和 app_key
-        String res = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V3+"/apps", object.toJSONString());
-        AddAppResponse response = JSON.parseObject(res, AddAppResponse.class);
-        return Result.resultOk(RepMessage.SAVE_SUCCESS,response);
+        String res = TakuRequestUtil.doRequest(HttpPost.METHOD_NAME, API_VERSION_V3+"/apps", object.toJSONString());
+        JSONObject jsonObject = JSON.parseObject(res);
+        // 1. 优先检查错误列表 (errs)
+        if (jsonObject.containsKey("errs")) {
+            JSONArray errsArray = jsonObject.getJSONArray("errs");
+            if (errsArray != null && !errsArray.isEmpty()) {
+                // 处理错误情况 - 提取第一个错误信息
+                JSONObject firstError = errsArray.getJSONObject(0);
+                Integer errorCode = firstError.getInteger("code");
+                String errorMsg = firstError.getString("msg");
+                throw new RuntimeException("错误码:" + errorCode + "\n message:"+errorMsg);
+            }
+        }
+        // 2. 检查成功返回的项目 (items)
+        if (jsonObject.containsKey("items")) {
+            JSONArray itemsArray = jsonObject.getJSONArray("items");
+            if (itemsArray != null && !itemsArray.isEmpty()) {
+                JSONObject successItem = itemsArray.getJSONObject(0);
+                String uuid = successItem.getString("uuid");
+                String appKey = successItem.getString("app_key");
+                AddAppResponse response = new AddAppResponse();
+                response.setApp_key(appKey);
+                response.setUuid(uuid);
+                return Result.resultOk(RepMessage.SAVE_SUCCESS,response);
+            }
+        }
+        return Result.resultErr("未知错误");
     }
 
     /**

+ 3 - 3
yt-advertise/advertise-service/src/main/java/com/ytpm/util/TakuRequestUtil.java

@@ -43,12 +43,12 @@ public class TakuRequestUtil {
             CloseableHttpClient httpClient = HttpClients.createDefault();
             HttpRequestBase httpRequest = null;
             if (httpMethod.equals(HttpPost.METHOD_NAME)) {
-                HttpPost httpPost = new HttpPost(reqUrl);
+                HttpPost httpPost = new HttpPost(DOMAIN+reqUrl);
                 httpPost.setEntity(new StringEntity(reqBody,"utf-8")); // 兼容中文
 //                httpPost.setEntity(new StringEntity(reqBody));
                 httpRequest = httpPost;
             } else if (httpMethod.equals(HttpGet.METHOD_NAME)) {
-                httpRequest = new HttpGet(reqUrl);
+                httpRequest = new HttpGet(DOMAIN+reqUrl);
             } else {
                 // TODO
             }
@@ -56,7 +56,7 @@ public class TakuRequestUtil {
             String contentMD5 = Objects.nonNull(reqBody)?DigestUtils.md5Hex(reqBody).toUpperCase():"";
             String nowMillis = System.currentTimeMillis() + "";
             String headerStr = "X-Up-Key:" + PUBLISHER_KEY + "\n" + "X-Up-Timestamp:" + nowMillis;
-            String relativePath = new URL(reqUrl).getPath();
+            String relativePath = new URL(DOMAIN+reqUrl).getPath();
             String finalSign = genSignature(httpMethod, contentMD5, CONTENT_TYPE, headerStr, relativePath);
             // set the headers
             httpRequest.setHeader("Content-Type", CONTENT_TYPE);

+ 2 - 6
yt-agent/agent-service/src/main/java/com/ytpm/controller/AppController.java

@@ -13,11 +13,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 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;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import springfox.documentation.annotations.ApiIgnore;
 
 import javax.annotation.Resource;
@@ -63,7 +59,7 @@ public class AppController {
      */
     @ApiOperation("删除应用")
     @GetMapping("/delApp")
-    public Result<?> delApp(@ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo, @Param("appId")String appId) {
+    public Result<?> delApp(@ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo, @RequestParam("appId")String appId) {
         return agentAppService.delApp(appId,userInfo.getUserId());
     }
 

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

@@ -19,6 +19,7 @@ import com.ytpm.general.RepMessage;
 import com.ytpm.general.Result;
 import com.ytpm.general.ResultTable;
 import com.ytpm.service.AgentAppService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -26,6 +27,7 @@ import java.util.Objects;
 
 
 @Service
+@Slf4j
 public class AgentAppServiceImpl implements AgentAppService {
 
     @Resource
@@ -60,8 +62,13 @@ public class AgentAppServiceImpl implements AgentAppService {
     public Result<?> saveApp(AppParam param, String userId) {
         //构造API对象
         AddAppParam addAppParam = new AddAppParam(param);
+        Result<AddAppResponse> result = null;
         //调用广告平台API 增加应用
-        Result<AddAppResponse> result = advertiseFeign.saveApp(addAppParam);
+        try {
+            result=advertiseFeign.saveApp(addAppParam);
+        }catch (Exception e){
+            log.error("参数错误{}",e);
+        }
         //数据库操作,有appId为修改, 没有时为新增
         changeDataAction(param,result,userId);
         return Result.resultOk(RepMessage.SAVE_SUCCESS);
@@ -76,8 +83,13 @@ public class AgentAppServiceImpl implements AgentAppService {
         if(StrUtil.isNotBlank(param.getAppId())){
             appMapper.updateOne(app);
         }else{
+            log.debug("result{}",result);
             AddAppResponse data = result.getData();
             BeanUtil.copyProperties(param, app);
+            app.setScreenOrientation(param.getScreen_orientation());
+            app.setPackageName(param.getPackage_name());
+            app.setStoreOnSale(param.getStore_on_sale());
+            app.setStoreUrl(param.getStore_url());
             app.setAppId(data.getUuid());
             app.setAppKey(data.getApp_key());
             app.setUserId(userId);

+ 10 - 0
yt-agent/agent-service/src/main/resources/mapper/AgentAppMapper.xml

@@ -33,6 +33,16 @@
             ya.version_code,
             ya.update_tips,
             ya.enabled,
+            ya.store_on_sale,
+            ya.store_type,
+            ya.store_url,
+            ya.package_name,
+            ya.domain,
+            ya.category,
+            ya.sub_category,
+            ya.coppa,
+            ya.ccpa,
+            ya.screen_orientation,
             GROUP_CONCAT( acr.channel_id ) channel_id,
             GROUP_CONCAT( acr.channel_name ) channel_name,
             GROUP_CONCAT( acr.network_app_id ) network_app_id,

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

@@ -13,7 +13,16 @@
          apk_url,
          qr_code,
          version_code,
-         update_tips
+         update_tips,
+         store_on_sale,
+         store_type,
+         package_name,
+         domain,
+         category,
+         sub_category,
+         coppa,
+         screen_orientation,
+         ccpa
         )
         values
         (
@@ -25,7 +34,16 @@
          #{apkUrl},
          #{qrCode},
          #{versionCode},
-         #{updateTips}
+         #{updateTips},
+         #{storeOnSale},
+         #{storeType},
+         #{packageName},
+         #{domain},
+         #{category},
+         #{subCategory},
+         #{coppa},
+         #{screenOrientation},
+         #{ccpa}
         )
     </insert>
     <update id="updateOne">

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

@@ -2,9 +2,13 @@ package com.ytpm.advertise.param;
 
 import com.ytpm.agent.param.AppParam;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 @Data
+@AllArgsConstructor
+@NoArgsConstructor
 public class AddAppParam {
     @ApiModelProperty(value = "1-安卓 2-IOS",required = true)
     private Integer platform;

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

@@ -4,30 +4,98 @@ import lombok.Data;
 
 @Data
 public class YtApp {
-    /** 应用ID */
+    /**
+     * 应用ID
+     */
     private String appId;
-    /** 应用名称 */
+    /**
+     * 应用名称
+     */
     private String appName;
-    /** 应用秘钥 */
+    /**
+     * 应用秘钥
+     */
     private String appKey;
-    /** 广告渠道ID */
+    /**
+     * 广告渠道ID
+     */
     private String channelId;
-    /** 广告渠道名称 */
+    /**
+     * 广告渠道名称
+     */
     private String channelName;
-    /** 平台加盟商ID */
+    /**
+     * 平台加盟商ID
+     */
     private String userId;
-    /** 应用类型 1-Android 2-IOS */
+    /**
+     * 应用类型 1-Android 2-IOS
+     */
     private Integer appType;
-    /** 广告渠道应用ID */
+    /**
+     * 广告渠道应用ID
+     */
     private String networkAppId;
-    /** 安装包链接 */
+    /**
+     * 安装包链接
+     */
     private String apkUrl;
-    /** 二维码 */
+    /**
+     * 二维码
+     */
     private String qrCode;
-    /** 版本号 */
+    /**
+     * 版本号
+     */
     private String versionCode;
-    /** 更新提示 */
+    /**
+     * 更新提示
+     */
     private String updateTips;
-    /** 启用状态 */
+    /**
+     * 启用状态
+     */
     private Integer enabled;
+    /**
+     * 是否应用商店上架 1-否 2-是
+     */
+    private Integer storeOnSale;
+    /**
+     * 应用商店类型
+     */
+    private Integer storeType;
+    /**
+     * 应用包名
+     */
+    private String packageName;
+    /**
+     * 应用商店链接
+     */
+    private String storeUrl;
+    /**
+     * 应用域名
+     */
+    private String domain;
+    /**
+     * 一级分类
+     */
+    private String category;
+    /**
+     * 二级分类
+     */
+    private String subCategory;
+    /**
+     * coppa
+     */
+    private Integer coppa;
+    /**
+     * ccpa
+     */
+    private Integer ccpa;
+    /**
+     * 屏幕方向
+     */
+    private Integer screenOrientation;
+
+
 }

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

@@ -2,6 +2,7 @@ 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;
@@ -13,6 +14,9 @@ import lombok.NoArgsConstructor;
 @AllArgsConstructor
 @ApiModel("应用列表入参")
 public class AppListParam extends PageMeta {
+    @ApiModelProperty("app名称")
     private String appName;
     private String userId;
+    private Integer appType;
+    private String channelName;
 }

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

@@ -28,6 +28,8 @@ public class AppParam {
     private String store_url;
     @ApiModelProperty(value = "应用包名",required = true)
     private String package_name;
+    @ApiModelProperty(value = "应用域名")
+    private String domain;
     @ApiModelProperty(value = "一级分类", required = true)
     private String category;
     @ApiModelProperty(value = "二级分类",required = true)

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

@@ -38,4 +38,47 @@ public class AgentAppView {
     @ApiModelProperty("加盟商名称")
     private String nickName;
     private boolean showKey;
+
+    /**
+     * 是否应用商店上架 1-否 2-是
+     */
+    private Integer storeOnSale;
+    /**
+     * 应用商店类型
+     */
+    private Integer storeType;
+    /**
+     * 应用包名
+     */
+    private String packageName;
+    /**
+     * 应用商店链接
+     */
+    private String storeUrl;
+    /**
+     * 应用域名
+     */
+    private String domain;
+    /**
+     * 一级分类
+     */
+    private String category;
+    /**
+     * 二级分类
+     */
+    private String subCategory;
+    /**
+     * coppa
+     */
+    private Integer coppa;
+    /**
+     * ccpa
+     */
+    private Integer ccpa;
+    /**
+     * 屏幕方向
+     */
+    private Integer screenOrientation;
+
+
 }