ClientCustomerServiceRpcClient.java
5.98 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.infoloop.tianting.service.client;
import com.infoloop.tianting.clientcustomerservice.BatchCreateClientCustomerLabelRefsRpcRequest;
import com.infoloop.tianting.clientcustomerservice.BatchCreateClientCustomerLabelRefsRpcResponse;
import com.infoloop.tianting.clientcustomerservice.ClientCustomerLabelRefCreation;
import com.infoloop.tianting.clientcustomerservice.ClientCustomerServiceRpcGrpc;
import com.infoloop.tianting.clientcustomerservice.DeleteClientCustomerLabelRefsByIdsRpcRequest;
import com.infoloop.tianting.clientcustomerservice.DeleteClientCustomerLabelRefsRpcResponse;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByHISCustomerIdRpcRequest;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByHISCustomerIdRpcResponse;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByIdRpcRequest;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByIdRpcResponse;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByMobileRpcRequest;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByMobileRpcResponse;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerHospitalRecordByCustomerIdRpcRequest;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerHospitalRecordByCustomerIdRpcResponse;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomersByIdsRpcRequest;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomersByIdsRpcResponse;
import com.infoloop.tianting.clientcustomerservice.QueryClientCustomerLabelRefsByConditionRpcRequest;
import com.infoloop.tianting.clientcustomerservice.QueryClientCustomerLabelRefsByConditionRpcResponse;
import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchCreateCustomerLabelRefDto;
import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefRequestDto;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ClientCustomerServiceRpcClient {
private final ClientCustomerServiceRpcGrpc.ClientCustomerServiceRpcBlockingStub
clientCustomerServiceRpcBlockingStub;
public GetClientCustomerByHISCustomerIdRpcResponse getClientCustomerByHISCustomerId(
String hisCustomerId
) {
final var request = GetClientCustomerByHISCustomerIdRpcRequest.newBuilder()
.setHISCustomerId(hisCustomerId)
.build();
return clientCustomerServiceRpcBlockingStub.getClientCustomerByHISCustomerId(request);
}
public GetClientCustomerByIdRpcResponse getClientCustomerById(Integer id) {
final var request = GetClientCustomerByIdRpcRequest.newBuilder().setId(id).build();
return clientCustomerServiceRpcBlockingStub.getClientCustomerById(request);
}
public GetClientCustomersByIdsRpcResponse getClientCustomersByIds(
Integer enterpriseId, List<Integer> ids) {
final var request = GetClientCustomersByIdsRpcRequest.newBuilder()
.setEnterpriseId(enterpriseId).addAllIds(ids)
.build();
return clientCustomerServiceRpcBlockingStub.getClientCustomersByIds(request);
}
public GetClientCustomerByMobileRpcResponse getClientCustomerByMobile(String phone) {
final var request = GetClientCustomerByMobileRpcRequest.newBuilder()
.setMobile(phone)
.build();
return clientCustomerServiceRpcBlockingStub.getClientCustomerByMobile(request);
}
public GetClientCustomerHospitalRecordByCustomerIdRpcResponse
getClientCustomerHospitalRecordsByCustomerId(Integer enterpriseId, Integer customerId) {
final var request = GetClientCustomerHospitalRecordByCustomerIdRpcRequest.newBuilder()
.setCustomerId(customerId)
.setEnterpriseId(enterpriseId)
.setIncludeDeleted(false)
.build();
return clientCustomerServiceRpcBlockingStub.getClientCustomerHospitalRecordByCustomerId(request);
}
public BatchCreateClientCustomerLabelRefsRpcResponse batchCreateClientCustomerLabelRefs(
BatchCreateCustomerLabelRefDto batchCreateCustomerLabelRefDto) {
final var creations = batchCreateCustomerLabelRefDto.getCreations().stream().map(
creation -> ClientCustomerLabelRefCreation.newBuilder()
.setCustomerId(creation.getCustomerId())
.setLabelId(creation.getLabelId())
.build()
).collect(Collectors.toList());
final var request = BatchCreateClientCustomerLabelRefsRpcRequest.newBuilder()
.setCreationSource(batchCreateCustomerLabelRefDto.getCreationSource().getNumber())
.setCreatedBy(batchCreateCustomerLabelRefDto.getCreatedBy())
.setEnterpriseId(batchCreateCustomerLabelRefDto.getEnterpriseId())
.addAllCreations(creations)
.build();
return clientCustomerServiceRpcBlockingStub.batchCreateClientCustomerLabelRefs(request);
}
public QueryClientCustomerLabelRefsByConditionRpcResponse getCustomerLabelsByCustomerId(
Integer enterpriseId, Integer customerId
) {
final var request =
QueryClientCustomerLabelRefsByConditionRpcRequest.newBuilder()
.setEnterpriseId(enterpriseId)
.setShouldFilterCustomerIds(true)
.addAllCustomerIds(List.of(customerId))
.setShouldFilterLabelIds(false)
.addLabelIds(0)
.build();
return clientCustomerServiceRpcBlockingStub.queryClientCustomerLabelRefsByCondition(request);
}
public DeleteClientCustomerLabelRefsRpcResponse batchDeleteClientCustomerLabelRefsByIds(
BatchDeleteCustomerLabelRefRequestDto batchDeleteCustomerLabelRefRequestDto) {
final var request = DeleteClientCustomerLabelRefsByIdsRpcRequest.newBuilder()
.setEnterpriseId(batchDeleteCustomerLabelRefRequestDto.getEnterpriseId())
.addAllIds(batchDeleteCustomerLabelRefRequestDto.getIds())
.build();
return clientCustomerServiceRpcBlockingStub.deleteClientCustomerLabelRefsByIds(request);
}
}