package weaver.backup.impl;

import com.engine.workflow.biz.newRule.RuleSetBiz;
import weaver.backup.beans.FieldBean;
import weaver.backup.beans.TableBean;
import weaver.backup.itf.AbstractTableAction;
import weaver.backup.itf.ITableAction;
import weaver.backup.services.ImportService;
import weaver.conn.RecordSet;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>Description: 合规导入前处理</p>
 *
 * @author dbx
 * @date 2020/6/29 16:22
 * @since JDK1.8
 */
public class NewruleBaseTableAction extends AbstractTableAction {
    //插入数据前执行动作
    public void doBeforeInsert(TableBean table, ImportService importService) throws Exception {
        String ruleid = table.getPrimaryKeyvalue();
        String source = table.getField("source").getValue();
        RuleSetBiz ruleSetBiz = new RuleSetBiz();
        if("1".equals(source)){
            String newRuleid = ruleSetBiz.generateNewId();
            table.setPrimaryKeyvalue(newRuleid);
        }else if("0".equals(source)){
            RecordSet rs = new RecordSet();
            rs.executeUpdate("delete from newrule_base where ruleid = ?",ruleid);
        }
    };
    //更新数据前执行动作
    public void doBeforeUpdate(TableBean table, ImportService importService, String newuuid) throws Exception {};
    //导入后执行动作
    public void doAfter(TableBean table, ImportService importService) throws Exception{};
    //所有都导入完成后执行动作
    public void doAfterAll(ImportService importService) throws Exception{};
}
