package com.unis.crk.utils;

import org.springframework.core.io.UrlResource;
import org.springframework.util.ResourceUtils;

import java.io.FileInputStream;
import java.net.URL;
import java.util.LinkedHashMap;
import java.util.Map;

public class SqpMapUtil {
	private final static Map<String, String> SQL_MAP =new LinkedHashMap<>();
	static {
		try {
			URL url1 = ResourceUtils.getURL("classpath:SqlMap/sql.xml");
			UrlResource resource1 = new UrlResource(url1);
			Xml xml = new Xml(new FileInputStream(resource1.getFile()));
			Map<String, String> sqls_ = xml.getText();
			for (Map.Entry<String, String> entry : sqls_.entrySet()) {
				SQL_MAP.put(entry.getKey(), entry.getValue());
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	public static String getSql(String key) {
	    return SQL_MAP.get(key);

	  }

}
