package com.tzld.piaoquan.recommend.server.grpcservice;

import com.tzld.piaoquan.recommend.server.gen.recommend.RecommendRequest;
import com.tzld.piaoquan.recommend.server.gen.recommend.RecommendResponse;
import com.tzld.piaoquan.recommend.server.gen.recommend.RecommendServiceGrpc;
import com.tzld.piaoquan.recommend.server.service.RecommendService;
import io.grpc.stub.StreamObserver;
import net.devh.boot.grpc.server.service.GrpcService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author dyp
 */
@GrpcService
public class RecommendGrpcService extends RecommendServiceGrpc.RecommendServiceImplBase {
    @Autowired
    private RecommendService recommendService;

    @Override
    public void homepageRecommend(RecommendRequest request, StreamObserver<RecommendResponse> responseObserver) {
        RecommendResponse response = recommendService.homepageRecommend(request);
        responseObserver.onNext(response);
        responseObserver.onCompleted();
    }

    @Override
    public void relevantRecommend(RecommendRequest request, StreamObserver<RecommendResponse> responseObserver) {
        RecommendResponse response = recommendService.relevantRecommend(request);
        responseObserver.onNext(response);
        responseObserver.onCompleted();
    }
}
