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) {
|
||||
HttpRequest httpRequest = new HttpRequest.Builder()
|
||||
.httpMethod(HttpMethod.POST)
|
||||
HttpRequest httpRequest = new HttpRequest.Builder().httpMethod(HttpMethod.POST)
|
||||
.url(url)
|
||||
.parameters(parameters)
|
||||
.headers(headers)
|
||||
|
|
|
|||
|
|
@ -17,4 +17,9 @@ public class Nonce {
|
|||
public static String ofNonce() {
|
||||
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() {
|
||||
String url = "/echo";
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
EchoRequest request = new EchoRequest();
|
||||
request.setDatetime(DateTimes.ofNow());
|
||||
EchoRequest request = new EchoRequest().setDatetime(DateTimes.ofNow());
|
||||
|
||||
HttpResponse<EchoResponse> response = apiClient.post(url, headers, request.toJsonRequest(), EchoResponse.class);
|
||||
if (Objects.isNull(response.getServiceResponse()) || !response.getServiceResponse().ok()) {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,15 @@
|
|||
package com.czcb.scfs.api.service.echo.model;
|
||||
|
||||
import com.czcb.scfs.api.core.ApiRequest;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author wangwei
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class EchoRequest implements ApiRequest {
|
||||
private String datetime;
|
||||
|
||||
public String getDatetime() {
|
||||
return datetime;
|
||||
}
|
||||
|
||||
public void setDatetime(String datetime) {
|
||||
this.datetime = datetime;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue