Ver código fonte

测试拦截器

kouchengxing 5 anos atrás
pai
commit
4079609485

+ 3 - 0
dgtly-apiframework/src/main/java/com/dgtly/apiframework/interceptor/SwitchEnSqlInterceptor.java

@@ -34,6 +34,7 @@ public class SwitchEnSqlInterceptor  implements Interceptor {
     }
 
     public Object intercept(Invocation invocation) throws Throwable {
+        System.out.println("进入拦截器-----------------------");
         // 获取原始sql语句
         MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
         Object parameter = invocation.getArgs()[1];
@@ -46,12 +47,14 @@ public class SwitchEnSqlInterceptor  implements Interceptor {
         String language = request.getHeader("language");
 
         if(StringUtils.isNotEmpty(language) && "en".equalsIgnoreCase(language)){
+
             // 方法中含有获取注解
             Class<?> classType = Class.forName(mappedStatement.getId().substring(0,mappedStatement.getId().lastIndexOf(".")));
             String mName  = mappedStatement.getId().substring(mappedStatement.getId().lastIndexOf(".") + 1 ,mappedStatement.getId().length());
             for(Method method : classType.getDeclaredMethods()){
                 if(method!=null && mName.equals(method.getName()) && method.isAnnotationPresent(SwitchEn.class))
                 {
+                    System.out.println("处理sql-----------------------");
                     SwitchEn switchEn = method.getAnnotation(SwitchEn.class);
                     String[] oldfiles = switchEn.oldfiles();
                     String[] newfiles = switchEn.newfiles();

+ 6 - 5
dgtly-goods/dgtly-goods-api/src/main/java/com/dgtly/goods/controller/GoodsInfoController.java

@@ -13,10 +13,7 @@ import com.dgtly.common.core.page.PageDomain;
 import com.dgtly.common.exception.api.LessParamException;
 import com.dgtly.goods.domain.GoodsInfo;
 import com.dgtly.goods.service.IGoodsInfoService;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.Example;
-import io.swagger.annotations.ExampleProperty;
+import io.swagger.annotations.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -56,7 +53,11 @@ public class GoodsInfoController extends ApiBaseController {
 
 
     @ApiOperation(value = "热门商品列表")
-    @ApiImplicitParam(name = "params" , paramType = "body")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "params" , paramType = "body"),
+            @ApiImplicitParam(name = "language" , paramType = "header")
+    })
+
     @PostMapping("/hotlist")
     public Object getHotList(){
         PageDomain pg1 = new PageDomain();