|
@@ -0,0 +1,125 @@
|
|
|
+//package com.tzld.piaoquan.ad.engine.service.score;
|
|
|
+//
|
|
|
+//import com.tzld.piaoquan.ad.engine.commons.base.AdActionFeature;
|
|
|
+//import com.tzld.piaoquan.ad.engine.commons.base.UserAdFeature;
|
|
|
+//import com.tzld.piaoquan.recommend.feature.client.FeatureClient;
|
|
|
+//import com.tzld.piaoquan.recommend.feature.model.feature.UserActionFeatureProto;
|
|
|
+//import com.tzld.piaoquan.recommend.feature.model.feature.UserFeatureProto;
|
|
|
+//import com.tzld.piaoquan.recommend.feature.model.feature.VideoFeatureProto;
|
|
|
+//import lombok.extern.slf4j.Slf4j;
|
|
|
+//import org.apache.commons.lang.StringUtils;
|
|
|
+//import org.apache.commons.lang.math.NumberUtils;
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+//import org.springframework.stereotype.Component;
|
|
|
+//import org.springframework.util.CollectionUtils;
|
|
|
+//
|
|
|
+//import java.util.Collections;
|
|
|
+//import java.util.List;
|
|
|
+//import java.util.Map;
|
|
|
+//
|
|
|
+//
|
|
|
+///**
|
|
|
+// * @author dyp
|
|
|
+// */
|
|
|
+//@Component
|
|
|
+//@Slf4j
|
|
|
+//public class FeatureRemoteService {
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private FeatureClient client;
|
|
|
+//
|
|
|
+// // 有性能问题再增加localCache
|
|
|
+// public UserAdFeature getUserFeature(String uid) {
|
|
|
+// if (StringUtils.isBlank(uid)) {
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+// UserFeatureProto proto = client.getUserFeature(uid);
|
|
|
+// UserAdFeature adFeature=convert(proto);
|
|
|
+//
|
|
|
+// return convert(proto);
|
|
|
+// }
|
|
|
+//
|
|
|
+// private UserAdFeature convert(UserFeatureProto proto) {
|
|
|
+// if (proto == null) {
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+// UserAdFeature feature = new UserAdFeature();
|
|
|
+// //todo
|
|
|
+// feature.setUser_type(proto.getUid());
|
|
|
+// if (proto.hasDay1CntFeature()) {
|
|
|
+// feature.setDay1_cnt_features(convert(proto.getDay1CntFeature()));
|
|
|
+// }
|
|
|
+// if (proto.hasDay3CntFeature()) {
|
|
|
+// feature.setDay3_cnt_features(convert(proto.getDay3CntFeature()));
|
|
|
+// }
|
|
|
+// if (proto.hasDay7CntFeature()) {
|
|
|
+// feature.setDay7_cnt_features(convert(proto.getDay7CntFeature()));
|
|
|
+// }
|
|
|
+// if (proto.hasMonth3CntFeature()) {
|
|
|
+// feature.setMonth3_cnt_features(convert(proto.getMonth3CntFeature()));
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// return feature;
|
|
|
+// }
|
|
|
+//
|
|
|
+// private AdActionFeature convert(UserActionFeatureProto proto) {
|
|
|
+// AdActionFeature feature = new AdActionFeature();
|
|
|
+// feature.setAdView(proto.get());
|
|
|
+// feature.setCtr(proto.getCtr());
|
|
|
+// feature.setExp_cnt(proto.getExpCnt());
|
|
|
+// feature.setReturn_cnt(proto.getReturnCnt());
|
|
|
+// feature.setRov(proto.getRov());
|
|
|
+// feature.setShare_cnt(proto.getShareCnt());
|
|
|
+// feature.setStr(proto.getStr());
|
|
|
+// return feature;
|
|
|
+// }
|
|
|
+//
|
|
|
+// public ItemFeature getVideoFeature(Long videoId) {
|
|
|
+// if (videoId == null) {
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+// VideoFeatureProto proto = client.getVideoFeature(videoId);
|
|
|
+// return convert(proto);
|
|
|
+// }
|
|
|
+//
|
|
|
+// public Map<Long, ItemFeature> getVideoFeatureMap(List<Long> videoIds) {
|
|
|
+// if (CollectionUtils.isEmpty(videoIds)) {
|
|
|
+// return Collections.emptyMap();
|
|
|
+// }
|
|
|
+// List<VideoFeatureProto> protoList = client.getAllVideoFeature(videoIds);
|
|
|
+// return CommonCollectionUtils.toMap(protoList, p -> NumberUtils.toLong(p.getVideoId(), 0L), this::convert);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// private ItemFeature convert(VideoFeatureProto proto) {
|
|
|
+// if (proto == null) {
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+// ItemFeature feature = new ItemFeature();
|
|
|
+//
|
|
|
+// feature.setPlayLength(proto.getPlayLength());
|
|
|
+// feature.setTags(proto.getTags());
|
|
|
+// feature.setTotalTime(proto.getTotalTime());
|
|
|
+// feature.setUpId(proto.getUpId());
|
|
|
+// feature.setVideoId(proto.getVideoId());
|
|
|
+// feature.setDaysSinceUpload(proto.getDaysSinceUpload());
|
|
|
+//
|
|
|
+//
|
|
|
+// if (proto.hasVideoDay1CntFeature()) {
|
|
|
+// feature.setDay1_cnt_features(convert(proto.getVideoDay1CntFeature()));
|
|
|
+// }
|
|
|
+// if (proto.hasVideoDay3CntFeature()) {
|
|
|
+// feature.setDay3_cnt_features(convert(proto.getVideoDay3CntFeature()));
|
|
|
+// }
|
|
|
+// if (proto.hasVideoDay7CntFeature()) {
|
|
|
+// feature.setDay7_cnt_features(convert(proto.getVideoDay7CntFeature()));
|
|
|
+// }
|
|
|
+// if (proto.hasVideoMonth3CntFeature()) {
|
|
|
+// feature.setMonth3_cnt_features(convert(proto.getVideoMonth3CntFeature()));
|
|
|
+// }
|
|
|
+// return feature;
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+//}
|