修改注释

master
星期八 5 years ago
parent 764b585eae
commit e8aa0312bd
  1. 13
      src/main/java/com/lq/code/executor/processor/InstantiationTracingBeanPostProcessor.java
  2. 13
      src/main/java/com/lq/code/interceptor/PageInteceptor.java

@ -4,14 +4,16 @@ import com.lq.code.dto.QueueDto;
import com.lq.code.util.BeanUtil; import com.lq.code.util.BeanUtil;
import com.lq.code.util.jdbc.JdbcUtils; import com.lq.code.util.jdbc.JdbcUtils;
import com.lq.code.util.sql.AbstractDbBuiler; import com.lq.code.util.sql.AbstractDbBuiler;
import com.lq.code.util.sql.MysqlBuilder; import com.lq.code.util.sql.SqlConstant;
import com.lq.code.util.sql.factory.DbBuilerFactory;
import com.lq.code.util.sql.factory.impl.DefaultDbBuilerFactory;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.ContextRefreshedEvent;
import java.util.Set; import java.util.Set;
/** /**
* Created by qi_liang on 2018/6/1. * @author qi
*/ */
public class InstantiationTracingBeanPostProcessor implements ApplicationListener<ContextRefreshedEvent> { public class InstantiationTracingBeanPostProcessor implements ApplicationListener<ContextRefreshedEvent> {
@ -42,15 +44,12 @@ public class InstantiationTracingBeanPostProcessor implements ApplicationListene
//需要执行的逻辑代码,当spring容器初始化完成后就会执行该方法。 //需要执行的逻辑代码,当spring容器初始化完成后就会执行该方法。
//扫描实体类 //扫描实体类
if (isUpdateDB) { if (isUpdateDB) {
long startTime = System.currentTimeMillis();
Set<Class> set = BeanUtil.getClassSet(packagePath); Set<Class> set = BeanUtil.getClassSet(packagePath);
QueueDto<Class> queueDto = BeanUtil.getQueueDto(packagePath); QueueDto<Class> queueDto = BeanUtil.getQueueDto(packagePath);
AbstractDbBuiler dbBuiler = new MysqlBuilder(); DbBuilerFactory dbBuilerFactory = new DefaultDbBuilerFactory();
// String sql = dbBuiler.automaticUpdateDbNew(queueDto); AbstractDbBuiler dbBuiler = dbBuilerFactory.getSqlBuilder(SqlConstant.DB_TYPE_MYSQL);
String sql = dbBuiler.automaticUpdateDb(set); String sql = dbBuiler.automaticUpdateDb(set);
JdbcUtils.createTable(sql); JdbcUtils.createTable(sql);
System.out.println("=========实体同步数据结构===========");
System.out.println(System.currentTimeMillis()-startTime+"毫秒");
} }
} }
} }

@ -2,6 +2,8 @@ package com.lq.code.interceptor;
import com.lq.code.util.StringUtil; import com.lq.code.util.StringUtil;
import com.lq.code.util.sql.*; import com.lq.code.util.sql.*;
import com.lq.code.util.sql.factory.DbBuilerFactory;
import com.lq.code.util.sql.factory.impl.DefaultDbBuilerFactory;
import org.apache.ibatis.executor.Executor; import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.executor.statement.StatementHandler; import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.mapping.BoundSql; import org.apache.ibatis.mapping.BoundSql;
@ -17,7 +19,7 @@ import java.sql.Connection;
import java.util.Properties; import java.util.Properties;
/** /**
* Created by qi_liang on 2018/2/16. * @author qi
*/ */
//注解拦截器并签名 //注解拦截器并签名
//@Signature 拦截的类签名 type 拦截的类 method 类里面的方法 args方法里面的参数 //@Signature 拦截的类签名 type 拦截的类 method 类里面的方法 args方法里面的参数
@ -48,13 +50,8 @@ public class PageInteceptor implements Interceptor {
BoundSql boundSql=(BoundSql)metaStatementHandler.getValue("delegate.boundSql"); BoundSql boundSql=(BoundSql)metaStatementHandler.getValue("delegate.boundSql");
String sql=boundSql.getSql(); String sql=boundSql.getSql();
PageInterface pageInterface=(PageInterface)boundSql.getParameterObject(); PageInterface pageInterface=(PageInterface)boundSql.getParameterObject();
AbstractDbBuiler db = null; DbBuilerFactory dbBuilerFactory = new DefaultDbBuilerFactory();
if (SqlConstant.DB_TYPE_MYSQL.equals(dialect)){ AbstractDbBuiler db = dbBuilerFactory.getSqlBuilder(dialect);
db = new MysqlBuilder();
}
if (SqlConstant.DB_TYPE_ORACLE.equals(dialect)){
db = new OracleBuiler();
}
String pageSql=db.concatPageSql(sql,pageInterface); String pageSql=db.concatPageSql(sql,pageInterface);
metaStatementHandler.setValue("delegate.boundSql.sql",pageSql); metaStatementHandler.setValue("delegate.boundSql.sql",pageSql);

Loading…
Cancel
Save