use of com.mendmix.mybatis.crud.GeneralSqlGenerator in project jeesuite-libs by vakinge.
the class JeesuiteMybatisEnhancer method handle.
public static void handle(String group, Configuration configuration) throws Exception {
if ("tkMapper".equals(MybatisConfigs.getCrudDriver())) {
Class<?> helperClazz = Class.forName("tk.mybatis.mapper.mapperhelper.MapperHelper");
Object helper = helperClazz.newInstance();
Class<?> configClazz = Class.forName("tk.mybatis.mapper.entity.Config");
Object config = configClazz.newInstance();
Method method = configClazz.getDeclaredMethod("setNotEmpty", boolean.class);
method.invoke(config, false);
method = helperClazz.getDeclaredMethod("setConfig", configClazz);
method.invoke(helper, config);
method = helperClazz.getDeclaredMethod("registerMapper", Class.class);
List<MapperMetadata> mappers = MybatisMapperParser.getMapperMetadatas(group);
for (MapperMetadata mapper : mappers) {
method.invoke(helper, mapper.getMapperClass());
}
method = helperClazz.getDeclaredMethod("processConfiguration", Configuration.class);
method.invoke(helper, configuration);
} else {
new GeneralSqlGenerator(group, configuration).generate();
}
// pageHelper
try {
Class<?> pageHelperClazz = Class.forName("com.github.pagehelper.PageInterceptor");
Interceptor pageInterceptor = (Interceptor) pageHelperClazz.newInstance();
configuration.addInterceptor(pageInterceptor);
} catch (Exception e) {
}
// 注册拦截器
String[] hanlderNames = MybatisConfigs.getHandlerNames(group);
JeesuiteMybatisInterceptor interceptor = new JeesuiteMybatisInterceptor(group, hanlderNames);
configuration.addInterceptor(interceptor);
interceptor.afterRegister();
logger.info(">> JeesuiteMybatisEnhancer finshed -> group:{},hanlderNames:{}", group, hanlderNames);
}
Aggregations