@ -1,20 +1,27 @@
package com.baiyee.adcallback.api.callback ;
import cn.hutool.core.text.CharSequenceUtil ;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.core.util.StrUtil ;
import cn.hutool.json.JSONUtil ;
import com.baiyee.adcallback.api.common.CommonResponse ;
import com.baiyee.adcallback.api.common.ResponseCode ;
import com.baiyee.adcallback.api.vo.* ;
import com.baiyee.adcallback.common.enums.DeliveryPlatformEnum ;
import com.baiyee.adcallback.config.pojo.* ;
import com.baiyee.adcallback.config.pojo.convert.* ;
import com.baiyee.adcallback.service.AdOriginalityManageService ;
import com.baiyee.adcallback.service.EquipmentService ;
import com.baiyee.adcallback.service.IdfaService ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.web.bind.annotation.* ;
import static com.baiyee.adcallback.common.constant.JuliangConstant.IMEI_NULL_TAG ;
import static com.baiyee.adcallback.common.constant.JuliangConstant.IMEI_TAG ;
import javax.annotation.Resource ;
import java.util.Set ;
import static com.baiyee.adcallback.common.constant.DataConstant.* ;
/ * *
* 移 动 监 控 api
@ -27,6 +34,13 @@ import static com.baiyee.adcallback.common.constant.JuliangConstant.IMEI_TAG;
@Slf4j
public class MobileMonitorCallbackAPI {
@Resource
private IdfaService idfaService ;
@Resource
private EquipmentService equipmentService ;
@Autowired
private AdOriginalityManageService adOriginalityManageService ;
@ -54,7 +68,7 @@ public class MobileMonitorCallbackAPI {
* < p >
* /
@RequestMapping ( value = "/jl/monitor" )
public CommonResponse julaingMonitorUrlCallbackReqUrl (
public CommonResponse < String > julaingMonitorUrlCallbackReqUrl (
@RequestParam ( value = "aid" , defaultValue = "" ) String aid ,
@RequestParam ( value = "aidname" , defaultValue = "" ) String aidName ,
@RequestParam ( value = "advertiserid" , defaultValue = "" ) String advertiserId ,
@ -82,9 +96,18 @@ public class MobileMonitorCallbackAPI {
if ( ObjectUtil . isNull ( vo ) ) {
return CommonResponse . createByErrorMessage ( ResponseCode . EMPTY_ARGUMENT . getDesc ( ) ) ;
}
Set < String > modeByResource =
equipmentService . queryModeByResource ( DeliveryPlatformEnum . JL . getType ( ) ) ;
// 保存机型
if ( StringUtils . isNotBlank ( model ) & & ! modeByResource . contains ( model ) ) {
equipmentService . saveEquipmentBySource ( model , DeliveryPlatformEnum . JL . getType ( ) ) ;
}
// 保存数据
filterIdfa ( idfa , tag , DeliveryPlatformEnum . JL . getType ( ) ) ;
// 请求过滤规则,过滤掉不用的数据
if ( preRuleForReq ( vo ) ) {
log . error ( "================================= [not right imei data ,vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
log . error ( "================================= [not right imei data ,vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
return CommonResponse . createBySuccess ( ) ;
}
setTag ( tag , vo ) ;
@ -95,6 +118,7 @@ public class MobileMonitorCallbackAPI {
return CommonResponse . createBySuccess ( ) ;
}
/ * *
* 之 前 的 规 则 要 求
*
@ -103,14 +127,13 @@ public class MobileMonitorCallbackAPI {
private boolean preRuleForReq ( JuliangMobileMonitorCallbackRequestVO vo ) {
String imei = vo . getImei ( ) ;
if ( StrUtil . isBlank ( imei ) ) {
return Boolean . TRUE ;
}
if ( StrUtil . equalsIgnoreCase ( IMEI_TAG , imei ) ) {
return Boolean . TRUE ;
}
return Boolean . FALSE ;
}
@ -124,7 +147,7 @@ public class MobileMonitorCallbackAPI {
* http : //www.test.com/notice?tag=test123&imei_md5={{IMEI_MD5}}&os={{OS}}&ip={{IP}}&ua={{UA}}&ts={{TS}}&userid={{USER_ID}}&pid={{PLAN_ID}}&uid={{UNIT_ID}}&aid={{IDEA_ID}}&click_id={{CLICK_ID}}&callback_url={{CALLBACK_URL}}
* /
@RequestMapping ( value = "/bd/monitor" )
public CommonResponse baiduMonitorUrlCallbackReqUrl (
public CommonResponse < String > baiduMonitorUrlCallbackReqUrl (
@RequestParam ( value = "userid" , defaultValue = "" ) String userId ,
@RequestParam ( value = "aid" , defaultValue = "" ) String aid ,
@RequestParam ( value = "pid" , defaultValue = "" ) String pid ,
@ -151,13 +174,22 @@ public class MobileMonitorCallbackAPI {
if ( ObjectUtil . isNull ( vo ) ) {
return CommonResponse . createByErrorMessage ( ResponseCode . EMPTY_ARGUMENT . getDesc ( ) ) ;
}
Set < String > modeByResource =
equipmentService . queryModeByResource ( DeliveryPlatformEnum . BD . getType ( ) ) ;
// 保存机型
if ( StringUtils . isNotBlank ( deviceInfo ) & & ! modeByResource . contains ( deviceInfo ) ) {
equipmentService . saveEquipmentBySource ( deviceInfo , DeliveryPlatformEnum . BD . getType ( ) ) ;
}
// 保存数据
filterIdfa ( idfa , tag , DeliveryPlatformEnum . BD . getType ( ) ) ;
// 请求过滤规则,过滤掉不用的数据
if ( preRuleForReq ( vo ) ) {
log . error ( "================================= [not right imei data ,vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
log . error ( "================================= [not right imei data ,vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
return CommonResponse . createBySuccess ( ) ;
}
setTag ( tag , vo ) ;
log . info ( "================================= [one request comming, baiduMonitorUrlCallbackReqUrl|MobileMonitorCallbackAPI, vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
log . info ( "================================= [one request comming, baiduMonitorUrlCallbackReqUrl|MobileMonitorCallbackAPI, vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
BdBackdataDTO bdBackdataDTO = new BdBackdataDTO ( ) ;
BdBackdataConvert . voCovertToDTO ( vo , bdBackdataDTO ) ;
@ -175,8 +207,7 @@ public class MobileMonitorCallbackAPI {
private boolean preRuleForReq ( BaiduMobileMonitorCallbackRequestVO vo ) {
String imei = vo . getImei ( ) ;
if ( StrUtil . isBlank ( imei ) | | StrUtil . equalsIgnoreCase ( IMEI_TAG , imei ) | | StrUtil . equalsIgnoreCase ( IMEI_NULL_TAG , imei ) ) {
if ( StrUtil . isBlank ( imei ) | | StrUtil . equalsIgnoreCase ( IMEI_TAG , imei ) | | StrUtil . equalsIgnoreCase ( IMEI_NULL_TAG , imei ) ) {
return Boolean . TRUE ;
}
return Boolean . FALSE ;
@ -192,7 +223,7 @@ public class MobileMonitorCallbackAPI {
* A } & acid = { ACID } & gid = { GID } & aid = { AID } & cid = { CID } & tag = uc - jq - 1
* /
@RequestMapping ( value = "/uc/monitor" )
public CommonResponse ucMonitorUrlCallbackReqUrl (
public CommonResponse < String > ucMonitorUrlCallbackReqUrl (
@RequestParam ( value = "imei" , defaultValue = "" ) String imei ,
@RequestParam ( value = "oaid" , defaultValue = "" ) String oaid ,
@RequestParam ( value = "time" , defaultValue = "" ) Long ts ,
@ -205,22 +236,33 @@ public class MobileMonitorCallbackAPI {
@RequestParam ( value = "gid" , defaultValue = "" ) String gid ,
@RequestParam ( value = "aid" , defaultValue = "" ) String aid ,
@RequestParam ( value = "cid" , defaultValue = "" ) String cid ,
@RequestParam ( value = "idfa" , defaultValue = "" ) String idfa ,
@RequestParam ( value = "model" , defaultValue = "" ) String model ,
@RequestParam ( value = "tag" , defaultValue = "" ) String tag
) {
UcMobileMonitorCallbackRequestVO vo = new UcMobileMonitorCallbackRequestVO (
imei , oaid , ts , callbackUrl , androidId , mac , ip , ua , acid , gid , aid , cid
imei , oaid , ts , callbackUrl , androidId , mac , ip , ua , acid , gid , aid , cid , model , idfa
) ;
if ( ObjectUtil . isNull ( vo ) ) {
return CommonResponse . createByErrorMessage ( ResponseCode . EMPTY_ARGUMENT . getDesc ( ) ) ;
}
Set < String > modeByResource =
equipmentService . queryModeByResource ( DeliveryPlatformEnum . UC . getType ( ) ) ;
// 保存机型
if ( StringUtils . isNotBlank ( model ) & & ! modeByResource . contains ( model ) ) {
equipmentService . saveEquipmentBySource ( model , DeliveryPlatformEnum . UC . getType ( ) ) ;
}
// 保存数据
filterIdfa ( idfa , tag , DeliveryPlatformEnum . UC . getType ( ) ) ;
// 请求过滤规则,过滤掉不用的数据
if ( preRuleForReq ( vo ) ) {
log . error ( "================================= [not right imei data ,vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
log . error ( "================================= [not right imei data ,vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
return CommonResponse . createBySuccess ( ) ;
}
setTag ( tag , vo ) ;
log . info ( "================================= [one request comming, ucMonitorUrlCallbackReqUrl|MobileMonitorCallbackAPI, vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
log . info ( "================================= [one request comming, ucMonitorUrlCallbackReqUrl|MobileMonitorCallbackAPI, vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
UcBackdataDTO ucBackdataDTO = new UcBackdataDTO ( ) ;
UcBackdataConvert . voCovertToDTO ( vo , ucBackdataDTO ) ;
adOriginalityManageService . handleMonitorUrlCallbackDataThenSave2 ( ) ;
@ -252,7 +294,7 @@ public class MobileMonitorCallbackAPI {
* https : //docs.qingque.cn/d/home/eZQBTWKAahwgCU4YeU_bRW5B_#
* /
@RequestMapping ( value = "/ks/monitor" )
public CommonResponse kuaishouMonitorUrlCallbackReqUrl (
public CommonResponse < String > kuaishouMonitorUrlCallbackReqUrl (
@RequestParam ( value = "accountid" , defaultValue = "" ) String accountid ,
@RequestParam ( value = "aid" , defaultValue = "" ) String aid ,
@RequestParam ( value = "cid" , defaultValue = "" ) String cid ,
@ -268,24 +310,33 @@ public class MobileMonitorCallbackAPI {
@RequestParam ( value = "ua" , defaultValue = "" ) String ua ,
@RequestParam ( value = "csite" , defaultValue = "" ) String cSite ,
@RequestParam ( value = "model" , defaultValue = "" ) String model ,
@RequestParam ( value = "idfa" , defaultValue = "" ) String idfa ,
@RequestParam ( value = "ac_creative" , defaultValue = "" ) String acCreative ,
@RequestParam ( value = "tag" , defaultValue = "" ) String tag
) {
KuaiShouMobileMonitorCallbackRequestVO vo = new KuaiShouMobileMonitorCallbackRequestVO (
accountid , aid , cid , did , dName , imei , oaid , mac , androidid , os , ts , ip , ua , cSite , model , acCreative
accountid , aid , cid , did , dName , imei , oaid , mac , androidid , os , ts , ip , ua , cSite , model , acCreative , idfa
) ;
if ( ObjectUtil . isNull ( vo ) ) {
return CommonResponse . createByErrorMessage ( ResponseCode . EMPTY_ARGUMENT . getDesc ( ) ) ;
}
Set < String > modeByResource =
equipmentService . queryModeByResource ( DeliveryPlatformEnum . KS . getType ( ) ) ;
// 保存机型
if ( StringUtils . isNotBlank ( model ) & & ! modeByResource . contains ( model ) ) {
equipmentService . saveEquipmentBySource ( model , DeliveryPlatformEnum . KS . getType ( ) ) ;
}
// 保存数据
filterIdfa ( idfa , tag , DeliveryPlatformEnum . KS . getType ( ) ) ;
// 请求过滤规则,过滤掉不用的数据
if ( preRuleForReq ( vo ) ) {
log . error ( "================================= [not right imei data ,vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
log . error ( "================================= [not right imei data ,vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
return CommonResponse . createBySuccess ( ) ;
}
setTag ( tag , vo ) ;
log . info ( "================================= [one request comming, vivoMonitorUrlCallbackReqUrl|MobileMonitorCallbackAPI, vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
log . info ( "================================= [one request comming, vivoMonitorUrlCallbackReqUrl|MobileMonitorCallbackAPI, vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
KuaiShouBackdataDTO kuaiShouBackdataDTO = new KuaiShouBackdataDTO ( ) ;
KuaiShouBackdataConvert . voCovertToDTO ( vo , kuaiShouBackdataDTO ) ;
adOriginalityManageService . handleMonitorUrlCallbackDataThenSave3 ( ) ;
@ -317,7 +368,7 @@ public class MobileMonitorCallbackAPI {
* API 文 档 地 址 : https : //ad.vivo.com.cn/help?id=353
* /
@RequestMapping ( value = "/vivo/monitor" )
public CommonResponse vivoMonitorUrlCallbackReqUrl (
public CommonResponse < String > vivoMonitorUrlCallbackReqUrl (
@RequestParam ( value = "os" , defaultValue = "" ) String os ,
@RequestParam ( value = "imei" , defaultValue = "" ) String imei ,
@RequestParam ( value = "ip" , defaultValue = "" ) String ip ,
@ -347,13 +398,19 @@ public class MobileMonitorCallbackAPI {
if ( ObjectUtil . isNull ( vo ) ) {
return CommonResponse . createByErrorMessage ( ResponseCode . EMPTY_ARGUMENT . getDesc ( ) ) ;
}
Set < String > modeByResource =
equipmentService . queryModeByResource ( DeliveryPlatformEnum . VI . getType ( ) ) ;
// 保存机型
if ( StringUtils . isNotBlank ( model ) & & ! modeByResource . contains ( model ) ) {
equipmentService . saveEquipmentBySource ( model , DeliveryPlatformEnum . VI . getType ( ) ) ;
}
// 请求过滤规则,过滤掉不用的数据
if ( preRuleForReq ( vo ) ) {
log . error ( "================================= [not right imei data , vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
log . error ( "================================= [not right imei data , vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
return CommonResponse . createBySuccess ( ) ;
}
setTag ( tag , vo ) ;
log . info ( "================================= [one request comming, vivoMonitorUrlCallbackReqUrl|MobileMonitorCallbackAPI, vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
log . info ( "================================= [one request comming, vivoMonitorUrlCallbackReqUrl|MobileMonitorCallbackAPI, vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
VivoBackdataDTO vivoBackdataDTO = new VivoBackdataDTO ( ) ;
VivoBackdataConvert . voCovertToDTO ( vo , vivoBackdataDTO ) ;
adOriginalityManageService . handleMonitorUrlCallbackDataThenSave4 ( ) ;
@ -388,21 +445,19 @@ public class MobileMonitorCallbackAPI {
* 直 接 配 置 链 接 即 可 https : //cb.tuoz.net/vivo/monitor
* /
@PostMapping ( value = "/vivo/p/monitor" )
public CommonResponse vivoMonitorUrlCallbackReqUrl ( @RequestBody VivoMobileMonitorPointCallbackRequestVO vo ) {
public CommonResponse < String > vivoMonitorUrlCallbackReqUrl ( @RequestBody VivoMobileMonitorPointCallbackRequestVO vo ) {
// fixme 返回值是 code msg 0 操作成功
return CommonResponse . createBySuccess ( ) ;
}
/ * *
* 广 点 通 互 联 网 检 测
* < p >
* API 文 档 地 址 : https : //developers.e.qq.com/docs/guide/conversion/new_version/dianjijiance
* /
@RequestMapping ( value = "/gdt/monitor" )
public CommonResponse gdtMonitorUrlCallbackReqUrl (
public CommonResponse < String > gdtMonitorUrlCallbackReqUrl (
@RequestParam ( value = "click_id" , defaultValue = "" ) String clickId ,
@RequestParam ( value = "click_time" , defaultValue = "" ) String clickTime ,
@RequestParam ( value = "impression_time" , defaultValue = "" ) String impressionTime ,
@ -451,13 +506,24 @@ public class MobileMonitorCallbackAPI {
if ( ObjectUtil . isNull ( vo ) ) {
return CommonResponse . createByErrorMessage ( ResponseCode . EMPTY_ARGUMENT . getDesc ( ) ) ;
}
if ( IOS . equalsIgnoreCase ( deviceOsType )
& & ! CharSequenceUtil . equalsIgnoreCase ( MUID , muid ) ) {
// 保存数据
filterIdfa ( muid , tag , DeliveryPlatformEnum . GD . getType ( ) ) ;
}
Set < String > modeByResource =
equipmentService . queryModeByResource ( DeliveryPlatformEnum . GD . getType ( ) ) ;
// 保存机型
if ( StringUtils . isNotBlank ( model ) & & ! modeByResource . contains ( model ) ) {
equipmentService . saveEquipmentBySource ( model , DeliveryPlatformEnum . GD . getType ( ) ) ;
}
// 请求过滤规则,过滤掉不用的数据
if ( preRuleForReq ( vo ) ) {
log . error ( "================================= [gdtMonitorUrlCallbackReqUrl|MobileMonitorCallbackAPI, not right imei data ,{} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
log . error ( "================================= [gdtMonitorUrlCallbackReqUrl|MobileMonitorCallbackAPI, not right imei data ,{} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
return CommonResponse . createBySuccess ( ) ;
}
setTag ( tag , vo ) ;
log . info ( "================================= [one request comming, gdtMonitorUrlCallbackReqUrl|MobileMonitorCallbackAPI, vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
log . info ( "================================= [one request comming, gdtMonitorUrlCallbackReqUrl|MobileMonitorCallbackAPI, vo json is {} ] =================================" , JSONUtil . toJsonStr ( vo ) ) ;
GdtBackdataDTO dto = new GdtBackdataDTO ( ) ;
GdtBackdataConvert . voCovertToDTO ( vo , dto ) ;
adOriginalityManageService . handleMonitorUrlCallbackDataThenSave5 ( ) ;
@ -484,7 +550,6 @@ public class MobileMonitorCallbackAPI {
}
/ * *
* 进 行 特 殊 标 识 处 理
*
@ -499,4 +564,14 @@ public class MobileMonitorCallbackAPI {
}
}
private void filterIdfa ( String idfa , String tag , String type ) {
// 保存数据
if ( StringUtils . isNotBlank ( idfa )
& & ! CharSequenceUtil . equalsIgnoreCase ( IMEI_NULL_TAG , idfa )
& & ! CharSequenceUtil . equalsIgnoreCase ( IDFA_NUM , idfa )
& & ! CharSequenceUtil . equalsIgnoreCase ( IDFA_STR , idfa ) ) {
idfaService . saveData ( idfa , tag , type ) ;
}
}
}