|
@@ -1,6 +1,7 @@
|
|
|
package cn.com.qmth.markingaudit.support;
|
|
|
|
|
|
import org.springframework.core.MethodParameter;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
|
import org.springframework.http.server.ServerHttpRequest;
|
|
@@ -23,6 +24,7 @@ public class ResponseAdvice implements ResponseBodyAdvice<Object> {
|
|
|
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
|
|
|
Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request,
|
|
|
ServerHttpResponse response) {
|
|
|
+ response.setStatusCode(HttpStatus.OK);
|
|
|
if (body instanceof String) {
|
|
|
return JSON.toJSONString(Result.of(body));
|
|
|
}
|
|
@@ -31,7 +33,7 @@ public class ResponseAdvice implements ResponseBodyAdvice<Object> {
|
|
|
}
|
|
|
if (body instanceof ExceptionResponseEntity) {
|
|
|
ExceptionResponseEntity t = (ExceptionResponseEntity) body;
|
|
|
- return Result.of(t.getMessage());
|
|
|
+ return new Result<Object>(500, t.getMessage());
|
|
|
}
|
|
|
return Result.of(body);
|
|
|
}
|