Przeglądaj źródła

增加文件下载配置

tags/24080901
WendyYang 11 miesięcy temu
rodzic
commit
79d0df236d
2 zmienionych plików z 9 dodań i 13 usunięć
  1. +8
    -13
      hz-pm-api/src/main/java/com/hz/pm/api/common/handler/GlobalResponseHandler.java
  2. +1
    -0
      hz-pm-api/src/main/resources/application-dev.yml

+ 8
- 13
hz-pm-api/src/main/java/com/hz/pm/api/common/handler/GlobalResponseHandler.java Wyświetl plik

@@ -11,10 +11,13 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;

/**
* @Author liuxinxin
* @Date 2021/7/21 11:26
* @Version 1.0
**/
* <p>
* GlobalResponseHandler
* </p>
*
* @author WendyYang
* @since 10:29 2023/12/29
*/
@RestControllerAdvice(basePackages = {
"com.hz.pm.api.fiscal.controller",
"com.hz.pm.api.organization.controller",
@@ -37,6 +40,7 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
"com.hz.pm.api.gov.controller",
"com.hz.pm.api.dashboard.controller",
"com.hz.pm.api.wps.controller",
"com.hz.pm.api.external.controller",
"com.hz.pm.api.gov.controller"
})
public class GlobalResponseHandler implements ResponseBodyAdvice<Object> {
@@ -52,16 +56,7 @@ public class GlobalResponseHandler implements ResponseBodyAdvice<Object> {
public Object beforeBodyWrite(Object o, MethodParameter methodParameter, MediaType mediaType,
Class<? extends HttpMessageConverter<?>> aClass, ServerHttpRequest serverHttpRequest,
ServerHttpResponse serverHttpResponse) {
ApiResponse<Object> apiResponse = ApiResponse.ofSuccess(o);
// 处理字符串时,遇到了类型转换的问题,debug一步一步跟踪,原来是对于字符串的ContentType是“text-plain”,
// ConverterType是StringHttpMessageConverter这个类型转换,
// 由于将结果封装成了自定义的ApiResponse类型,所以有ApiResponse转换成String报错
// 所以需要对String类型的返回值单独进行处理
// if (o instanceof String) {
// return JSONUtil.toJsonStr(apiResponse);
// }
return ApiResponse.ofSuccess(o);
// return o;
}

private Boolean filter(MethodParameter methodParameter) {


+ 1
- 0
hz-pm-api/src/main/resources/application-dev.yml Wyświetl plik

@@ -253,4 +253,5 @@ mh:
# api-host: http://10.54.38.13:8081/mh-gateway/auth-single
expert-qr-code-url: https://jiema.wwei.cn/uploads/2023/12/28/658d7a3f15f06.jpg
file:
down-url: https://weixin.hzszxc.hzswb.cn:8443/mh-gateway/oss/oss/previewFileLogin
detail-url: https://weixin.hzszxc.hzswb.cn:8443/mh-gateway/oss/ossfile/getFileInfoList

Ładowanie…
Anuluj
Zapisz