
package com.lideeyunji.tool.framework.sql.build.buildmodel.dql;


import com.lideeyunji.tool.framework.sql.build.ISQLExpression;
import com.lideeyunji.tool.framework.sql.build.build.dql.BuildInsert;
import com.lideeyunji.tool.framework.sql.build.buildmodel.SqlInfoBaseModel;
import com.lideeyunji.tool.framework.sql.core.model.SqlFormatModel;
import com.lideeyunji.tool.framework.yunji.enums.LideeYunJiFieldTypeEnum;

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

public class SqlInfoInsertModel<T> extends SqlInfoBaseModel {

    private String tableName;
    private Map<String, LideeYunJiFieldTypeEnum> fieldTypeEnumMap=new HashMap<>();

    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 Builder setFieldType(Map<String, LideeYunJiFieldTypeEnum> fieldTypeEnumMap){
            insertModel.fieldTypeEnumMap=fieldTypeEnumMap;
            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;
    }

    public Map<String, LideeYunJiFieldTypeEnum> getFieldTypeEnumMap() {
        return fieldTypeEnumMap;
    }

    public void setFieldTypeEnumMap(Map<String, LideeYunJiFieldTypeEnum> fieldTypeEnumMap) {
        this.fieldTypeEnumMap = fieldTypeEnumMap;
    }
}
