去除全局的数据格式化,统一后续使用 CommonResult

ps:全局的格式化,也会格式化掉 swagger 的返回,会导致 swagger 无法使用的问题的。
This commit is contained in:
YunaiV
2019-02-26 12:10:14 +08:00
parent 6cbce27412
commit 4b0038759f
13 changed files with 211 additions and 102 deletions

View File

@@ -1,16 +1,14 @@
package cn.iocoder.mall.product.config;
import cn.iocoder.common.framework.config.GlobalExceptionHandler;
import cn.iocoder.common.framework.config.GlobalResponseBodyAdvice;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@EnableWebMvc
@Configuration
@Import(value = {GlobalResponseBodyAdvice.class, GlobalExceptionHandler.class}) // 统一全局返回
//@Import(value = {GlobalExceptionHandler.class}) // 统一全局返回
public class MVCConfiguration implements WebMvcConfigurer {
// @Autowired
@@ -24,4 +22,11 @@ public class MVCConfiguration implements WebMvcConfigurer {
// registry.addInterceptor(securityInterceptor);
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// 解决 swagger-ui.html 的访问,参考自 https://stackoverflow.com/questions/43545540/swagger-ui-no-mapping-found-for-http-request 解决
registry.addResourceHandler("swagger-ui.html**").addResourceLocations("classpath:/META-INF/resources/swagger-ui.html");
registry.addResourceHandler("webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}

View File

@@ -24,7 +24,7 @@ public class ProductCategoryController {
@GetMapping
@ApiOperation("获得指定编号下的子分类的数组")
@ApiImplicitParam(name = "pid", value = "指定分类编号", required = true)
@ApiImplicitParam(name = "pid", value = "指定分类编号", required = true, example = "0")
public List<ProductCategoryVO> list(@RequestParam("pid") Integer pid) {
return ProductCategoryConvert.INSTANCE.convertToVO(
productCategoryService.getListByPid(pid)

View File

@@ -10,7 +10,7 @@ spring:
# server
server:
port: 8080
port: 8081
# mybatis
mybatis: