com.github.bingoohuang.sqltrigger.ProxyFactoryInsert Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sql-trigger Show documentation
Show all versions of sql-trigger Show documentation
delay queue based on redis
The newest version!
package com.github.bingoohuang.sqltrigger;
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.val;
import org.apache.commons.collections.CollectionUtils;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import static com.github.bingoohuang.sqltrigger.SqlParseUtil.fulfilColumnInfo;
public class ProxyFactoryInsert extends ProxyFactoryPrepare {
private final String sql;
private final SqlTriggerBeanMap sqlTriggerBeanMap;
private final SQLInsertStatement stmt;
private final List items;
public ProxyFactoryInsert(String sql, SqlTriggerBeanMap sqlTriggerBeanMap, SQLInsertStatement stmt) {
this.sql = sql;
this.sqlTriggerBeanMap = sqlTriggerBeanMap;
this.stmt = stmt;
val tableName = stmt.getTableName().getSimpleName();
this.items = sqlTriggerBeanMap.findByTriggerType(tableName, TriggerType.INSERT);
}
@Override public boolean requiredProxy() {
return CollectionUtils.isNotEmpty(items);
}
@Override public Object createPsProxyFactory(Object ps) {
val cols = createSqlInsertColumns();
val colsList = fulfilSqlInsertColumns(cols);
Object[] triggerBeans = sqlTriggerBeanMap.getTriggerBeans();
return new ProxyImpl(sql, ps, Lists.newArrayList(colsList), null, items, triggerBeans, new AtomicInteger()).create();
}
private List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy