修改断句默认最大字数为50个

This commit is contained in:
wulin 2023-10-26 18:04:41 +08:00
parent 9aa4d6722a
commit b9396e3878
2 changed files with 38 additions and 8 deletions

View File

@ -30,10 +30,18 @@ public class WebClientUtils {
public static Mono<JSONObject> get(String url, Map<String, String> headers) {
log.info("GET WebClient URL:{} headers:{}", url, headers);
String logId = MDC.get(Log4Constans.PRINT_LOG_ID);
if(headers == null || headers.size() == 0) {
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));
}).contextWrite(ctx -> {
if(StringUtils.isNotEmpty(logId)){
Context contextTmp = ctx.put(Log4Constans.PRINT_LOG_ID, logId);
return contextTmp;
}
return ctx;
});
}else{
return webClient.get().uri(url).headers(httpHeaders -> {
@ -42,20 +50,35 @@ public class WebClientUtils {
httpHeaders.set(key, headers.get(key));
}
}).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));
}).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) {
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) {
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));
}).contextWrite(ctx -> {
if(StringUtils.isNotEmpty(logId)){
Context contextTmp = ctx.put(Log4Constans.PRINT_LOG_ID, logId);
return contextTmp;
}
return ctx;
});
}else{
return webClient.post().uri(url).bodyValue(body.toString()).headers(httpHeaders -> {
@ -64,8 +87,15 @@ public class WebClientUtils {
httpHeaders.set(key, headers.get(key));
}
}).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));
}).contextWrite(ctx -> {
if(StringUtils.isNotEmpty(logId)){
Context contextTmp = ctx.put(Log4Constans.PRINT_LOG_ID, logId);
return contextTmp;
}
return ctx;
});
}

View File

@ -58,7 +58,7 @@ public class BaseWebSocketService {
@Autowired
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,
text,
0,
text.length() - 1,
text.length(),
baseSession.getRequestId()).flatMap(s -> {
return Mono.just(true);
});
@ -292,7 +292,7 @@ public class BaseWebSocketService {
builder,
text,
0,
text.length() - 1,
text.length(),
baseSession.getRequestId()).subscribe();
}else{
BoxMessageResp boxMessageResp = new BoxMessageResp();