Old project? Use ibatis?
help star , thank you
if you use spring aop to intercept the methods under SqlMapClientTemplate, you can intercept all executable sql and perform operations.
package com.detain.system.aop;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.detain.system.service.SystemService;
@Component
@Aspect
public class OperationRecordLog {
@Autowired
private SystemService systemService;
@Around(value = "execution(* org.springframework.orm.ibatis.SqlMapClientTemplate.delete(..)) or execution(* org.springframework.orm.ibatis.SqlMapClientTemplate.insert(..)) or execution(* org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(..)) or execution(* org.springframework.orm.ibatis.SqlMapClientTemplate.queryForMap(..)) or execution(* org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(..)) or execution(* org.springframework.orm.ibatis.SqlMapClientTemplate.queryWithRowHandler(..)) or execution(* org.springframework.orm.ibatis.SqlMapClientTemplate.update(..))")
public Object exec(ProceedingJoinPoint invocation) throws Throwable {
Object result = invocation.proceed();
Object[] args = invocation.getArgs();
if (args.length > 0) {
if (!args[0].toString().equals("system.saveSqlOperationRecord")) {
try {
if (args.length>1) {
systemService.saveSqlOperationRecord(args[0].toString(), args[1]);
} else {
systemService.saveSqlOperationRecord(args[0].toString(), "");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return result;
}
}
Previous: Indexddb twice open is suspended
Next: The browser CSS animation is not loaded immediately, only when the mouse moves.