dmp链接生成
parent
e4515af549
commit
608e26d60b
@ -0,0 +1,33 @@
|
|||||||
|
package com.baiyee.adcallback.api.controller;
|
||||||
|
|
||||||
|
import com.baiyee.adcallback.api.common.CommonResponse;
|
||||||
|
import com.baiyee.adcallback.service.GenerateService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/generate")
|
||||||
|
public class GenerateController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GenerateService generateService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成DMP链接
|
||||||
|
* @param tag
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/dmp")
|
||||||
|
public CommonResponse<String> generateDmp(@RequestParam("tag") String tag,@RequestParam("type") Integer type){
|
||||||
|
String dmp = generateService.generateDmp(tag, type);
|
||||||
|
if (dmp == null || StringUtils.isBlank(dmp)){
|
||||||
|
return CommonResponse.createByErrorMessage("暂不支持此类型");
|
||||||
|
}
|
||||||
|
return CommonResponse.createBySuccess(dmp);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2020 Zheng Jie
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.baiyee.adcallback.common.exception;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Zheng Jie
|
||||||
|
* @date 2018-11-23
|
||||||
|
* 统一异常处理
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public class BadRequestException extends RuntimeException{
|
||||||
|
|
||||||
|
private Integer status = BAD_REQUEST.value();
|
||||||
|
|
||||||
|
public BadRequestException(String msg){
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BadRequestException(HttpStatus status, String msg){
|
||||||
|
super(msg);
|
||||||
|
this.status = status.value();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.baiyee.adcallback.service;
|
||||||
|
|
||||||
|
|
||||||
|
public interface GenerateService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成DMP链接
|
||||||
|
* @param tag
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String generateDmp(String tag, Integer type);
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.baiyee.adcallback.service.impl;
|
||||||
|
|
||||||
|
import com.baiyee.adcallback.common.exception.BadRequestException;
|
||||||
|
import com.baiyee.adcallback.service.GenerateService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class GenerateServiceImpl implements GenerateService {
|
||||||
|
|
||||||
|
@Value("${generate.url}")
|
||||||
|
private String URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param tag
|
||||||
|
* @param type 0:巨量 1:百度 2:快手 3:UC 4:VIVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String generateDmp(String tag, Integer type) {
|
||||||
|
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 generateDmp;
|
||||||
|
switch (type){
|
||||||
|
case 0:
|
||||||
|
generateDmp = URL + JL + replaceTag;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
generateDmp = URL + BD +replaceTag;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
generateDmp = null;
|
||||||
|
}
|
||||||
|
return generateDmp;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue