|
@@ -1,12 +1,17 @@
|
|
|
package com.tzld.piaoquan.ad.engine.server.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
import com.tzld.piaoquan.ad.engine.commons.dto.AdPlatformCreativeDTO;
|
|
|
import com.tzld.piaoquan.ad.engine.commons.enums.GuaranteedTypeEnum;
|
|
|
+import com.tzld.piaoquan.ad.engine.commons.param.LayerParam;
|
|
|
import com.tzld.piaoquan.ad.engine.commons.param.RankRecommendRequestParam;
|
|
|
+import com.tzld.piaoquan.ad.engine.commons.redis.AlgorithmRedisHelper;
|
|
|
import com.tzld.piaoquan.ad.engine.service.score.RankService;
|
|
|
import com.tzld.piaoquan.ad.engine.service.score.deprecated.BidRankRecommendRequestParam;
|
|
|
import com.tzld.piaoquan.recommend.feature.domain.ad.base.AdRankItem;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -28,6 +33,9 @@ public class AdRecommendController {
|
|
|
@Qualifier("rankServiceImpl")
|
|
|
RankService rankService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ protected AlgorithmRedisHelper algRedisHelper;
|
|
|
+
|
|
|
@RequestMapping("/top1/basic")
|
|
|
public Map<String, Object> adRecommendTop1Basic(@RequestBody RankRecommendRequestParam request) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
@@ -107,4 +115,40 @@ public class AdRecommendController {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping("/layer")
|
|
|
+ public Map<String, Object> getMidWithLayer(@RequestBody LayerParam request) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ if (request == null || StringUtils.isEmpty(request.getMid())) {
|
|
|
+ map.put("code", "1");
|
|
|
+ map.put("msg", "mid is null");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ map.put("code", "0");
|
|
|
+ map.put("msg", "success");
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ map.put("content", result);
|
|
|
+ String key = String.format("ad:engine:mid:layer:%s", request.getMid());
|
|
|
+ String value = algRedisHelper.get(key);
|
|
|
+ if (StringUtils.isEmpty(value)) {
|
|
|
+ result.put("layer", "无曝光");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ Map<String, String> layerMap = JSON.parseObject(value, new TypeReference<Map<String, String>>() {
|
|
|
+ });
|
|
|
+ String layer = layerMap.getOrDefault("layer", "无曝光");
|
|
|
+ if (Objects.equals(layer, "已转化")) {
|
|
|
+ layer = "有转化";
|
|
|
+ }
|
|
|
+ result.put("layer", layer);
|
|
|
+ return map;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("getMidWithLayer error. mid: {}, \n", request.getMid(), e);
|
|
|
+ map.put("code", "1");
|
|
|
+ map.put("msg", "get mid layer error");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|