业务方法:
@ServiceLog
@EventLog
@Aop(TransAop.READ_COMMITTED)
public Object deleteInfo(NutMap map) throws BusinessException {
BagInfo bagInfo = new BagInfo();
int updateNum = 0;
String bagCode = map.get("bagCode").toString();
updateNum = dao.delete(BagInfo.class,bagCode);
dao.delete(BloodIn.class,bagCode);
dao.delete(BloodStorage.class,bagCode);
return updateNum;
}
AOP拦截器方法:
@IocBean
public class EventLogInterceptor implements MethodInterceptor {
@Inject //AnnotationIocLoader根据这个注解来了解类中的字段,具体的注入方式
protected Dao dao;
@Override
public void filter(InterceptorChain chain) throws Throwable {
// TODO Auto-generated method stub
chain.doChain();// 继续执行其他拦截器
String ServiceName = chain.getCallingObj().getClass().getName();
int loc = ServiceName.indexOf("$");//首先获取字符的位置
ServiceName = ServiceName.substring(0,loc);//再对字符串进行截取,获得想要得到的字符串
String ServiceMethodName = chain.getCallingMethod().getName();
System.out.println("================拦截器中,进行事件记录,向后台事件表写入记录:==============>");
Sql sql = Sqls.create("insert into BLOOD_SYS_EVENT values ('0001','0002')");
dao.execute(sql);
}
}