Explorar o código

Merge remote-tracking branch 'origin/master'

marxjaw hai 4 meses
pai
achega
756739a74c

+ 26 - 22
yt-advertise/advertise-service/src/main/java/com/ytpm/service/impl/TakuApiServiceImpl.java

@@ -35,8 +35,10 @@ import com.ytpm.advertise.param.AddAppParam;
 import com.ytpm.service.TakuApiService;
 import com.ytpm.util.TakuRequestUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -51,6 +53,7 @@ public class TakuApiServiceImpl implements TakuApiService {
     private final static String API_VERSION_V1 = "/v1";
     private final static String API_VERSION_V2 = "/v2";
     private final static String API_VERSION_V3 = "/v3";
+
     /**
      * 新增或修改应用
      */
@@ -58,9 +61,10 @@ public class TakuApiServiceImpl implements TakuApiService {
     public Result<AddAppResponse> saveApp(AddAppParam param) {
         //API支持多个添加,我们这里只添加一个
         JSONObject object = new JSONObject();
-        object.put("items",Collections.singletonList(param));
+        object.put("items", Collections.singletonList(param));
         //若添加成功,API返回应用uuid和 app_key
-        String res = TakuRequestUtil.doRequest(HttpPost.METHOD_NAME, API_VERSION_V3+"/apps", object.toJSONString());
+        //修改时应该使用put 新增使用post
+        String res=TakuRequestUtil.doRequest(StringUtils.isNotBlank(param.getUuid())? HttpPut.METHOD_NAME:HttpPost.METHOD_NAME, API_VERSION_V3 + "/apps", object.toJSONString());
         JSONObject jsonObject = JSON.parseObject(res);
         // 1. 优先检查错误列表 (errs)
         if (jsonObject.containsKey("errs")) {
@@ -70,7 +74,7 @@ public class TakuApiServiceImpl implements TakuApiService {
                 JSONObject firstError = errsArray.getJSONObject(0);
                 Integer errorCode = firstError.getInteger("code");
                 String errorMsg = firstError.getString("msg");
-                throw new RuntimeException("错误码:" + errorCode + "\n message:"+errorMsg);
+                throw new RuntimeException("错误码:" + errorCode + "\n message:" + errorMsg);
             }
         }
         // 2. 检查成功返回的项目 (items)
@@ -83,7 +87,7 @@ public class TakuApiServiceImpl implements TakuApiService {
                 AddAppResponse response = new AddAppResponse();
                 response.setApp_key(appKey);
                 response.setUuid(uuid);
-                return Result.resultOk(RepMessage.SAVE_SUCCESS,response);
+                return Result.resultOk(RepMessage.SAVE_SUCCESS, response);
             }
         }
         return Result.resultErr("未知错误");
@@ -94,7 +98,7 @@ public class TakuApiServiceImpl implements TakuApiService {
      */
     @Override
     public ResultTable<AppV1View> getAppList() {
-        String res = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V1+"/apps", null);
+        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));
     }
@@ -105,8 +109,8 @@ public class TakuApiServiceImpl implements TakuApiService {
     @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());
+        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);
     }
 
@@ -122,7 +126,7 @@ public class TakuApiServiceImpl implements TakuApiService {
         AuthContent authContent = new AuthContent();
         authContent.setAccount_id(channelParam.getChannelAccount());
         authContent.setSecret_key(channelParam.getApiSecret());
-        if(channelParam.getAdPlatformType().equals(AdPlatformTypeEnum.KUAISHOU.getCode())){
+        if (channelParam.getAdPlatformType().equals(AdPlatformTypeEnum.KUAISHOU.getCode())) {
             authContent.setAccess_key(channelParam.getApiKey());
         }
         network.setAuth_content(authContent);
@@ -134,9 +138,9 @@ public class TakuApiServiceImpl implements TakuApiService {
         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));
+        String res = TakuRequestUtil.doRequest(HttpPost.METHOD_NAME, API_VERSION_V1 + "/set_networks", JSONObject.toJSONString(network));
         Network result = JSONObject.parseObject(res, Network.class);
-        return Result.resultOk(RepMessage.RELATIVE_SUCCESS,result);
+        return Result.resultOk(RepMessage.RELATIVE_SUCCESS, result);
     }
 
     /**
@@ -145,7 +149,7 @@ public class TakuApiServiceImpl implements TakuApiService {
     @Override
     public ResultTable<Network> getNetworks() {
         // 这个接口虽然没有参数但是要设置为 " ", 如果reqBody设置为NULL会报601
-        String res = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V1+"/networks", "");
+        String res = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V1 + "/networks", "");
         return ResultTable.resultTableOk(new PageInfo<>(JSON.parseArray(res, Network.class)));
     }
 
@@ -154,7 +158,7 @@ public class TakuApiServiceImpl implements TakuApiService {
      */
     @Override
     public ResultTable<AddPlacementResponse> addPlacements(AddPlacementParam param) {
-        String res = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V1+"/deal_placement", JSON.toJSONString(param));
+        String res = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V1 + "/deal_placement", JSON.toJSONString(param));
         List<AddPlacementResponse> placements = JSONArray.parseArray(res, AddPlacementResponse.class);
         return ResultTable.resultTableOk(new PageInfo<>(placements));
     }
@@ -164,7 +168,7 @@ public class TakuApiServiceImpl implements TakuApiService {
      */
     @Override
     public ResultTable<?> getPlacementList(AddPlacementParam param) {
-        String res = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V1+"/placements", JSON.toJSONString(param));
+        String res = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V1 + "/placements", JSON.toJSONString(param));
         List<AddPlacementResponse> placements = JSONArray.parseArray(res, AddPlacementResponse.class);
         return ResultTable.resultTableOk(new PageInfo<>(placements));
     }
@@ -175,8 +179,8 @@ public class TakuApiServiceImpl implements TakuApiService {
     @Override
     public Result<?> delPlacement(List<String> placementIds) {
         JSONObject object = new JSONObject();
-        object.put("placement_ids",placementIds);
-        TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V1+"/del_placements", object.toJSONString());
+        object.put("placement_ids", placementIds);
+        TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V1 + "/del_placements", object.toJSONString());
         return Result.resultOk(RepMessage.DELETE_SUCCESS);
     }
 
@@ -185,7 +189,7 @@ public class TakuApiServiceImpl implements TakuApiService {
      */
     @Override
     public ResultTable<UnitsListView> getUnitsList(UnitsListParam unitsListParam) {
-        String result = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V3+"/units/list", JSON.toJSONString(unitsListParam));
+        String result = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V3 + "/units/list", JSON.toJSONString(unitsListParam));
         return ResultTable.resultTableOk(new PageInfo<>(JSON.parseArray(result, UnitsListView.class)));
     }
 
@@ -195,8 +199,8 @@ public class TakuApiServiceImpl implements TakuApiService {
     @Override
     public ResultTable<UnitsView> getUnitsView(List<Integer> ids) {
         JSONObject object = new JSONObject();
-        object.put("ids",ids);
-        String result = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V3+"/units", JSON.toJSONString(object));
+        object.put("ids", ids);
+        String result = TakuRequestUtil.doRequest(HttpGet.METHOD_NAME, API_VERSION_V3 + "/units", JSON.toJSONString(object));
         return ResultTable.resultTableOk(new PageInfo<>(JSON.parseArray(result, UnitsView.class)));
     }
 
@@ -205,7 +209,7 @@ public class TakuApiServiceImpl implements TakuApiService {
      */
     @Override
     public Result<?> saveUnits(UnitsParam param) {
-        String result = TakuRequestUtil.doRequest(HttpPost.METHOD_NAME, API_VERSION_V3+"/units", JSON.toJSONString(param));
+        String result = TakuRequestUtil.doRequest(HttpPost.METHOD_NAME, API_VERSION_V3 + "/units", JSON.toJSONString(param));
         return Result.resultObjOk(JSONObject.parseObject(result, UnitsAddResponse.class));
     }
 
@@ -214,7 +218,7 @@ public class TakuApiServiceImpl implements TakuApiService {
      */
     @Override
     public Result<?> updateUnits(UnitsParam param) {
-        String result = TakuRequestUtil.doRequest(HttpPost.METHOD_NAME, API_VERSION_V3+"/units", JSON.toJSONString(param));
+        String result = TakuRequestUtil.doRequest(HttpPost.METHOD_NAME, API_VERSION_V3 + "/units", JSON.toJSONString(param));
         return Result.resultObjOk(JSONObject.parseObject(result, UnitsUpdateResponse.class));
     }
 
@@ -224,8 +228,8 @@ public class TakuApiServiceImpl implements TakuApiService {
     @Override
     public Result<?> delUnits(List<Integer> adsource_ids) {
         JSONObject object = new JSONObject();
-        object.put("adsource_ids",adsource_ids);
-        TakuRequestUtil.doRequest(HttpPost.METHOD_NAME, API_VERSION_V1+"/del_units", JSON.toJSONString(object));
+        object.put("adsource_ids", adsource_ids);
+        TakuRequestUtil.doRequest(HttpPost.METHOD_NAME, API_VERSION_V1 + "/del_units", JSON.toJSONString(object));
         return Result.resultOk(RepMessage.DELETE_SUCCESS);
     }
 

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

@@ -10,6 +10,7 @@ import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
 import org.apache.http.client.methods.HttpRequestBase;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
@@ -53,8 +54,10 @@ public class TakuRequestUtil {
                 httpRequest = httpPost;
             } else if (httpMethod.equals(HttpGet.METHOD_NAME)) {
                 httpRequest = new HttpGet(DOMAIN+reqUrl);
-            } else {
-                // TODO
+            } else if(httpMethod.equals(HttpPut.METHOD_NAME)){
+                HttpPut httpPut = new HttpPut(DOMAIN + reqUrl);
+                httpPut.setEntity(new StringEntity(reqBody,"utf-8"));
+                httpRequest = httpPut;
             }
             // create the final signature
             String contentMD5 = Objects.nonNull(reqBody)?DigestUtils.md5Hex(reqBody).toUpperCase():"";

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

@@ -39,7 +39,7 @@ public class AgentChannelController {
      */
     @ApiOperation("新增广告渠道")
     @PostMapping("/addOne")
-    public Result<?> addOne(ChannelParam param){
+    public Result<?> addOne(@RequestBody ChannelParam param){
         return channelService.addOne(param);
     }
 
@@ -48,7 +48,7 @@ public class AgentChannelController {
      */
     @ApiOperation("修改广告渠道")
     @PostMapping("/updateOne")
-    public Result<?> updateOne(ChannelParam param){
+    public Result<?> updateOne(@RequestBody ChannelParam param){
         return channelService.updateOne(param);
     }
 

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

@@ -81,6 +81,10 @@ public class AgentAppServiceImpl implements AgentAppService {
         YtApp app = new YtApp();
         BeanUtil.copyProperties(param, app);
         if(StrUtil.isNotBlank(param.getAppId())){
+            app.setScreenOrientation(param.getScreen_orientation());
+            app.setPackageName(param.getPackage_name());
+            app.setStoreOnSale(param.getStore_on_sale());
+            app.setStoreUrl(param.getStore_url());
             appMapper.updateOne(app);
         }else{
             log.debug("result{}",result);

+ 42 - 3
yt-agent/agent-service/src/main/resources/mapper/AppMapper.xml

@@ -22,7 +22,8 @@
          sub_category,
          coppa,
          screen_orientation,
-         ccpa
+         ccpa,
+         store_url
         )
         values
         (
@@ -43,7 +44,8 @@
          #{subCategory},
          #{coppa},
          #{screenOrientation},
-         #{ccpa}
+         #{ccpa},
+         #{storeUrl}
         )
     </insert>
     <update id="updateOne">
@@ -65,8 +67,45 @@
                 update_tips = #{updateTips},
             </if>
             <if test="enabled != null">
-                enabled = #{enabled}
+                enabled = #{enabled},
             </if>
+            <if test="storeOnSale != null">
+                store_on_sale = #{storeOnSale},
+            </if>
+            <if test="storeType != null">
+                store_type = #{storeType},
+            </if>
+            <if test="storeUrl != null">
+                store_url = #{storeUrl},
+            </if>
+            <if test="packageName != null">
+                package_name = #{packageName},
+            </if>
+            <if test="domain != null">
+                domain = #{domain},
+            </if>
+            <if test="category != null">
+                category = #{category},
+            </if>
+            <if test="subCategory != null">
+                sub_category = #{subCategory},
+            </if>
+            <if test="coppa != null">
+                coppa = #{coppa},
+            </if>
+            <if test="screenOrientation != null">
+                screen_orientation = #{screenOrientation},
+            </if>
+            <if test="ccpa != null">
+                ccpa = #{ccpa},
+            </if>
+            <if test=" apkUrl != null">
+                apk_url = #{apkUrl},
+            </if>
+            <if test="qrCode != null">
+                qr_code = #{qrCode},
+            </if>
+
         </set>
         where app_id = #{appId}
     </update>

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

@@ -12,7 +12,8 @@
              channel_status,
              api_key,
              api_secret,
-             remark
+             remark,
+             ad_platform_type
             )
         values
             (
@@ -24,7 +25,8 @@
                 #{channelStatus},
                 #{apiKey},
                 #{apiSecret},
-                #{remark}
+                #{remark},
+                #{adPlatformType}
             )
     </insert>
     <update id="update">
@@ -45,13 +47,28 @@
             <if test="remark !=null">
                 remark = #{remark},
             </if>
+            <if test="enabled !=null">
+                enabled = #{enabled},
+            </if>
+            <if test="adPlatformType !=null">
+                ad_platform_type = #{adPlatformType},
+            </if>
+            <if test="channelAccount !=null">
+                channel_account = #{channelAccount},
+            </if>
+            <if test="channelPwd !=null">
+                channel_pwd = #{channelPwd},
+            </if>
+            <if test="loginType !=null">
+                login_type = #{loginType},
+            </if>
         </set>
         where channel_id = #{channelId}
     </update>
 
     <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, enabled
+            channel_id, channel_name, login_type, channel_account, channel_pwd, channel_status, api_key, api_secret, remark, enabled,ad_platform_type
         from yt_channel
         where enabled = 1
     </select>

+ 3 - 0
yt-common/src/main/java/com/ytpm/agent/model/YtChannel.java

@@ -27,4 +27,7 @@ public class YtChannel {
     private String remark;
     @ApiModelProperty("是否启用")
     private Integer enabled;
+    @ApiModelProperty("广告平台类型 15-穿山甲 8-腾讯广告 22-百度联盟 28-快手 29-Sigmob")
+    private Integer adPlatformType;
+
 }

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

@@ -6,7 +6,7 @@ import lombok.Data;
 
 @Data
 @ApiModel("广告渠道入参")
-public class ChannelParam {
+public class    ChannelParam {
     @ApiModelProperty("渠道ID")
     private String channelId;
     @ApiModelProperty("渠道名称")
@@ -27,6 +27,6 @@ public class ChannelParam {
     private String apiSecret;
     @ApiModelProperty("备注")
     private String remark;
-    @ApiModelProperty("广告平台类型 1-穿山甲 2-腾讯广告 3-百度联盟 4-快手 5-Sigmob")
+    @ApiModelProperty("广告平台类型 15-穿山甲 8-腾讯广告 22-百度联盟 28-快手 29-Sigmob")
     private Integer adPlatformType;
 }