DeliveryRuleServiceRpcClient.java
1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.infoloop.tianting.service.client;
import com.infoloop.tianting.deliveryruleservice.ClientLabelTypeEnum;
import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcRequest;
import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcResponse;
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 java.util.List;
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 getLabelsByTypes(QueryLabelsDto queryLabelsDto) {
final var request = QueryClientLabelsByConditionRpcRequest.newBuilder()
.setEnterpriseId(queryLabelsDto.getEnterpriseId())
.setShouldFilterTypes(true)
.addAllTypes(queryLabelsDto.getTypes())
.setIncludeDeleted(false)
.build();
return deliveryRuleServiceRpcBlockingStub.queryClientLabelsByCondition(request);
}
public GetClientLabelsByIdsRpcResponse GetClientLabelsByIds(Integer enterpriseId, List<Integer> ids) {
final var request = GetClientLabelsByIdsRpcRequest
.newBuilder()
.setEnterpriseId(enterpriseId)
.setIncludeDeleted(false)
.addAllIds(ids)
.build();
return deliveryRuleServiceRpcBlockingStub.getClientLabelsByIds(request);
}
}