ソースを参照

request context

丁云鹏 1 年間 前
コミット
f92ab5d099

+ 18 - 0
recommend-server-client/src/main/java/com/tzld/piaoquan/recommend/server/client/RecommendHttpRequest.java

@@ -13,7 +13,10 @@ public class RecommendHttpRequest {
     private int size;
     private int appType;
     private String cityCode;
+    private String city;
     private String provinceCode;
+    private String province;
+
     private List<String> abExpCodes;
     private Map<String, String> eventIdMap;
     private int versionAuditStatus;
@@ -116,4 +119,19 @@ public class RecommendHttpRequest {
         this.videoId = videoId;
     }
 
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getProvince() {
+        return province;
+    }
+
+    public void setProvince(String province) {
+        this.province = province;
+    }
 }

+ 16 - 16
recommend-server-client/src/main/java/com/tzld/piaoquan/recommend/server/gen/recommend/Recommend.java

@@ -46,27 +46,27 @@ public final class Recommend {
       "\n2com/tzld/piaoquan/recommend/server/rec" +
       "ommend.proto\032\031google/protobuf/any.proto\032" +
       "/com/tzld/piaoquan/recommend/server/comm" +
-      "on.proto\"\315\002\n\020RecommendRequest\022\022\n\nrequest" +
+      "on.proto\"\355\002\n\020RecommendRequest\022\022\n\nrequest" +
       "_id\030\001 \001(\t\022\013\n\003mid\030\002 \001(\t\022\013\n\003uid\030\003 \001(\t\022\014\n\004s" +
       "ize\030\004 \001(\005\022\020\n\010app_type\030\005 \001(\005\022\021\n\tcity_code" +
       "\030\006 \001(\t\022\025\n\rprovince_code\030\007 \001(\t\022\023\n\013ab_exp_" +
       "code\030\010 \003(\t\0220\n\010event_id\030\t \003(\0132\036.Recommend" +
       "Request.EventIdEntry\022\034\n\024version_audit_st" +
       "atus\030\n \001(\005\022\032\n\022recommend_trace_id\030\013 \001(\t\022\020" +
-      "\n\010video_id\030\014 \001(\003\032.\n\014EventIdEntry\022\013\n\003key\030" +
-      "\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"H\n\021RecommendRes" +
-      "ponse\022\027\n\006result\030\001 \001(\0132\007.Result\022\032\n\005video\030" +
-      "\002 \003(\0132\013.VideoProto\"\265\001\n\nVideoProto\022\020\n\010vid" +
-      "eo_id\030\001 \001(\003\022\021\n\trov_score\030\002 \001(\001\022\021\n\tpush_f" +
-      "rom\030\003 \001(\t\022\017\n\007ab_code\030\004 \001(\t\022\022\n\nsort_score" +
-      "\030\005 \001(\001\022\020\n\010position\030\006 \001(\005\022\021\n\tflow_pool\030\007 " +
-      "\001(\t\022\027\n\017is_in_flow_pool\030\010 \001(\005\022\014\n\004rand\030\t \001" +
-      "(\0012\212\001\n\020RecommendService\022:\n\021HomepageRecom" +
-      "mend\022\021.RecommendRequest\032\022.RecommendRespo" +
-      "nse\022:\n\021RelevantRecommend\022\021.RecommendRequ" +
-      "est\032\022.RecommendResponseB7\n0com.tzld.piao" +
-      "quan.recommend.server.gen.recommendP\001\210\001\001" +
-      "b\006proto3"
+      "\n\010video_id\030\014 \001(\003\022\014\n\004city\030\r \001(\t\022\020\n\010provin" +
+      "ce\030\016 \001(\t\032.\n\014EventIdEntry\022\013\n\003key\030\001 \001(\t\022\r\n" +
+      "\005value\030\002 \001(\t:\0028\001\"H\n\021RecommendResponse\022\027\n" +
+      "\006result\030\001 \001(\0132\007.Result\022\032\n\005video\030\002 \003(\0132\013." +
+      "VideoProto\"\265\001\n\nVideoProto\022\020\n\010video_id\030\001 " +
+      "\001(\003\022\021\n\trov_score\030\002 \001(\001\022\021\n\tpush_from\030\003 \001(" +
+      "\t\022\017\n\007ab_code\030\004 \001(\t\022\022\n\nsort_score\030\005 \001(\001\022\020" +
+      "\n\010position\030\006 \001(\005\022\021\n\tflow_pool\030\007 \001(\t\022\027\n\017i" +
+      "s_in_flow_pool\030\010 \001(\005\022\014\n\004rand\030\t \001(\0012\212\001\n\020R" +
+      "ecommendService\022:\n\021HomepageRecommend\022\021.R" +
+      "ecommendRequest\032\022.RecommendResponse\022:\n\021R" +
+      "elevantRecommend\022\021.RecommendRequest\032\022.Re" +
+      "commendResponseB7\n0com.tzld.piaoquan.rec" +
+      "ommend.server.gen.recommendP\001\210\001\001b\006proto3"
     };
     descriptor = com.google.protobuf.Descriptors.FileDescriptor
       .internalBuildGeneratedFileFrom(descriptorData,
@@ -79,7 +79,7 @@ public final class Recommend {
     internal_static_RecommendRequest_fieldAccessorTable = new
       com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
         internal_static_RecommendRequest_descriptor,
-        new java.lang.String[] { "RequestId", "Mid", "Uid", "Size", "AppType", "CityCode", "ProvinceCode", "AbExpCode", "EventId", "VersionAuditStatus", "RecommendTraceId", "VideoId", });
+        new java.lang.String[] { "RequestId", "Mid", "Uid", "Size", "AppType", "CityCode", "ProvinceCode", "AbExpCode", "EventId", "VersionAuditStatus", "RecommendTraceId", "VideoId", "City", "Province", });
     internal_static_RecommendRequest_EventIdEntry_descriptor =
       internal_static_RecommendRequest_descriptor.getNestedTypes().get(0);
     internal_static_RecommendRequest_EventIdEntry_fieldAccessorTable = new

+ 276 - 0
recommend-server-client/src/main/java/com/tzld/piaoquan/recommend/server/gen/recommend/RecommendRequest.java

@@ -23,6 +23,8 @@ private static final long serialVersionUID = 0L;
     provinceCode_ = "";
     abExpCode_ = com.google.protobuf.LazyStringArrayList.EMPTY;
     recommendTraceId_ = "";
+    city_ = "";
+    province_ = "";
   }
 
   @java.lang.Override
@@ -134,6 +136,18 @@ private static final long serialVersionUID = 0L;
             videoId_ = input.readInt64();
             break;
           }
+          case 106: {
+            java.lang.String s = input.readStringRequireUtf8();
+
+            city_ = s;
+            break;
+          }
+          case 114: {
+            java.lang.String s = input.readStringRequireUtf8();
+
+            province_ = s;
+            break;
+          }
           default: {
             if (!parseUnknownField(
                 input, unknownFields, extensionRegistry, tag)) {
@@ -581,6 +595,82 @@ private static final long serialVersionUID = 0L;
     return videoId_;
   }
 
+  public static final int CITY_FIELD_NUMBER = 13;
+  private volatile java.lang.Object city_;
+  /**
+   * <code>string city = 13;</code>
+   * @return The city.
+   */
+  @java.lang.Override
+  public java.lang.String getCity() {
+    java.lang.Object ref = city_;
+    if (ref instanceof java.lang.String) {
+      return (java.lang.String) ref;
+    } else {
+      com.google.protobuf.ByteString bs = 
+          (com.google.protobuf.ByteString) ref;
+      java.lang.String s = bs.toStringUtf8();
+      city_ = s;
+      return s;
+    }
+  }
+  /**
+   * <code>string city = 13;</code>
+   * @return The bytes for city.
+   */
+  @java.lang.Override
+  public com.google.protobuf.ByteString
+      getCityBytes() {
+    java.lang.Object ref = city_;
+    if (ref instanceof java.lang.String) {
+      com.google.protobuf.ByteString b = 
+          com.google.protobuf.ByteString.copyFromUtf8(
+              (java.lang.String) ref);
+      city_ = b;
+      return b;
+    } else {
+      return (com.google.protobuf.ByteString) ref;
+    }
+  }
+
+  public static final int PROVINCE_FIELD_NUMBER = 14;
+  private volatile java.lang.Object province_;
+  /**
+   * <code>string province = 14;</code>
+   * @return The province.
+   */
+  @java.lang.Override
+  public java.lang.String getProvince() {
+    java.lang.Object ref = province_;
+    if (ref instanceof java.lang.String) {
+      return (java.lang.String) ref;
+    } else {
+      com.google.protobuf.ByteString bs = 
+          (com.google.protobuf.ByteString) ref;
+      java.lang.String s = bs.toStringUtf8();
+      province_ = s;
+      return s;
+    }
+  }
+  /**
+   * <code>string province = 14;</code>
+   * @return The bytes for province.
+   */
+  @java.lang.Override
+  public com.google.protobuf.ByteString
+      getProvinceBytes() {
+    java.lang.Object ref = province_;
+    if (ref instanceof java.lang.String) {
+      com.google.protobuf.ByteString b = 
+          com.google.protobuf.ByteString.copyFromUtf8(
+              (java.lang.String) ref);
+      province_ = b;
+      return b;
+    } else {
+      return (com.google.protobuf.ByteString) ref;
+    }
+  }
+
   private byte memoizedIsInitialized = -1;
   @java.lang.Override
   public final boolean isInitialized() {
@@ -634,6 +724,12 @@ private static final long serialVersionUID = 0L;
     if (videoId_ != 0L) {
       output.writeInt64(12, videoId_);
     }
+    if (!getCityBytes().isEmpty()) {
+      com.google.protobuf.GeneratedMessageV3.writeString(output, 13, city_);
+    }
+    if (!getProvinceBytes().isEmpty()) {
+      com.google.protobuf.GeneratedMessageV3.writeString(output, 14, province_);
+    }
     unknownFields.writeTo(output);
   }
 
@@ -695,6 +791,12 @@ private static final long serialVersionUID = 0L;
       size += com.google.protobuf.CodedOutputStream
         .computeInt64Size(12, videoId_);
     }
+    if (!getCityBytes().isEmpty()) {
+      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(13, city_);
+    }
+    if (!getProvinceBytes().isEmpty()) {
+      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(14, province_);
+    }
     size += unknownFields.getSerializedSize();
     memoizedSize = size;
     return size;
@@ -734,6 +836,10 @@ private static final long serialVersionUID = 0L;
         .equals(other.getRecommendTraceId())) return false;
     if (getVideoId()
         != other.getVideoId()) return false;
+    if (!getCity()
+        .equals(other.getCity())) return false;
+    if (!getProvince()
+        .equals(other.getProvince())) return false;
     if (!unknownFields.equals(other.unknownFields)) return false;
     return true;
   }
@@ -774,6 +880,10 @@ private static final long serialVersionUID = 0L;
     hash = (37 * hash) + VIDEO_ID_FIELD_NUMBER;
     hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
         getVideoId());
+    hash = (37 * hash) + CITY_FIELD_NUMBER;
+    hash = (53 * hash) + getCity().hashCode();
+    hash = (37 * hash) + PROVINCE_FIELD_NUMBER;
+    hash = (53 * hash) + getProvince().hashCode();
     hash = (29 * hash) + unknownFields.hashCode();
     memoizedHashCode = hash;
     return hash;
@@ -952,6 +1062,10 @@ private static final long serialVersionUID = 0L;
 
       videoId_ = 0L;
 
+      city_ = "";
+
+      province_ = "";
+
       return this;
     }
 
@@ -996,6 +1110,8 @@ private static final long serialVersionUID = 0L;
       result.versionAuditStatus_ = versionAuditStatus_;
       result.recommendTraceId_ = recommendTraceId_;
       result.videoId_ = videoId_;
+      result.city_ = city_;
+      result.province_ = province_;
       onBuilt();
       return result;
     }
@@ -1092,6 +1208,14 @@ private static final long serialVersionUID = 0L;
       if (other.getVideoId() != 0L) {
         setVideoId(other.getVideoId());
       }
+      if (!other.getCity().isEmpty()) {
+        city_ = other.city_;
+        onChanged();
+      }
+      if (!other.getProvince().isEmpty()) {
+        province_ = other.province_;
+        onChanged();
+      }
       this.mergeUnknownFields(other.unknownFields);
       onChanged();
       return this;
@@ -1975,6 +2099,158 @@ private static final long serialVersionUID = 0L;
       onChanged();
       return this;
     }
+
+    private java.lang.Object city_ = "";
+    /**
+     * <code>string city = 13;</code>
+     * @return The city.
+     */
+    public java.lang.String getCity() {
+      java.lang.Object ref = city_;
+      if (!(ref instanceof java.lang.String)) {
+        com.google.protobuf.ByteString bs =
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        city_ = s;
+        return s;
+      } else {
+        return (java.lang.String) ref;
+      }
+    }
+    /**
+     * <code>string city = 13;</code>
+     * @return The bytes for city.
+     */
+    public com.google.protobuf.ByteString
+        getCityBytes() {
+      java.lang.Object ref = city_;
+      if (ref instanceof String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        city_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+    /**
+     * <code>string city = 13;</code>
+     * @param value The city to set.
+     * @return This builder for chaining.
+     */
+    public Builder setCity(
+        java.lang.String value) {
+      if (value == null) {
+    throw new NullPointerException();
+  }
+  
+      city_ = value;
+      onChanged();
+      return this;
+    }
+    /**
+     * <code>string city = 13;</code>
+     * @return This builder for chaining.
+     */
+    public Builder clearCity() {
+      
+      city_ = getDefaultInstance().getCity();
+      onChanged();
+      return this;
+    }
+    /**
+     * <code>string city = 13;</code>
+     * @param value The bytes for city to set.
+     * @return This builder for chaining.
+     */
+    public Builder setCityBytes(
+        com.google.protobuf.ByteString value) {
+      if (value == null) {
+    throw new NullPointerException();
+  }
+  checkByteStringIsUtf8(value);
+      
+      city_ = value;
+      onChanged();
+      return this;
+    }
+
+    private java.lang.Object province_ = "";
+    /**
+     * <code>string province = 14;</code>
+     * @return The province.
+     */
+    public java.lang.String getProvince() {
+      java.lang.Object ref = province_;
+      if (!(ref instanceof java.lang.String)) {
+        com.google.protobuf.ByteString bs =
+            (com.google.protobuf.ByteString) ref;
+        java.lang.String s = bs.toStringUtf8();
+        province_ = s;
+        return s;
+      } else {
+        return (java.lang.String) ref;
+      }
+    }
+    /**
+     * <code>string province = 14;</code>
+     * @return The bytes for province.
+     */
+    public com.google.protobuf.ByteString
+        getProvinceBytes() {
+      java.lang.Object ref = province_;
+      if (ref instanceof String) {
+        com.google.protobuf.ByteString b = 
+            com.google.protobuf.ByteString.copyFromUtf8(
+                (java.lang.String) ref);
+        province_ = b;
+        return b;
+      } else {
+        return (com.google.protobuf.ByteString) ref;
+      }
+    }
+    /**
+     * <code>string province = 14;</code>
+     * @param value The province to set.
+     * @return This builder for chaining.
+     */
+    public Builder setProvince(
+        java.lang.String value) {
+      if (value == null) {
+    throw new NullPointerException();
+  }
+  
+      province_ = value;
+      onChanged();
+      return this;
+    }
+    /**
+     * <code>string province = 14;</code>
+     * @return This builder for chaining.
+     */
+    public Builder clearProvince() {
+      
+      province_ = getDefaultInstance().getProvince();
+      onChanged();
+      return this;
+    }
+    /**
+     * <code>string province = 14;</code>
+     * @param value The bytes for province to set.
+     * @return This builder for chaining.
+     */
+    public Builder setProvinceBytes(
+        com.google.protobuf.ByteString value) {
+      if (value == null) {
+    throw new NullPointerException();
+  }
+  checkByteStringIsUtf8(value);
+      
+      province_ = value;
+      onChanged();
+      return this;
+    }
     @java.lang.Override
     public final Builder setUnknownFields(
         final com.google.protobuf.UnknownFieldSet unknownFields) {

+ 24 - 0
recommend-server-client/src/main/java/com/tzld/piaoquan/recommend/server/gen/recommend/RecommendRequestOrBuilder.java

@@ -173,4 +173,28 @@ public interface RecommendRequestOrBuilder extends
    * @return The videoId.
    */
   long getVideoId();
+
+  /**
+   * <code>string city = 13;</code>
+   * @return The city.
+   */
+  java.lang.String getCity();
+  /**
+   * <code>string city = 13;</code>
+   * @return The bytes for city.
+   */
+  com.google.protobuf.ByteString
+      getCityBytes();
+
+  /**
+   * <code>string province = 14;</code>
+   * @return The province.
+   */
+  java.lang.String getProvince();
+  /**
+   * <code>string province = 14;</code>
+   * @return The bytes for province.
+   */
+  com.google.protobuf.ByteString
+      getProvinceBytes();
 }

+ 2 - 0
recommend-server-client/src/main/proto/com/tzld/piaoquan/recommend/server/recommend.proto

@@ -21,6 +21,8 @@ message RecommendRequest {
   int32 version_audit_status = 10; // default 2
   string recommend_trace_id = 11;
   int64 video_id = 12;
+  string city = 13;
+  string province = 14;
 }
 
 // https://sls.console.aliyun.com/lognext/project/rov-server/logsearch/info

+ 6 - 4
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/web/RecommendController.java

@@ -34,9 +34,9 @@ public class RecommendController {
     }
 
     @RequestMapping("/homepage/recommend")
-    public String homepageRecommend(@RequestBody RecommendHttpRequest httpRequest) {
+    public String homepageRecommend(@RequestBody RecommendRequest httpRequest) {
         MDC.put("appType", String.valueOf(httpRequest.getAppType()));
-        RecommendResponse response = recommendService.homepageRecommend(generate(httpRequest));
+        RecommendResponse response = recommendService.homepageRecommend(httpRequest);
         String result = "";
         try {
             result = ProtobufUtils.toJson(response);
@@ -47,10 +47,10 @@ public class RecommendController {
     }
 
     @RequestMapping("/relevant/recommend")
-    public String relevantRecommend(@RequestBody RecommendHttpRequest httpRequest) {
+    public String relevantRecommend(@RequestBody RecommendRequest httpRequest) {
         MDC.put("appType", String.valueOf(httpRequest.getAppType()));
 
-        RecommendResponse response = recommendService.relevantRecommend(generate(httpRequest));
+        RecommendResponse response = recommendService.relevantRecommend(httpRequest);
         String result = "";
         try {
             result = ProtobufUtils.toJson(response);
@@ -75,6 +75,8 @@ public class RecommendController {
                 .setProvinceCode(Strings.nullToEmpty(httpRequest.getProvinceCode()))
                 .setVersionAuditStatus(httpRequest.getVersionAuditStatus())
                 .setRecommendTraceId(Strings.nullToEmpty(httpRequest.getRecommendTraceId()))
+                .setProvince(Strings.nullToEmpty(httpRequest.getProvince()))
+                .setCity(Strings.nullToEmpty(httpRequest.getCity()))
                 .setVideoId(httpRequest.getVideoId());
 
         if (CollectionUtils.isNotEmpty(httpRequest.getAbExpCodes())) {