zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.changhong.epc.config.aop.rest;
 
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
 
import com.changhong.epc.constter.base.BaseBean;
import com.iemsoft.framework.cloud.config.aop.rest.RestFormatAdvisor;
import com.iemsoft.framework.cloud.core.thread.Keys;
import com.iemsoft.framework.cloud.core.thread.ThreadData;
import com.iemsoft.framework.cloud.core.tools.ObjectUtil;
 
import lombok.extern.slf4j.Slf4j;
 
@Aspect
@Component
@Slf4j
public class RestAdvisor extends RestFormatAdvisor {
 
    @Override
    protected void begin(RestInfo ri) {
        Object[] args = ri.getArgs();
        if(ObjectUtil.notEmpty(args) && args[0] instanceof BaseBean){
            BaseBean bp = (BaseBean) args[0];
            ThreadData.set(Keys.PAGE_NUM, bp.getPageNum());
            ThreadData.set(Keys.PAGE_SIZE, bp.getPageSize());
            log.debug("添加分页参数{},{}", bp.getPageNum(), bp.getPageSize());
        }
    }
    
    @Override
    protected boolean isFilter(RestInfo ri) {
        return ri.getClazz().getName().startsWith("com.changhong.epc");
    }
 
}