|
|
|
@ -46,7 +46,10 @@ public class ResponseConfig implements ResponseBodyAdvice<Object> {
|
|
|
|
|
public Object beforeBodyWrite(Object o, @Nullable MethodParameter methodParameter, @Nullable MediaType mediaType,
|
|
|
|
|
@Nullable Class<? extends HttpMessageConverter<?>> aClass, @Nullable ServerHttpRequest serverHttpRequest,
|
|
|
|
|
@Nullable ServerHttpResponse serverHttpResponse) {
|
|
|
|
|
|
|
|
|
|
HttpHeaders headers = serverHttpResponse.getHeaders();
|
|
|
|
|
if (CollectionUtil.isEmpty(headers.get("Content-Type"))){
|
|
|
|
|
headers.set("Content-Type","application/json");
|
|
|
|
|
}
|
|
|
|
|
if (Objects.isNull(o)) {
|
|
|
|
|
return GlobalResult.ok(null, "success");
|
|
|
|
|
}
|
|
|
|
@ -55,10 +58,6 @@ public class ResponseConfig implements ResponseBodyAdvice<Object> {
|
|
|
|
|
}
|
|
|
|
|
// 对于String类型的返回值需要进行特殊处理
|
|
|
|
|
if (o instanceof String) {
|
|
|
|
|
HttpHeaders headers = serverHttpResponse.getHeaders();
|
|
|
|
|
if (CollectionUtil.isEmpty(headers.get("Content-Type"))){
|
|
|
|
|
headers.set("Content-Type","application/json");
|
|
|
|
|
}
|
|
|
|
|
return JSONUtil.toJsonStr(GlobalResult.ok(o, "success"));
|
|
|
|
|
}
|
|
|
|
|
return GlobalResult.ok(o, "success");
|
|
|
|
|