package com.ag.dynamicmodule.service;

import com.ag.base.DefaultBussniessImpl;
import com.ag.dynamicmodule.main.HotApplicationContext;

import java.util.List;

/**
 * 对象操作基类
 * @author running
 * @since 2020-11-09
 */
public class BaseEntiy {

    /**
     * 保存
     */
    public void save() {
        DefaultBussniessImpl defaultBussniess = (DefaultBussniessImpl) HotApplicationContext.getBean("defaultBussniessImpl");

        defaultBussniess.save(this);
    }

    /**
     * 删除
     * 用法 delete( "CONTRACT_ID", "CATEGORY_ID", "ITEM_ID")可以定义多个参数
     * @param colName
     */
    public void delete(Object... colName) {
        DefaultBussniessImpl defaultBussniess = (DefaultBussniessImpl) HotApplicationContext.getBean("defaultBussniessImpl");
        defaultBussniess.delete(this, colName);
    }

    /**
     * 查询
     * 用法 queryList("ID","NAME","") 可以定义多个参数
     * @param colName
     */
    public List queryList( Object... colName) {
        DefaultBussniessImpl defaultBussniess = (DefaultBussniessImpl) HotApplicationContext.getBean("defaultBussniessImpl");
        return defaultBussniess.findByEqCriteria(this, this.getClass(), colName);
    }
    /**
     * 更新
     * 用法 update( "CONTRACT_ID", "CATEGORY_ID", "ITEM_ID")
     * @param colName
     */
    public void update(Object... colName) {
        DefaultBussniessImpl defaultBussniess = (DefaultBussniessImpl) HotApplicationContext.getBean("defaultBussniessImpl");
        defaultBussniess.update(this, colName);

    }
}
