ClientCustomerServiceHttpClient.java
1.52 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
package com.infoloop.tianting.service.client;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.CurrentClientCustomerDto;
import com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto;
import java.util.ArrayList;
import java.util.List;
import lombok.RequiredArgsConstructor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ClientCustomerServiceHttpClient {
private final OkHttpClient client = new OkHttpClient();
public List<CurrentClientCustomerDto> getCurrentClientCustomer() {
ObjectMapper objectMapper = new ObjectMapper();
try {
String url = "http://47.101.193.136:3031/clientcustomers/current/query";
Request request = new Request.Builder()
.url(url)
.build();
Response response = client.newCall(request).execute();
String jsonData = response.body().string();
System.out.println(jsonData);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// return objectMapper.readValue(jsonData, WxUserOpenIdDto.class);
return new ArrayList<>();
} catch (Exception e) {
System.out.println("error"+e.getMessage());
throw new IllegalArgumentException("获取用户openid失败");
}
}
}