|
|
|
@ -1,11 +1,13 @@
|
|
|
|
|
package com.supervision.config;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.supervision.domain.GlobalResult;
|
|
|
|
|
import com.supervision.exception.BusinessException;
|
|
|
|
|
import com.supervision.exception.HumanException;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.core.MethodParameter;
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
|
|
@ -47,13 +49,17 @@ public class ResponseConfig implements ResponseBodyAdvice<Object> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Objects.isNull(o)) {
|
|
|
|
|
return JSONUtil.toJsonStr(GlobalResult.ok(null, "success"));
|
|
|
|
|
return GlobalResult.ok(null, "success");
|
|
|
|
|
}
|
|
|
|
|
if (o instanceof GlobalResult) {
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
// 对于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");
|
|
|
|
|