
package com.lideeyunji.tool.framework.sql.build.build.ddl;

import com.lideeyunji.tool.framework.sql.build.ISQLExpression;
import com.lideeyunji.tool.framework.sql.build.buildmodel.SQLInterpretContext;
import com.lideeyunji.tool.framework.sql.build.buildmodel.ddl.SqlInfoDdlModel;
import com.lideeyunji.tool.framework.sql.utils.PlusUtils;
import com.lideeyunji.tool.framework.sql.core.model.SqlFormatModel;
import com.lideeyunji.tool.framework.yunji.utils.FuncBase;
import net.sf.jsqlparser.JSQLParserException;

import java.util.List;

/**
 * 通用DDL
 */
public class BuildDdl implements ISQLExpression<List<SqlFormatModel>> {

    @Override
    public List<SqlFormatModel> interpret(SQLInterpretContext context) throws JSQLParserException {
        SqlInfoDdlModel ddlModel = context.getDdlModel();
        if (FuncBase.isEmpty(ddlModel)) {
            return null;
        }
        //存在自定义ddl
        List<String> executeDdlList = ddlModel.getExecuteDdlList();
        if (FuncBase.isEmpty(executeDdlList)) {
            return null;
        }

        return PlusUtils.ddl2SqlFormatModel(executeDdlList);
    }


}
