SpringBoot uses AOP to intercept the JSON of the request to obtain object parameters

SpringBoot uses AOP to intercept the JSON of the request to obtain object parameters
for example

Entity class:

public class Company {
    private Integer id;

    private String companyName;

    private Integer companyState;

    public Company(Integer id, String companyName, Integer companyState) {
        this.id = id;
        this.companyName = companyName;
        this.companyState = companyState;
    }

    public Company() {
        super();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public Integer getCompanyState() {
        return companyState;
    }

    public void setCompanyState(Integer companyState) {
        this.companyState = companyState;
    }
}

Action class:

@RestController
@RequestMapping("company")
public class CompanyAction {

    @RequestMapping(value="updateone",method=RequestMethod.POST)
    public ReturnJSON<List<Company>> updateOne(@RequestBody Company company_param){

        System.out.println("action");
        
        return new ReturnJSON<List<Company>>(null);
    }
}

Aop class:

@Aspect
@Component
public class LogAspect {
    
    @Pointcut("execution(public * com.action.*.*(..))")  
    public void webLog(){}  
    
    @Around("webLog()")  
    public Object arround(ProceedingJoinPoint pjp) {  
        System.out.println("start.....");  
        try {  
            System.out.println("ARGS : " + Arrays.toString(pjp.getArgs()));  
            Object o =  pjp.proceed();  
            System.out.println("proceed :" + o);  
            return o;  
        } catch (Throwable e) {  
            e.printStackTrace();  
            return null;  
        }  
    }  
}

when I make a request, the console says something like this:

start.....
ARGS : [com.entity.Company@38250ab4]
action
proceed : com.entity4action.ReturnJSON@7a6f374c

my parameter to send the request is a JSON, and then let SpringBoot parse into the object Company through JSON, but I want to use AOP to record what the JSON received by the specific request is, how should I write it? Should you not intercept this class, but instead intercept a class in SpringBoot?

Mar.22,2021

write JsonUtil.toJson directly (just pjp.getArgs ())


this is @ RequestBody and @ Pointcut ("execution (public com.action. . * (..)")) The question of who will take effect first is AOP, but the result is Mr. @ RequestBody. Only one Company object can be obtained in public Object arround (ProceedingJoinPoint pjp), and the original json is gone.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf1375-31d54.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf1375-31d54.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?