
sf.database.template.TemplateRender Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sorm Show documentation
Show all versions of sorm Show documentation
java jpa tool for spring
The newest version!
package sf.database.template;
import org.smallframework.spring.path.ClassPathScanningUtils;
import sf.database.OrmConfig;
import sf.database.template.enjoy.EnjoyHandler;
import sf.database.template.freemarker.FreemarkerHandler;
import sf.database.template.mybatis.MybatisHandler;
import sf.tools.StringUtils;
import java.net.URL;
import java.util.Set;
public class TemplateRender {
public static TemplateHandler getTemplateHandler(TemplateType type) {
if (type == null) {
type = OrmConfig.getInstance().getSqlTemplateType();//默认使用enjoy
}
switch (type) {
case enjoy:
return EnjoyHandler.getInstance();
case freemarker:
return FreemarkerHandler.getInstance();
case mybatis:
return MybatisHandler.getInstance();
default:
return EnjoyHandler.getInstance();
}
}
public static String[] defaultPath = new String[]{"classpath*:sql/**/*.sql"};
public static Set getDefaultSqlTemplates() {
return getSqlTemplates(defaultPath);
}
public static Set getSqlTemplates(String[] paths) {
return ClassPathScanningUtils.getPathScanning().getResourcesURL(null, paths);
}
/**
* 跨数据库的key,如果dbType为空,
* @param key sqlId
* @param dbType 数据库类型
* @return
*/
public static String wrapKey(String key, String dbType) {
if (StringUtils.isNotBlank(dbType)) {
return key + "." + dbType;
} else {
return key;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy