package com.viettel.campaign.utils;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.io.IOException;
import org.springframework.core.io.ClassPathResource;

/**
 * @author anhvd_itsol
 */
public class SQLBuilder {
    public static final String SQL_MODULE_CAMPAIGN_MNG = "campaign-mng";
    public static final String SQL_MODULE_CAMPAIGN_STATUS_MNG = "campaign-status-mng";

    public static String getSqlQueryById(String module,
                                         String queryId) {
        File folder = null;
        try {
            folder = new ClassPathResource(
                    "sql" + File.separator + module + File.separator + queryId + ".sql").getFile();

            // Read file
            if (folder.isFile()) {
                String sql = new String(Files.readAllBytes(Paths.get(folder.getAbsolutePath())));
                return sql;
            }
        } catch (IOException e) {
            return null;
        }
        return null;
    }
}
