Commit c9e6cc6b authored by 宋新宇's avatar 宋新宇

md5

parent 8fb2d748
......@@ -50,6 +50,10 @@ public class ClickbackService extends ServiceHelper{
@Resource(name = "storyKafka")
public KafkaTemplate<String, String> storyKafkaTemplate;
private static final String UAPRE = "Mozilla/5.0 (iPhone; CPU iPhone OS ";
private static final String UASUF = " like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148";
@RequestMapping("/jrtt")
@ResponseBody
......@@ -62,19 +66,19 @@ public class ClickbackService extends ServiceHelper{
DeliveryDeviceInfo ddi = action.getDeliveryDeviceInfo();
if (StringUtils.isNotEmpty(ddi.getDj_channel())) {
redisTemplate.opsForValue().set(CacheKeyUtils.getChannelByDeviceIdKeyAndPlatformId(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(Integer.parseInt(ddi.getDj_channel())), bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getChannelByDeviceIdKeyAndPlatformId(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(Integer.parseInt(ddi.getDj_channel())), bookIdExpireTime, TimeUnit.SECONDS);
if (StringUtils.isNumeric(ddi.getBook_id())) {
redisTemplate.opsForValue().set(CacheKeyUtils.getDeliveryBookIdCacheKey(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(ddi.getBook_id()), bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getDeliveryBookIdCacheKey(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(ddi.getBook_id()), bookIdExpireTime, TimeUnit.SECONDS);
if (StringUtils.isNumeric(ddi.getPartId())) {
redisTemplate.opsForValue().set(CacheKeyUtils.getDeliveryPartIdCacheKey(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(ddi.getPartId()), bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getDeliveryPartIdCacheKey(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(ddi.getPartId()), bookIdExpireTime, TimeUnit.SECONDS);
}
}
}
if (type == DeviceType.IP) {
redisTemplate.opsForValue().set(CacheKeyUtils.getClickKey(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(ddi),bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getClickKey(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(ddi),bookIdExpireTime, TimeUnit.SECONDS);
} else {
redisTemplate.opsForValue().set(CacheKeyUtils.getClickKeyByIdfaAndPlatformId(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(ddi),bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getClickKeyByIdfaAndPlatformId(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(ddi),bookIdExpireTime, TimeUnit.SECONDS);
}
}
}
......@@ -95,19 +99,19 @@ public class ClickbackService extends ServiceHelper{
DeliveryDeviceInfo ddi = action.getDeliveryDeviceInfo();
if (StringUtils.isNotEmpty(ddi.getDj_channel())) {
redisTemplate.opsForValue().set(CacheKeyUtils.getChannelByDeviceIdKeyAndPlatformId(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(Integer.parseInt(ddi.getDj_channel())), bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getChannelByDeviceIdKeyAndPlatformId(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(Integer.parseInt(ddi.getDj_channel())), bookIdExpireTime, TimeUnit.SECONDS);
if (StringUtils.isNumeric(ddi.getBook_id())) {
redisTemplate.opsForValue().set(CacheKeyUtils.getDeliveryBookIdCacheKey(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(ddi.getBook_id()), bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getDeliveryBookIdCacheKey(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(ddi.getBook_id()), bookIdExpireTime, TimeUnit.SECONDS);
if (StringUtils.isNumeric(ddi.getPartId())) {
redisTemplate.opsForValue().set(CacheKeyUtils.getDeliveryPartIdCacheKey(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(ddi.getPartId()), bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getDeliveryPartIdCacheKey(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(ddi.getPartId()), bookIdExpireTime, TimeUnit.SECONDS);
}
}
}
if (type == DeviceType.IP) {
redisTemplate.opsForValue().set(CacheKeyUtils.getClickKey(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(ddi),bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getClickKey(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(ddi),bookIdExpireTime, TimeUnit.SECONDS);
} else {
redisTemplate.opsForValue().set(CacheKeyUtils.getClickKeyByIdfaAndPlatformId(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(ddi),bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getClickKeyByIdfaAndPlatformId(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(ddi),bookIdExpireTime, TimeUnit.SECONDS);
}
}
}
......@@ -127,19 +131,19 @@ public class ClickbackService extends ServiceHelper{
DeliveryDeviceInfo ddi = action.getDeliveryDeviceInfo();
if (StringUtils.isNotEmpty(ddi.getDj_channel())) {
redisTemplate.opsForValue().set(CacheKeyUtils.getChannelByDeviceIdKeyAndPlatformId(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(Integer.parseInt(ddi.getDj_channel())), bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getChannelByDeviceIdKeyAndPlatformId(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(Integer.parseInt(ddi.getDj_channel())), bookIdExpireTime, TimeUnit.SECONDS);
if (StringUtils.isNumeric(ddi.getVideoResourceId())) {
redisTemplate.opsForValue().set(CacheKeyUtils.getDeliveryVRIdCacheKey(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(ddi.getVideoResourceId()), bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getDeliveryVRIdCacheKey(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(ddi.getVideoResourceId()), bookIdExpireTime, TimeUnit.SECONDS);
if (StringUtils.isNumeric(ddi.getVideoId())) {
redisTemplate.opsForValue().set(CacheKeyUtils.getDeliveryVIIdCacheKey(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(ddi.getVideoId()), bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getDeliveryVIIdCacheKey(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(ddi.getVideoId()), bookIdExpireTime, TimeUnit.SECONDS);
}
}
}
if (type == DeviceVideoType.IDFA) {
redisTemplate.opsForValue().set(CacheKeyUtils.getClickKey(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(ddi),bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getClickKey(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(ddi),bookIdExpireTime, TimeUnit.SECONDS);
} else {
redisTemplate.opsForValue().set(CacheKeyUtils.getClickKeyByIdfaAndPlatformId(assembleKey(deviceIdKey,type), ddi.getPlatform_id()),JSON.toJSONString(ddi),bookIdExpireTime, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CacheKeyUtils.getClickKeyByIdfaAndPlatformId(deviceIdKey, ddi.getPlatform_id()),JSON.toJSONString(ddi),bookIdExpireTime, TimeUnit.SECONDS);
}
}
}
......@@ -152,8 +156,6 @@ public class ClickbackService extends ServiceHelper{
public NovelAction fullJrtt(Map<String, String> params) {
ClientInfo clientInfo = new ClientInfo();
//imeiMd5
clientInfo.setImei(params.get("imei"));
clientInfo.setOaid(params.get("oaid_md5"));
clientInfo.setIdfa(params.get("idfaMd5"));
clientInfo.setClientIp(params.get("ip"));
......@@ -184,8 +186,6 @@ public class ClickbackService extends ServiceHelper{
public NovelAction fullJrttFreeVideo(Map<String, String> params) {
ClientInfo clientInfo = new ClientInfo();
//imeiMd5
clientInfo.setImei(params.get("imei"));
clientInfo.setOaid(params.get("oaid_md5"));
String idfa = params.get("idfa");
if (!filter.contains(idfa) && StringUtils.isNotEmpty(idfa)) {
......@@ -249,12 +249,11 @@ public class ClickbackService extends ServiceHelper{
}
enum DeviceType {
IMEI("imei",(c) -> isNotEmptyAndSNull(c.getImei())?c.getImei():null),
OAID("oaid", (c) -> isNotEmptyAndSNull(c.getOaid())?c.getOaid():null),
IDFA("idfa",(c) -> isNotEmptyAndSNull(c.getIdfa())?c.getIdfa():null),
IP_UA("ipua",(c) -> isNotEmptyAndSNull(c.getClientIp()) && isNotEmptyAndSNull(c.getUa())?c.getClientIp().concat(StringUtils.substringBefore(c.getUa(), " Chrome/")):null),
IP_MODEL("ipmodel",(c) -> isNotEmptyAndSNull(c.getClientIp()) && isNotEmptyAndSNull(c.getPhoneModel())?c.getClientIp().concat(c.getPhoneModel()):null),
IP("ip",(c) -> isNotEmptyAndSNull(c.getClientIp())?c.getClientIp():null);
IP_UA("ipua",(c) -> isNotEmptyAndSNull(c.getClientIp()) && isNotEmptyAndSNull(c.getUa())?SecureUtil.md5(c.getClientIp().concat(StringUtils.substringBefore(c.getUa(), " Chrome/"))):null),
IP_MODEL("ipmodel",(c) -> isNotEmptyAndSNull(c.getClientIp()) && isNotEmptyAndSNull(c.getPhoneModel())?SecureUtil.md5(c.getClientIp().concat(c.getPhoneModel())):null),
IP("ip",(c) -> isNotEmptyAndSNull(c.getClientIp())?SecureUtil.md5(c.getClientIp()):null);
private String value;
......@@ -283,9 +282,9 @@ public class ClickbackService extends ServiceHelper{
IDFA("idfa",(c) -> isNotEmptyAndSNull(c.getIdfa())?c.getIdfa():null),
IP_UA("ipua",(c) ->
(isNotEmptyAndSNull(c.getClientIp()) && isNotEmptyAndSNull(c.getUa())) ?
(("0".equals(c.getOs()) ? c.getClientIp().concat(StringUtils.substringBefore(c.getUa(), " Chrome/")) :
( c.getUa().startsWith("bi kan duan ju") ? Arrays.stream(c.getSystemVersion().split("\\.")).collect(Collectors.joining("_")):
c.getClientIp().concat(c.getUa())))):null),
(("0".equals(c.getOs()) ? SecureUtil.md5(c.getClientIp().concat(StringUtils.substringBefore(c.getUa(), " Chrome/"))) :
( c.getUa().startsWith("bi kan duan ju") ? SecureUtil.md5(c.getClientIp().concat(UAPRE + Arrays.stream(c.getSystemVersion().split("\\.")).collect(Collectors.joining("_")) + UASUF)):
SecureUtil.md5(c.getClientIp().concat(c.getUa()))))):null),
IP_MODEL("ipmodel",(c) -> isNotEmptyAndSNull(c.getClientIp()) && isNotEmptyAndSNull(c.getPhoneModel())?c.getClientIp().concat(c.getPhoneModel()):null);
private String value;
......
......@@ -27,32 +27,6 @@ public class ServiceHelper {
}
}
public String assembleKey(String deviceId, ClickbackService.DeviceType type) {
switch (type) {
case IMEI:
case OAID:
case IDFA:
return deviceId;
case IP_UA:
case IP_MODEL:
case IP:
return SecureUtil.md5(deviceId);
}
return null;
}
public String assembleKey(String deviceId, ClickbackService.DeviceVideoType type) {
switch (type) {
case OAID:
case IDFA:
return deviceId;
case IP_UA:
case IP_MODEL:
return SecureUtil.md5(deviceId);
}
return null;
}
public String getModelByUa(String ua) {
String uasplit = ua.split("Build")[0];
String model = 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