package com.ywt.alipaympapi.core.configs;

import com.ywt.gapi.base.file.FileServiceGrpc;
import com.ywt.gapi.gateway.AuthServiceGrpc;
import com.ywt.gapi.message.MessageServiceGrpc;
import com.ywt.gapi.order.OrderServiceGrpc;
import com.ywt.gapi.ordercenter.OrderCenterServiceGrpc;
import com.ywt.gapi.system.SystemServiceGrpc;
import com.ywt.gapi.taihe.register.TaiheRegisterServiceGrpc;
import com.ywt.gapi.third.taihe.TaiheServiceGrpc;
import com.ywt.gapi.user.DoctorServiceGrpc;
import com.ywt.gapi.user.UserServiceGrpc;
import io.grpc.Channel;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class ServiceGrpcStubBeans {
    @Resource(name = "agentChannel")
    private Channel agentChannel;

    @Bean(name = "userServiceBlockingStub")
    public UserServiceGrpc.UserServiceBlockingStub getUserServiceBlockingStub() {
        UserServiceGrpc.UserServiceBlockingStub stub = UserServiceGrpc.newBlockingStub(agentChannel);
        return stub;
    }

    @Bean(name = "doctorServiceBlockingStub")
    public DoctorServiceGrpc.DoctorServiceBlockingStub getDoctorServiceBlockingStub() {
        DoctorServiceGrpc.DoctorServiceBlockingStub stub = DoctorServiceGrpc.newBlockingStub(agentChannel);
        return stub;
    }

    @Bean(name = "systemServiceBlockingStub")
    public SystemServiceGrpc.SystemServiceBlockingStub getSystemServiceBlockingStub() {
        SystemServiceGrpc.SystemServiceBlockingStub stub = SystemServiceGrpc.newBlockingStub(agentChannel);
        return stub;
    }

    @Bean(name = "orderServiceBlockingStub")
    public OrderServiceGrpc.OrderServiceBlockingStub getOrderServiceBlockingStub() {
        OrderServiceGrpc.OrderServiceBlockingStub stub = OrderServiceGrpc.newBlockingStub(agentChannel);
        return stub;
    }

    @Bean(name = "fileServiceBlockingStub")
    public FileServiceGrpc.FileServiceBlockingStub getFileServiceBlockingStub() {
        return FileServiceGrpc.newBlockingStub(agentChannel);
    }


    @Bean(name = "taiheServiceBlockingStub")
    public TaiheServiceGrpc.TaiheServiceBlockingStub getTaiheServiceBlockingStub() {
        return TaiheServiceGrpc.newBlockingStub(agentChannel);
    }

    @Bean(name = "authServiceBlockingStub")
    public AuthServiceGrpc.AuthServiceBlockingStub getAuthServiceBlockingStub() {
        return AuthServiceGrpc.newBlockingStub(agentChannel);
    }

    @Bean(name = "orderCenterServiceBlockingStub")
    public OrderCenterServiceGrpc.OrderCenterServiceBlockingStub getOrderCenterBlockingStub() {
        return OrderCenterServiceGrpc.newBlockingStub(agentChannel);
    }

    @Bean(name = "taiheRegisterServiceBlockingStub")
    public TaiheRegisterServiceGrpc.TaiheRegisterServiceBlockingStub getTaiheRegisterServiceBlockingStub() {
        return TaiheRegisterServiceGrpc.newBlockingStub(agentChannel);
    }

    @Bean(name = "messageServiceBlockingStub")
    public MessageServiceGrpc.MessageServiceBlockingStub getMessageServiceBlockingStub() {
        MessageServiceGrpc.MessageServiceBlockingStub stub = MessageServiceGrpc.newBlockingStub(agentChannel);
        return stub;
    }
}
