添加机型认证 修改请求参数

master
bynt 2 years ago
parent 4b97a72be3
commit a3c305251c

@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import static com.baiyee.adcallback.common.constant.JuliangConstant.IMEI_TAG;
import static com.baiyee.adcallback.common.constant.DataConstant.IMEI_TAG;
/**
* juliangapi

@ -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);
}
}
}

@ -12,6 +12,11 @@ public class SqlConstant {
public static final String MUID_STR = "muid";
public static final String DELETE_STR = "DELETE FROM ";
public static final String WHERE_STR = " WHERE GMT_CREATE < :DATE ";
public static final String TABLE_STR = "tabIndex";

@ -33,5 +33,7 @@ public class KuaiShouMobileMonitorCallbackRequestVO extends MobileMonitorCallbac
private String cSite;
private String model;
private String acCreative;
private String idfa;
}

@ -24,4 +24,6 @@ public class UcMobileMonitorCallbackRequestVO extends MobileMonitorCallbackRequ
private String gid;
private String aid;
private String cid;
private String model;
private String idfa;
}

@ -6,7 +6,7 @@ package com.baiyee.adcallback.common.constant;
* @author q
* @date 2022/01/05
*/
public class JuliangConstant {
public class DataConstant {
/**
*
@ -33,5 +33,17 @@ public class JuliangConstant {
public static final String IMEI_NULL_TAG = "NULL";
public static final String IDFA_STR = "__IDFA__";
public static final String IOS = "IOS";
public static final String MUID = "__MUID__";
public static final String IDFA_NUM = "00000000-0000-0000-0000-000000000000";
}

@ -0,0 +1,30 @@
package com.baiyee.adcallback.repository;
import com.baiyee.adcallback.repository.entity.TbEquipmentEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.Map;
import java.util.Set;
/**
* @author Enzo
* @date 2023-2-28
*/
public interface TbEquipmentEntityRepository extends JpaRepository<TbEquipmentEntity, Long> {
/**
*
*
* @param sourceType
* @return
*/
@Query(value = "SELECT " +
" t.models "+
" FROM " +
" tb_equipment t" +
" WHERE " +
" t.data_source = ?1", nativeQuery = true)
Set<String> queryModelBySourceType(String sourceType);
}

@ -0,0 +1,14 @@
package com.baiyee.adcallback.repository;
import com.baiyee.adcallback.repository.entity.TbIDFAEntity;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @author Enzo
* @date 2023-2-28
*
*/
public interface TbIDFAEntityRepository extends JpaRepository<TbIDFAEntity, Long> {
}

@ -10,7 +10,6 @@ import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;
@Data
@Entity

@ -0,0 +1,48 @@
package com.baiyee.adcallback.repository.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author Enzo
* @date : 2023/2/28
*/
@Getter
@Setter
@Entity
@Table(name = "tb_equipment", schema = "db_ad")
@EntityListeners(AuditingEntityListener.class)
public class TbEquipmentEntity implements Serializable {
private static final long serialVersionUID = 6137554839655790811L;
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@Column(name = "id", nullable = false)
private long id;
@CreatedDate
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "gmt_create", nullable = false)
private Timestamp gmtCreate;
@Basic
@Column(name = "models", nullable = false)
private String models;
@Basic
@Column(name = "data_source", nullable = false)
private String dataSource;
}

@ -0,0 +1,56 @@
package com.baiyee.adcallback.repository.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author Enzo
* @date : 2023/2/28
*/
@Getter
@Setter
@Entity
@Table(name = "tb_idfa", schema = "db_ad")
@EntityListeners(AuditingEntityListener.class)
public class TbIDFAEntity implements Serializable {
private static final long serialVersionUID = 4232805678739238024L;
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@Column(name = "id", nullable = false)
private long id;
@CreatedDate
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "gmt_create", nullable = false)
private Timestamp gmtCreate;
@Basic
@Column(name = "idfa", nullable = false)
private String idfa;
@Basic
@Column(name = "tag", nullable = false)
private String tag;
@Basic
@Column(name = "use_type", nullable = false)
private Integer useType = 0;
@Basic
@Column(name = "data_source", nullable = false)
private String dataSource;
}

@ -0,0 +1,26 @@
package com.baiyee.adcallback.service;
import java.util.Set;
/**
* @author Enzo
* @date : 2023/2/28
*/
public interface EquipmentService {
/**
*
* @param sourceType
* @return
*/
Set<String> queryModeByResource(String sourceType);
/**
*
*
* @param model
* @param sourceType
* @return
*/
Boolean saveEquipmentBySource(String model, String sourceType);
}

@ -0,0 +1,15 @@
package com.baiyee.adcallback.service;
/**
* @author Enzo
* @date : 2023/2/28
*/
public interface IdfaService {
/**
*
* @param idfa
* @param tag
* @param type
*/
void saveData(String idfa, String tag, String type);
}

@ -0,0 +1,40 @@
package com.baiyee.adcallback.service.impl;
import com.baiyee.adcallback.repository.TbEquipmentEntityRepository;
import com.baiyee.adcallback.repository.entity.TbEquipmentEntity;
import com.baiyee.adcallback.service.EquipmentService;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.Set;
/**
* @author Enzo
* @date : 2023/2/28
*/
@Service
@RequiredArgsConstructor
public class EquipmentServiceImpl implements EquipmentService {
private final TbEquipmentEntityRepository equipmentEntityRepository;
@Override
@Cacheable(cacheNames = "ModelCacheByResource", key = "#sourceType")
public Set<String> queryModeByResource(String sourceType) {
return equipmentEntityRepository.queryModelBySourceType(sourceType);
}
@Override
@CacheEvict(cacheNames = "ModelCacheByResource", key = "#sourceType")
public Boolean saveEquipmentBySource(String model, String sourceType) {
TbEquipmentEntity tbEquipment = new TbEquipmentEntity();
tbEquipment.setModels(model);
tbEquipment.setDataSource(sourceType);
return equipmentEntityRepository.save(tbEquipment).getId() > 0;
}
}

@ -24,9 +24,9 @@ public class GenerateServiceImpl implements GenerateService {
String replaceTag = tag.replace(" ", "");
String JL = "/api/jl/monitor?aid=__AID__&cid=__CID__&ctype=__CTYPE__&csite=__CSITE__&imei=__IMEI__&idfa=__IDFA__&oaid=__OAID__&os=__OS__&mac=__MAC__&mac1=__MAC1__&ip=__IP__&geo=__GEO__&TIMESTAMP=__TS__&callback_url=__CALLBACK_URL__&model=__MODEL__&caid1=__CAID1__&tag=";
String BD = "/api/bd/monitor?userid=__USER_ID__&aid=__IDEA_ID__&pid=__PLAN_ID__&uid=__UNIT_ID__&callback_url=__CALLBACK_URL__&click_id=__CLICK_ID__&idfa=__IDFA__&imei_md5=__IMEI__&oaid=__OAID__&mac=__MAC__&ip=__IP__&os=__OS__&ts=__TS__&device_info=__DEVICE_INFO__&tag=";
String UC = "/api/uc/monitor?imei={IMEI_SUM1}&oaid={OAID}&time={TS}&callback={CALLBACK_URL}&androidid={ANDROIDID_SUM1}&mac={MAC_SUM2}&ip={IP}&ua={UA}&acid={ACID}&gid={GID}&aid={AID}&cid={CID}&tag=";
String GDT = "/api/gdt/monitor?click_id=__CLICK_ID__&click_time=__CLICK_TIME__&campaign_id=_CAMPAIGN_ID__&adgroup_id=__ADGROUP_ID__&ad_id=__AD_ID__&muid=__MUID__&hash_android_id=__HASH_ANDROID_ID__&oaid=__OAID__&hash_oaid=__HASH_OAID__&ip=__IP__&user_agent=__USER_AGENT__&account_id=__ACCOUNT_ID__&promoted_object_type=__PROMOTED_OBJECT_TYPE__&device_os_type=__DEVICE_OS_TYPE__&callback=__CALLBACK__&qz_gdt=__QZ_GDT__&tag=";
String KS = "/api/ks/monitor?&accountid=__ACCOUNTID__&aid=__AID__&cid=__CID__&did=__DID__&dname=__DNAME__&imeiMD5=__IMEI2__&oaid=__OAID__&mac=__MAC2__&androidid=__ANDROIDID2__&os=__OS__&ts=__TS__&ip=__IP__&ua=__UA__&csite=__CSITE__&model=__MODEL__&ac_creative=__AC_CREATIVE__&tag=";
String UC = "/api/uc/monitor?imei={IMEI_SUM1}&oaid={OAID}&time={TS}&callback={CALLBACK_URL}&androidid={ANDROIDID_SUM1}&mac={MAC_SUM2}&ip={IP}&ua={UA}&acid={ACID}&gid={GID}&aid={AID}&cid={CID}&model={MODEL1}&idfa={IDFA1}&tag=";
String GDT = "/api/gdt/monitor?click_id=__CLICK_ID__&click_time=__CLICK_TIME__&campaign_id=_CAMPAIGN_ID__&adgroup_id=__ADGROUP_ID__&ad_id=__AD_ID__&muid=__MUID__&hash_android_id=__HASH_ANDROID_ID__&oaid=__OAID__&hash_oaid=__HASH_OAID__&ip=__IP__&user_agent=__USER_AGENT__&account_id=__ACCOUNT_ID__&promoted_object_type=__PROMOTED_OBJECT_TYPE__&device_os_type=__DEVICE_OS_TYPE__&callback=__CALLBACK__&qz_gdt=__QZ_GDT__&model=__MODEL__&tag=";
String KS = "/api/ks/monitor?&accountid=__ACCOUNTID__&aid=__AID__&cid=__CID__&did=__DID__&dname=__DNAME__&imeiMD5=__IMEI2__&oaid=__OAID__&mac=__MAC2__&androidid=__ANDROIDID2__&os=__OS__&ts=__TS__&ip=__IP__&ua=__UA__&csite=__CSITE__&model=__MODEL__&ac_creative=__AC_CREATIVE__&idfa=__IDFA2__&tag=";
String VIVO = "/api/vivo/monitor?os=__OS__&imei=__IMEI__&ip=__IP__&oaid=__OAID__&oaidPlain=__OAIDPLAIN__&ua=__UA__&androidId=__ANDROIDID__&location=__LOCATION__&requestId=__REQUESTID__&requestTime=__REQUESTTIME__&advertiserId=__ADVERTISERID__&adName=__ADNAME__&creativeId=__CREATIVEID__&osVersion=__OSVERSION__&model=__MODEL__&lang=__LANG__&resolution=__RESOLUTION__&netType=__NETTYPE__&ts=__TS__&tag=";
String generateDmp;
switch (type){

@ -0,0 +1,30 @@
package com.baiyee.adcallback.service.impl;
import cn.hutool.core.text.CharSequenceUtil;
import com.baiyee.adcallback.repository.TbIDFAEntityRepository;
import com.baiyee.adcallback.repository.entity.TbIDFAEntity;
import com.baiyee.adcallback.service.IdfaService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
/**
* @author Enzo
* @date : 2023/2/28
*/
@Service
@RequiredArgsConstructor
public class IdfaServiceImpl implements IdfaService {
private final TbIDFAEntityRepository tbIDFAEntityRepository;
@Override
public void saveData(String idfa, String tag, String type) {
TbIDFAEntity entity = new TbIDFAEntity();
entity.setIdfa(idfa);
entity.setTag(StringUtils.isNotBlank(tag) ? tag : CharSequenceUtil.EMPTY);
entity.setDataSource(type);
tbIDFAEntityRepository.save(entity);
}
}

@ -4,7 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.baiyee.adcallback.api.constants.RequestInfoConstant;
import com.baiyee.adcallback.common.constant.JuliangConstant;
import com.baiyee.adcallback.common.constant.DataConstant;
import com.baiyee.adcallback.common.request.JuliangRequestParam;
import com.baiyee.adcallback.repository.entity.TbJlTokenEntity;
import com.baiyee.adcallback.service.TokenManageService;
@ -73,7 +73,7 @@ public class TokenManageServiceImpl implements TokenManageService {
// 发送获取 Access_Token 请求
String result = HttpRequest
.post(JuliangConstant.GET_ACCESS_TOKEN_URL)
.post(DataConstant.GET_ACCESS_TOKEN_URL)
.timeout(RequestInfoConstant.DEFAULT_TIMEOUT_NUMBER)
// 允许值1开启Debugger模式仅适用于接口测试使用不适合线上生产环境目前频控限制为20次/分钟建议在遇到调用接口报错后在header中传入此段以获取错误help message。
// .header(JuliangRequestHeader.X_Debug_Mode_NAME,JuliangRequestHeader.X_DEBUGMODE_VALUE,true)

@ -0,0 +1,72 @@
package com.baiyee.adcallback.task;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baiyee.adcallback.api.constants.SqlConstant;
import com.baiyee.adcallback.common.enums.TableEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.math.BigInteger;
/**
* @author Enzo
* @date : 2023/2/28
*/
@Slf4j
// @Component
public class DeleteDeliveryDataTask {
@PersistenceContext
private EntityManager entityManager;
/**
*
*/
@Scheduled(cron = "0 0 5 * * ?")
@Transactional(rollbackFor = Exception.class)
public void deleteDataTask() {
for (TableEnum value : TableEnum.values()) {
//数据中需要删除的数据量
long expiredCount;
// 已经删除数据量
long totalDeleted = 0L;
// 删除表
String tableName = value.getTableName();
// 时间偏移一个月
DateTime date = DateUtil.offsetMonth(DateUtil.date(), -1);
do {
Query deleteTagByQuery = entityManager.createNativeQuery
(SqlConstant.DELETE_STR
.concat(tableName)
.concat(SqlConstant.WHERE_STR)
.concat(" limit 50000"));
deleteTagByQuery.setParameter("DATE", date.toDateStr());
int executeUpdate = deleteTagByQuery.executeUpdate();
totalDeleted += executeUpdate;
expiredCount = queryCount(tableName, date);
} while (expiredCount > 0);
log.info("======== delete tag{} table size as [{}] ========", tableName, totalDeleted);
}
}
/**
*
*
* @param tableName
* @param date
* @return
*/
private Long queryCount(String tableName, DateTime date) {
String sql = "select count(1) FROM " + tableName + " where gmt_create < :date ";
Query selectQueryCount = entityManager.createNativeQuery(sql);
selectQueryCount.setParameter("date", date.toDateStr());
BigInteger bigInteger = (BigInteger) selectQueryCount.getSingleResult();
return bigInteger.longValue();
}
}

@ -1,13 +1,6 @@
package com.baiyee.adcallback.task;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.baiyee.adcallback.api.constants.RequestInfoConstant;
import com.baiyee.adcallback.common.constant.JuliangConstant;
import com.baiyee.adcallback.common.request.JuliangRequestParam;
import com.baiyee.adcallback.repository.entity.TbJlTokenEntity;
import com.baiyee.adcallback.service.TokenManageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;

@ -0,0 +1,63 @@
package com.baiyee.adcallback;
import cn.hutool.core.text.csv.CsvData;
import cn.hutool.core.text.csv.CsvReader;
import cn.hutool.core.text.csv.CsvUtil;
import com.baiyee.adcallback.common.enums.DeliveryPlatformEnum;
import com.baiyee.adcallback.repository.TbEquipmentEntityRepository;
import com.baiyee.adcallback.repository.entity.TbEquipmentEntity;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.io.File;
import java.util.List;
/**
* @author Enzo
* @date : 2023/3/1
*/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = AdCallbackApplication.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class TbEquipmentTest {
@Resource
private TbEquipmentEntityRepository tbEquipmentEntityRepository;
@Test
public void getSetting() {
File file = new File("C:\\Users\\a\\Desktop\\1.csv");
List<String> stringList = Lists.newArrayList();
List<TbEquipmentEntity> list = Lists.newArrayList();
CsvReader reader = CsvUtil.getReader();
// 解析文件
CsvData data = reader.read(file);
data.getRows().forEach(clue -> stringList.add
(clue.get(0)));
for (String s : stringList) {
TbEquipmentEntity equipment = new TbEquipmentEntity();
if (StringUtils.isNotBlank(s)){
equipment.setModels(s);
equipment.setDataSource(DeliveryPlatformEnum.VI.getType());
list.add(equipment);
}
}
tbEquipmentEntityRepository.saveAll(list);
}
}
Loading…
Cancel
Save