request id
parent
92beab28c1
commit
b09bec5c2b
|
|
@ -46,8 +46,7 @@ public interface ApiClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
default <T> HttpResponse<T> post(String url, QueryParameter parameters, HttpHeaders headers, RequestBody body, Class<T> responseClass) {
|
default <T> HttpResponse<T> post(String url, QueryParameter parameters, HttpHeaders headers, RequestBody body, Class<T> responseClass) {
|
||||||
HttpRequest httpRequest = new HttpRequest.Builder()
|
HttpRequest httpRequest = new HttpRequest.Builder().httpMethod(HttpMethod.POST)
|
||||||
.httpMethod(HttpMethod.POST)
|
|
||||||
.url(url)
|
.url(url)
|
||||||
.parameters(parameters)
|
.parameters(parameters)
|
||||||
.headers(headers)
|
.headers(headers)
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,9 @@ public class Nonce {
|
||||||
public static String ofNonce() {
|
public static String ofNonce() {
|
||||||
return UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
return UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String ofShortNonce() {
|
||||||
|
// TODO 短ID
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.czcb.scfs.api.core.util;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class NonceTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void ofNonce() {
|
||||||
|
Assertions.assertEquals(32, Nonce.ofNonce().length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -26,8 +26,7 @@ public class EchoService {
|
||||||
public void echo() {
|
public void echo() {
|
||||||
String url = "/echo";
|
String url = "/echo";
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
EchoRequest request = new EchoRequest();
|
EchoRequest request = new EchoRequest().setDatetime(DateTimes.ofNow());
|
||||||
request.setDatetime(DateTimes.ofNow());
|
|
||||||
|
|
||||||
HttpResponse<EchoResponse> response = apiClient.post(url, headers, request.toJsonRequest(), EchoResponse.class);
|
HttpResponse<EchoResponse> response = apiClient.post(url, headers, request.toJsonRequest(), EchoResponse.class);
|
||||||
if (Objects.isNull(response.getServiceResponse()) || !response.getServiceResponse().ok()) {
|
if (Objects.isNull(response.getServiceResponse()) || !response.getServiceResponse().ok()) {
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,15 @@
|
||||||
package com.czcb.scfs.api.service.echo.model;
|
package com.czcb.scfs.api.service.echo.model;
|
||||||
|
|
||||||
import com.czcb.scfs.api.core.ApiRequest;
|
import com.czcb.scfs.api.core.ApiRequest;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wangwei
|
* @author wangwei
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
public class EchoRequest implements ApiRequest {
|
public class EchoRequest implements ApiRequest {
|
||||||
private String datetime;
|
private String datetime;
|
||||||
|
|
||||||
public String getDatetime() {
|
|
||||||
return datetime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDatetime(String datetime) {
|
|
||||||
this.datetime = datetime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue