
package com.jeelowcode.framework.plus.build.buildmodel.dql;


import com.jeelowcode.framework.plus.build.ISQLExpression;
import com.jeelowcode.framework.plus.build.build.dql.BuildInsert;
import com.jeelowcode.framework.plus.build.buildmodel.SqlInfoBaseModel;
import com.jeelowcode.framework.plus.core.model.SqlFormatModel;

import java.util.LinkedHashMap;
import java.util.Map;

public class SqlInfoInsertModel<T> extends SqlInfoBaseModel {

    private String tableName;

    private Map<String,Object> insertMap=new LinkedHashMap<>();

    private SqlInfoInsertModel (){}

    public static Builder builder(){
        return new Builder();
    }

    public static class Builder{
        private SqlInfoInsertModel insertModel = new SqlInfoInsertModel();

        public Builder setTableName(String tableName){
            insertModel.setTableName(tableName);
            return this;
        }
        public Builder addColumn(String column,Object val){
            insertModel.insertMap.put(column,val);
            return this;
        }

        public Builder addMap(Map<String,Object> insertMap){
            insertModel.insertMap.putAll(insertMap);
            return this;
        }

        public SqlInfoInsertModel<BuildInsert> build(){
            ISQLExpression<SqlFormatModel> expression = new BuildInsert();
            insertModel.setSqlExpression(expression);
            return insertModel;
        }

    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public Map<String, Object> getInsertMap() {
        return insertMap;
    }

    public void setInsertMap(Map<String, Object> insertMap) {
        this.insertMap = insertMap;
    }
}
