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


import com.jeelowcode.framework.plus.build.ISQLExpression;
import com.jeelowcode.framework.plus.build.build.dql.BuildUpdate;
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 SqlInfoUpdateModel<T> extends SqlInfoBaseModel {
    private String tableName;

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

    private SqlInfoUpdateModel(){}

    public static Builder builder(){
        return new Builder();
    }
    public static class Builder {
        SqlInfoUpdateModel updateModel = new SqlInfoUpdateModel();

        public Builder setTableName(String tableName) {
            updateModel.tableName = tableName;
            return this;
        }

        public Builder addColumn(String column, Object val){
            updateModel.updateMap.put(column,val);
            return this;
        }

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


        public SqlInfoUpdateModel<BuildUpdate> build() {
            ISQLExpression<SqlFormatModel> expression = new BuildUpdate();
            updateModel.setSqlExpression(expression);
            return updateModel;
        }

    }

    public String getTableName() {
        return tableName;
    }

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

    public Map<String, Object> getUpdateMap() {
        return updateMap;
    }

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