DeliveryRuleServiceRpcClient.java 1.27 KB
package com.infoloop.tianting.service.client;

import com.infoloop.tianting.deliveryruleservice.ClientLabelTypeEnum;
import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcRequest;
import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcResponse;
import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc;
import com.infoloop.tianting.model.dto.ClientLabelDTO.QueryLabelsDto;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class DeliveryRuleServiceRpcClient {

  private final TiantingDeliveryRuleServiceRpcGrpc.TiantingDeliveryRuleServiceRpcBlockingStub
      deliveryRuleServiceRpcBlockingStub;

  public QueryClientLabelsByConditionRpcResponse getLabelsByType(QueryLabelsDto queryLabelsDto) {
    final var request = QueryClientLabelsByConditionRpcRequest.newBuilder()
        .setEnterpriseId(queryLabelsDto.getEnterpriseId())
        .setShouldFilterType(true)
        .setType(queryLabelsDto.getType())
        .setIncludeDeleted(false)
        .build();
    return deliveryRuleServiceRpcBlockingStub.queryClientLabelsByCondition(request);

  }
}