|
@@ -0,0 +1,277 @@
|
|
|
|
+package com.tzld.piaoquan.recommend.feature.service;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.tzld.piaoquan.recommend.feature.model.feature.GetUserFeatureInfo;
|
|
|
|
+import com.tzld.piaoquan.recommend.feature.model.feature.GetVideoFeatureInfo;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author sunxy
|
|
|
|
+ */
|
|
|
|
+public class UserAndVideoFeatureConverter {
|
|
|
|
+
|
|
|
|
+ public static GetUserFeatureInfo convertUserFeatureInfoToProto(JSONObject jsonObject) {
|
|
|
|
+ if (jsonObject == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ GetUserFeatureInfo.Builder builder = GetUserFeatureInfo.newBuilder();
|
|
|
|
+ if (jsonObject.containsKey("u1hour_exp_cnt")) {
|
|
|
|
+ builder.setU1HourExpCnt(jsonObject.getLong("u1hour_exp_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u1hour_click_cnt")) {
|
|
|
|
+ builder.setU1HourClickCnt(jsonObject.getLong("u1hour_click_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u1hour_share_cnt")) {
|
|
|
|
+ builder.setU1HourShareCnt(jsonObject.getLong("u1hour_share_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u1hour_return_cnt")) {
|
|
|
|
+ builder.setU1HourReturnCnt(jsonObject.getLong("u1hour_return_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_ctr1hour")) {
|
|
|
|
+ builder.setUCtr1Hour(jsonObject.getDouble("u_ctr1hour"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_str1hour")) {
|
|
|
|
+ builder.setUStr1Hour(jsonObject.getDouble("u_str1hour"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_rov1hour")) {
|
|
|
|
+ builder.setURov1Hour(jsonObject.getDouble("u_rov1hour"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_ros1hour")) {
|
|
|
|
+ builder.setURos1Hour(jsonObject.getDouble("u_ros1hour"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_today_exp_cnt")) {
|
|
|
|
+ builder.setUTodayExpCnt(jsonObject.getLong("u_today_exp_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_today_click_cnt")) {
|
|
|
|
+ builder.setUTodayClickCnt(jsonObject.getLong("u_today_click_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_today_share_cnt")) {
|
|
|
|
+ builder.setUTodayShareCnt(jsonObject.getLong("u_today_share_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_today_return_cnt")) {
|
|
|
|
+ builder.setUTodayReturnCnt(jsonObject.getLong("u_today_return_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_ctr_today")) {
|
|
|
|
+ builder.setUCtrToday(jsonObject.getDouble("u_ctr_today"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_str_today")) {
|
|
|
|
+ builder.setUStrToday(jsonObject.getDouble("u_str_today"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_rov_today")) {
|
|
|
|
+ builder.setURovToday(jsonObject.getDouble("u_rov_today"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_ros_today")) {
|
|
|
|
+ builder.setURosToday(jsonObject.getDouble("u_ros_today"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u1day_exp_cnt")) {
|
|
|
|
+ builder.setU1DayExpCnt(jsonObject.getLong("u1day_exp_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u1day_click_cnt")) {
|
|
|
|
+ builder.setU1DayClickCnt(jsonObject.getLong("u1day_click_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u1day_share_cnt")) {
|
|
|
|
+ builder.setU1DayShareCnt(jsonObject.getLong("u1day_share_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u1day_return_cnt")) {
|
|
|
|
+ builder.setU1DayReturnCnt(jsonObject.getLong("u1day_return_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_ctr1day")) {
|
|
|
|
+ builder.setUCtr1Day(jsonObject.getDouble("u_ctr1day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_str1day")) {
|
|
|
|
+ builder.setUStr1Day(jsonObject.getDouble("u_str1day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_rov1day")) {
|
|
|
|
+ builder.setURov1Day(jsonObject.getDouble("u_rov1day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_ros1day")) {
|
|
|
|
+ builder.setURos1Day(jsonObject.getDouble("u_ros1day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u3day_exp_cnt")) {
|
|
|
|
+ builder.setU3DayExpCnt(jsonObject.getLong("u3day_exp_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u3day_click_cnt")) {
|
|
|
|
+ builder.setU3DayClickCnt(jsonObject.getLong("u3day_click_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u3day_share_cnt")) {
|
|
|
|
+ builder.setU3DayShareCnt(jsonObject.getLong("u3day_share_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u3day_return_cnt")) {
|
|
|
|
+ builder.setU3DayReturnCnt(jsonObject.getLong("u3day_return_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_ctr3day")) {
|
|
|
|
+ builder.setUCtr3Day(jsonObject.getDouble("u_ctr3day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_str3day")) {
|
|
|
|
+ builder.setUStr3Day(jsonObject.getDouble("u_str3day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_rov3day")) {
|
|
|
|
+ builder.setURov3Day(jsonObject.getDouble("u_rov3day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("u_ros3day")) {
|
|
|
|
+ builder.setURos3Day(jsonObject.getDouble("u_ros3day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("mid")) {
|
|
|
|
+ builder.setMid(jsonObject.getString("mid"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("machineinfo_brand")) {
|
|
|
|
+ builder.setMachineinfoBrand(jsonObject.getString("machineinfo_brand"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("machineinfo_model")) {
|
|
|
|
+ builder.setMachineinfoModel(jsonObject.getString("machineinfo_model"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("machineinfo_system")) {
|
|
|
|
+ builder.setMachineinfoSystem(jsonObject.getString("machineinfo_system"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("machineinfo_platform")) {
|
|
|
|
+ builder.setMachineinfoPlatform(jsonObject.getString("machineinfo_platform"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return builder.build();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static GetVideoFeatureInfo convertVideoFeatureInfoToProtoVideo(JSONObject jsonObject) {
|
|
|
|
+ if (jsonObject == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ GetVideoFeatureInfo.Builder builder = GetVideoFeatureInfo.newBuilder();
|
|
|
|
+ if (jsonObject.containsKey("video_id")) {
|
|
|
|
+ builder.setVideoId(jsonObject.getLong("video_id"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("play_count_total")) {
|
|
|
|
+ builder.setPlayCountTotal(jsonObject.getLong("play_count_total"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("total_time")) {
|
|
|
|
+ builder.setTotalTime(jsonObject.getInteger("total_time"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("gmt_create")) {
|
|
|
|
+ builder.setGmtCreate(jsonObject.getString("gmt_create"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("uid")) {
|
|
|
|
+ builder.setUid(jsonObject.getLong("uid"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i15min_exp_cnt")) {
|
|
|
|
+ builder.setI15MinExpCnt(jsonObject.getLong("i15min_exp_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i15min_click_cnt")) {
|
|
|
|
+ builder.setI15MinClickCnt(jsonObject.getLong("i15min_click_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i15min_share_cnt")) {
|
|
|
|
+ builder.setI15MinShareCnt(jsonObject.getLong("i15min_share_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i15min_return_cnt")) {
|
|
|
|
+ builder.setI15MinReturnCnt(jsonObject.getLong("i15min_return_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_ctr15min")) {
|
|
|
|
+ builder.setICtr15Min(jsonObject.getDouble("i_ctr15min"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_str15min")) {
|
|
|
|
+ builder.setIStr15Min(jsonObject.getDouble("i_str15min"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_rov15min")) {
|
|
|
|
+ builder.setIRov15Min(jsonObject.getDouble("i_rov15min"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_ros15min")) {
|
|
|
|
+ builder.setIRos15Min(jsonObject.getDouble("i_ros15min"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i1hour_exp_cnt")) {
|
|
|
|
+ builder.setI1HourExpCnt(jsonObject.getLong("i1hour_exp_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i1hour_click_cnt")) {
|
|
|
|
+ builder.setI1HourClickCnt(jsonObject.getLong("i1hour_click_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i1hour_share_cnt")) {
|
|
|
|
+ builder.setI1HourShareCnt(jsonObject.getLong("i1hour_share_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i1hour_return_cnt")) {
|
|
|
|
+ builder.setI1HourReturnCnt(jsonObject.getLong("i1hour_return_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_ctr1hour")) {
|
|
|
|
+ builder.setICtr1Hour(jsonObject.getDouble("i_ctr1hour"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_str1hour")) {
|
|
|
|
+ builder.setIStr1Hour(jsonObject.getDouble("i_str1hour"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_rov1hour")) {
|
|
|
|
+ builder.setIRov1Hour(jsonObject.getDouble("i_rov1hour"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_ros1hour")) {
|
|
|
|
+ builder.setIRos1Hour(jsonObject.getDouble("i_ros1hour"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_today_exp_cnt")) {
|
|
|
|
+ builder.setITodayExpCnt(jsonObject.getLong("i_today_exp_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_today_click_cnt")) {
|
|
|
|
+ builder.setITodayClickCnt(jsonObject.getLong("i_today_click_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_today_share_cnt")) {
|
|
|
|
+ builder.setITodayShareCnt(jsonObject.getLong("i_today_share_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_today_return_cnt")) {
|
|
|
|
+ builder.setITodayReturnCnt(jsonObject.getLong("i_today_return_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_ctr_today")) {
|
|
|
|
+ builder.setICtrToday(jsonObject.getDouble("i_ctr_today"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_str_today")) {
|
|
|
|
+ builder.setIStrToday(jsonObject.getDouble("i_str_today"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_rov_today")) {
|
|
|
|
+ builder.setIRovToday(jsonObject.getDouble("i_rov_today"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_ros_today")) {
|
|
|
|
+ builder.setIRosToday(jsonObject.getDouble("i_ros_today"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i1day_exp_cnt")) {
|
|
|
|
+ builder.setI1DayExpCnt(jsonObject.getLong("i1day_exp_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i1day_click_cnt")) {
|
|
|
|
+ builder.setI1DayClickCnt(jsonObject.getLong("i1day_click_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i1day_share_cnt")) {
|
|
|
|
+ builder.setI1DayShareCnt(jsonObject.getLong("i1day_share_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i1day_return_cnt")) {
|
|
|
|
+ builder.setI1DayReturnCnt(jsonObject.getLong("i1day_return_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_ctr1day")) {
|
|
|
|
+ builder.setICtr1Day(jsonObject.getDouble("i_ctr1day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_str1day")) {
|
|
|
|
+ builder.setIStr1Day(jsonObject.getDouble("i_str1day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_rov1day")) {
|
|
|
|
+ builder.setIRov1Day(jsonObject.getDouble("i_rov1day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_ros1day")) {
|
|
|
|
+ builder.setIRos1Day(jsonObject.getDouble("i_ros1day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i3day_exp_cnt")) {
|
|
|
|
+ builder.setI3DayExpCnt(jsonObject.getLong("i3day_exp_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i3day_click_cnt")) {
|
|
|
|
+ builder.setI3DayClickCnt(jsonObject.getLong("i3day_click_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i3day_share_cnt")) {
|
|
|
|
+ builder.setI3DayShareCnt(jsonObject.getLong("i3day_share_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i3day_return_cnt")) {
|
|
|
|
+ builder.setI3DayReturnCnt(jsonObject.getLong("i3day_return_cnt"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_ctr3day")) {
|
|
|
|
+ builder.setICtr3Day(jsonObject.getDouble("i_ctr3day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_str3day")) {
|
|
|
|
+ builder.setIStr3Day(jsonObject.getDouble("i_str3day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_rov3day")) {
|
|
|
|
+ builder.setIRov3Day(jsonObject.getDouble("i_rov3day"));
|
|
|
|
+ }
|
|
|
|
+ if (jsonObject.containsKey("i_ros3day")) {
|
|
|
|
+ builder.setIRos3Day(jsonObject.getDouble("i_ros3day"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return builder.build();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|