修改断句默认最大字数为50个
This commit is contained in:
parent
9aa4d6722a
commit
b9396e3878
@ -30,10 +30,18 @@ public class WebClientUtils {
|
|||||||
|
|
||||||
public static Mono<JSONObject> get(String url, Map<String, String> headers) {
|
public static Mono<JSONObject> get(String url, Map<String, String> headers) {
|
||||||
log.info("GET WebClient URL:{} headers:{}", url, headers);
|
log.info("GET WebClient URL:{} headers:{}", url, headers);
|
||||||
|
String logId = MDC.get(Log4Constans.PRINT_LOG_ID);
|
||||||
if(headers == null || headers.size() == 0) {
|
if(headers == null || headers.size() == 0) {
|
||||||
return webClient.get().uri(url).retrieve().bodyToMono(String.class).flatMap(s-> {
|
return webClient.get().uri(url).retrieve().bodyToMono(String.class).flatMap(s-> {
|
||||||
log.info("GET WebClient Respon:{}", s);
|
log.info("[{}]GET WebClient Respon:{}", logId, s);
|
||||||
return Mono.just(JSONObject.parseObject(s));
|
return Mono.just(JSONObject.parseObject(s));
|
||||||
|
}).contextWrite(ctx -> {
|
||||||
|
if(StringUtils.isNotEmpty(logId)){
|
||||||
|
Context contextTmp = ctx.put(Log4Constans.PRINT_LOG_ID, logId);
|
||||||
|
|
||||||
|
return contextTmp;
|
||||||
|
}
|
||||||
|
return ctx;
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
return webClient.get().uri(url).headers(httpHeaders -> {
|
return webClient.get().uri(url).headers(httpHeaders -> {
|
||||||
@ -42,20 +50,35 @@ public class WebClientUtils {
|
|||||||
httpHeaders.set(key, headers.get(key));
|
httpHeaders.set(key, headers.get(key));
|
||||||
}
|
}
|
||||||
}).retrieve().bodyToMono(String.class).flatMap(s-> {
|
}).retrieve().bodyToMono(String.class).flatMap(s-> {
|
||||||
log.info("GET WebClient Respon:{}", s);
|
log.info("[{}]GET WebClient Respon:{}", logId, s);
|
||||||
return Mono.just(JSONObject.parseObject(s));
|
return Mono.just(JSONObject.parseObject(s));
|
||||||
|
}).contextWrite(ctx -> {
|
||||||
|
if(StringUtils.isNotEmpty(logId)){
|
||||||
|
Context contextTmp = ctx.put(Log4Constans.PRINT_LOG_ID, logId);
|
||||||
|
|
||||||
|
return contextTmp;
|
||||||
|
}
|
||||||
|
return ctx;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Mono<JSONObject> post(String url, JSONObject body, Map<String, String> headers) {
|
public static Mono<JSONObject> post(String url, JSONObject body, Map<String, String> headers) {
|
||||||
log.info("POST WebClient URL:{} body:{} headers:{}", url, body, headers);
|
log.info("POST WebClient URL:{} body:{} headers:{}", url, body, headers);
|
||||||
//String logId = MDC.get(Log4Constans.PRINT_LOG_ID);
|
String logId = MDC.get(Log4Constans.PRINT_LOG_ID);
|
||||||
if(headers == null || headers.size() == 0) {
|
if(headers == null || headers.size() == 0) {
|
||||||
return webClient.post().uri(url).bodyValue(body.toString()).retrieve().bodyToMono(String.class).flatMap(s->
|
return webClient.post().uri(url).bodyValue(body.toString()).retrieve().bodyToMono(String.class).flatMap(s->
|
||||||
{
|
{
|
||||||
log.info("POST WebClient Respon:{}", s);
|
|
||||||
|
log.info("[{}]POST WebClient Respon:{}", logId, s);
|
||||||
return Mono.just(JSONObject.parseObject(s));
|
return Mono.just(JSONObject.parseObject(s));
|
||||||
|
}).contextWrite(ctx -> {
|
||||||
|
if(StringUtils.isNotEmpty(logId)){
|
||||||
|
Context contextTmp = ctx.put(Log4Constans.PRINT_LOG_ID, logId);
|
||||||
|
|
||||||
|
return contextTmp;
|
||||||
|
}
|
||||||
|
return ctx;
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
return webClient.post().uri(url).bodyValue(body.toString()).headers(httpHeaders -> {
|
return webClient.post().uri(url).bodyValue(body.toString()).headers(httpHeaders -> {
|
||||||
@ -64,8 +87,15 @@ public class WebClientUtils {
|
|||||||
httpHeaders.set(key, headers.get(key));
|
httpHeaders.set(key, headers.get(key));
|
||||||
}
|
}
|
||||||
}).retrieve().bodyToMono(String.class).flatMap(s-> {
|
}).retrieve().bodyToMono(String.class).flatMap(s-> {
|
||||||
log.info("POST WebClient Respon:{}", s);
|
log.info("[{}]POST WebClient Respon:{}", logId, s);
|
||||||
return Mono.just(JSONObject.parseObject(s));
|
return Mono.just(JSONObject.parseObject(s));
|
||||||
|
}).contextWrite(ctx -> {
|
||||||
|
if(StringUtils.isNotEmpty(logId)){
|
||||||
|
Context contextTmp = ctx.put(Log4Constans.PRINT_LOG_ID, logId);
|
||||||
|
|
||||||
|
return contextTmp;
|
||||||
|
}
|
||||||
|
return ctx;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ public class BaseWebSocketService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ReactiveStringRedisTemplate reactiveStringRedisTemplate;
|
private ReactiveStringRedisTemplate reactiveStringRedisTemplate;
|
||||||
|
|
||||||
protected static int ONE_MAX_TEXT = 30;
|
protected static int ONE_MAX_TEXT = 50;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ public class BaseWebSocketService {
|
|||||||
builder,
|
builder,
|
||||||
text,
|
text,
|
||||||
0,
|
0,
|
||||||
text.length() - 1,
|
text.length(),
|
||||||
baseSession.getRequestId()).flatMap(s -> {
|
baseSession.getRequestId()).flatMap(s -> {
|
||||||
return Mono.just(true);
|
return Mono.just(true);
|
||||||
});
|
});
|
||||||
@ -292,7 +292,7 @@ public class BaseWebSocketService {
|
|||||||
builder,
|
builder,
|
||||||
text,
|
text,
|
||||||
0,
|
0,
|
||||||
text.length() - 1,
|
text.length(),
|
||||||
baseSession.getRequestId()).subscribe();
|
baseSession.getRequestId()).subscribe();
|
||||||
}else{
|
}else{
|
||||||
BoxMessageResp boxMessageResp = new BoxMessageResp();
|
BoxMessageResp boxMessageResp = new BoxMessageResp();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user