|
@@ -1,6 +1,7 @@
|
|
|
package com.tzld.piaoquan.recommend.feature.client;
|
|
|
|
|
|
-import com.tzld.piaoquan.recommend.feature.model.feature.FeatureServiceGrpc;
|
|
|
+import com.tzld.piaoquan.recommend.feature.model.feature.*;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import net.devh.boot.grpc.client.inject.GrpcClient;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -8,70 +9,42 @@ import org.springframework.stereotype.Component;
|
|
|
* @author dyp
|
|
|
*/
|
|
|
@Component
|
|
|
+@Slf4j
|
|
|
public class FeatureClient {
|
|
|
- @GrpcClient("recommend-server")
|
|
|
+ @GrpcClient("recommend-feature")
|
|
|
private FeatureServiceGrpc.FeatureServiceBlockingStub client;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ public UserFeatureProto getUserFeature(String uid) {
|
|
|
+ GetUserFeatureRequest request = GetUserFeatureRequest.newBuilder()
|
|
|
+ .setUid(uid)
|
|
|
+ .build();
|
|
|
+ GetUserFeatureResponse response = client.getUserFeature(request);
|
|
|
+ if (response == null || !response.hasResult()) {
|
|
|
+ log.info("getUserFeature grpc error");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (response.getResult().getCode() != 1) {
|
|
|
+ log.info("getUserFeature grpc code={}, msg={}", response.getResult().getCode(),
|
|
|
+ response.getResult().getMessage());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return response.getUserFeature();
|
|
|
+ }
|
|
|
+
|
|
|
+ public VideoFeatureProto getVideoFeature(Long videoId) {
|
|
|
+ GetVideoFeatureRequest request = GetVideoFeatureRequest.newBuilder()
|
|
|
+ .setVideoId(String.valueOf(videoId))
|
|
|
+ .build();
|
|
|
+ GetVideoFeatureResponse response = client.getVideoFeature(request);
|
|
|
+ if (response == null || !response.hasResult()) {
|
|
|
+ log.info("getVideoFeature grpc error");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (response.getResult().getCode() != 1) {
|
|
|
+ log.info("getVideoFeature grpc code={}, msg={}", response.getResult().getCode(),
|
|
|
+ response.getResult().getMessage());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return response.getVideoFeature();
|
|
|
+ }
|
|
|
}
|