Commit d0c6a4a9 authored by dingjy's avatar dingjy

modify

parent ce34daaa
...@@ -31,7 +31,7 @@ import java.util.function.Function; ...@@ -31,7 +31,7 @@ import java.util.function.Function;
@RestController @RestController
@Slf4j @Slf4j
@RequestMapping(value = "/clickback") @RequestMapping(value = "/clickback")
public class ClickbackService { public class ClickbackService extends ServiceHelper{
final static ImmutableSet<String> filter = ImmutableSet.of("click.special.param:00000000-0000-0000-0000-000000000000","9f89c84a559f573636a47ff8daed0d33","__IMEI__","null","NULL"); final static ImmutableSet<String> filter = ImmutableSet.of("click.special.param:00000000-0000-0000-0000-000000000000","9f89c84a559f573636a47ff8daed0d33","__IMEI__","null","NULL");
...@@ -77,12 +77,7 @@ public class ClickbackService { ...@@ -77,12 +77,7 @@ public class ClickbackService {
clientInfo.setIdfa(params.get("idfa")); clientInfo.setIdfa(params.get("idfa"));
clientInfo.setClientIp(params.get("ip")); clientInfo.setClientIp(params.get("ip"));
clientInfo.setUa(params.get("ua")); clientInfo.setUa(params.get("ua"));
try { clientInfo.setPhoneModel(encode(params.get("model")));
clientInfo.setPhoneModel(StringUtils.defaultIfEmpty(URLEncoder.encode(params.get("model"),"utf-8"),null));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
DeliveryDeviceInfo deliveryDeviceInfo = new DeliveryDeviceInfo(); DeliveryDeviceInfo deliveryDeviceInfo = new DeliveryDeviceInfo();
deliveryDeviceInfo.setClick_time(System.currentTimeMillis()); deliveryDeviceInfo.setClick_time(System.currentTimeMillis());
deliveryDeviceInfo.setAd_group_id(params.get("campaign_id")); deliveryDeviceInfo.setAd_group_id(params.get("campaign_id"));
...@@ -104,16 +99,15 @@ public class ClickbackService { ...@@ -104,16 +99,15 @@ public class ClickbackService {
deliveryDeviceInfo.setUnion_site(params.get("union_site")); deliveryDeviceInfo.setUnion_site(params.get("union_site"));
deliveryDeviceInfo.setPartId(params.get("part_id")); deliveryDeviceInfo.setPartId(params.get("part_id"));
//巨量广告体验版中特有的宏参,代表巨量广告体验版的广告ID //巨量广告体验版中特有的宏参,代表巨量广告体验版的广告ID
deliveryDeviceInfo.setPromotion_id(StringUtils.defaultIfEmpty(params.get("promotion_id"),null)); deliveryDeviceInfo.setPromotion_id(emptyIsNull(params.get("promotion_id")));
//巨量广告体验版中特有的宏参,代表巨量广告体验版的项目ID //巨量广告体验版中特有的宏参,代表巨量广告体验版的项目ID
deliveryDeviceInfo.setProject_id(StringUtils.defaultIfEmpty(params.get("project_id"),null)); deliveryDeviceInfo.setProject_id(emptyIsNull(params.get("project_id")));
//巨量广告体验版中的广告名称 //巨量广告体验版中的广告名称
deliveryDeviceInfo.setPromotion_name(StringUtils.defaultIfEmpty(params.get("promotion_name"),null)); deliveryDeviceInfo.setPromotion_name(emptyIsNull(params.get("promotion_name")));
//巨量广告体验版中的项目名称 //巨量广告体验版中的项目名称
deliveryDeviceInfo.setProject_name(StringUtils.defaultIfEmpty(params.get("project_name"),null)); deliveryDeviceInfo.setProject_name(emptyIsNull(params.get("project_name")));
//信息流投放广告来源(碎片 1 书籍 2) //信息流投放广告来源(碎片 1 书籍 2)
deliveryDeviceInfo.setSource(Integer.valueOf(params.get("source"))); deliveryDeviceInfo.setSource(parseInt(params.get("source")));
return new NovelAction(clientInfo,deliveryDeviceInfo); return new NovelAction(clientInfo,deliveryDeviceInfo);
} }
......
package com.lwby.marketing.controller;
import org.apache.commons.lang3.StringUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class ServiceHelper {
public String emptyIsNull(String params){
return StringUtils.defaultIfEmpty(params,null);
}
public String encode(String params){
try {
return URLEncoder.encode(params,"utf-8");
} catch (UnsupportedEncodingException e) {
return null;
}
}
public Integer parseInt(String params){
try {
return Integer.valueOf(params);
}catch (Exception e){
return null;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment