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


import com.jeelowcode.framework.plus.build.ISQLExpression;
import com.jeelowcode.framework.plus.build.build.ddl.BuildAlter;
import com.jeelowcode.framework.plus.entity.FieldModel;
import com.jeelowcode.framework.plus.core.model.SqlFormatModel;

import java.util.List;

/**
 * @author JX
 * @create 2024-07-06 11:45
 * @dedescription:
 */
public class SqlInfoAlterModel<T> extends SqlInfoBaseDdlModel {

    private AlterType alterType;//操作类型

    private String tableName;//表名称
    //addColumn
    private FieldModel fieldModel;//字段属性


    private SqlInfoAlterModel(){}


    public enum AlterType{
        ADD_COLUMN,   //增加字段
        UPDATE_COLUMN    //修改字段
    }

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

        private SqlInfoAlterModel alterModel = new SqlInfoAlterModel();
        ISQLExpression<List<SqlFormatModel>> alterExpression = new BuildAlter();

        public Builder setTableName(String tableName){
            alterModel.tableName = tableName;
            return this;
        }
        //增加字段
        public SqlInfoAlterModel<BuildAlter> buildAddColumn(FieldModel fieldModel){
            alterModel.alterType = AlterType.ADD_COLUMN;
            alterModel.fieldModel =fieldModel;
            alterModel.setSqlExpression(alterExpression);
            return alterModel;
        }

        //更新字段
        public SqlInfoAlterModel<BuildAlter> buildUpdateColum(FieldModel fieldModel){
            alterModel.alterType = AlterType.UPDATE_COLUMN;
            alterModel.fieldModel =fieldModel;
            alterModel.setSqlExpression(alterExpression);
            return alterModel;
        }

    }


    public AlterType getAlterType() {
        return alterType;
    }

    public void setAlterType(AlterType alterType) {
        this.alterType = alterType;
    }

    public String getTableName() {
        return tableName;
    }

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

    public FieldModel getFieldModel() {
        return fieldModel;
    }

    public void setFieldModel(FieldModel fieldModel) {
        this.fieldModel = fieldModel;
    }


}
