更新代码

master
星期八 5 years ago
parent fc01760722
commit d09b59f3bd
  1. 7
      panda-all/panda-all.iml
  2. 2
      panda-all/pom.xml
  3. 7
      panda-aop/panda-aop.iml
  4. 2
      panda-aop/pom.xml
  5. 7
      panda-beans/panda-beans.iml
  6. 2
      panda-beans/pom.xml
  7. 3
      panda-beans/src/main/java/org/panda/beans/util/BeanUtil.java
  8. 7
      panda-code/panda-code.iml
  9. 2
      panda-code/pom.xml
  10. 7
      panda-jdbc/panda-jdbc.iml
  11. 2
      panda-jdbc/pom.xml
  12. 13
      panda-jdbc/src/main/java/org/panda/jdbc/sql/AbstractDbBuiler.java
  13. 32
      panda-jdbc/src/main/java/org/panda/jdbc/sql/SqlConstant.java
  14. 14
      panda-jdbc/src/main/java/org/panda/jdbc/sql/factory/DbBuilerFactory.java
  15. 30
      panda-jdbc/src/main/java/org/panda/jdbc/sql/factory/impl/DefaultDbBuilerFactory.java
  16. 7
      panda-web/panda-web.iml
  17. 2
      panda-web/pom.xml
  18. 2
      pom.xml

@ -7,10 +7,17 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/classes" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/test-classes" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.4" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.2" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.40" level="project" />
<orderEntry type="module" module-name="panda-code" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" />

@ -5,7 +5,7 @@
<parent>
<artifactId>panda</artifactId>
<groupId>org.panda</groupId>
<version>2.0</version>
<version>2.0.0</version>
</parent>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>

@ -7,10 +7,17 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/classes" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/test-classes" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.4" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.2" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.40" level="project" />
<orderEntry type="library" name="Maven: cglib:cglib:3.2.9" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm:7.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.ant:ant:1.10.3" level="project" />

@ -5,7 +5,7 @@
<parent>
<artifactId>panda</artifactId>
<groupId>org.panda</groupId>
<version>2.0</version>
<version>2.0.0</version>
</parent>
<version>${project.version}</version>
<modelVersion>4.0.0</modelVersion>

@ -7,10 +7,17 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/classes" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/test-classes" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.4" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.2" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.40" level="project" />
<orderEntry type="module" module-name="panda-code" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" />

@ -5,7 +5,7 @@
<parent>
<artifactId>panda</artifactId>
<groupId>org.panda</groupId>
<version>2.0</version>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

@ -1,7 +1,6 @@
package org.panda.beans.util;
import com.sun.tools.javac.util.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -218,7 +217,6 @@ public class BeanUtil {
*/
public static <T> T instantiateClass(Class<T> clazz){
T t = null;
Assert.checkNonNull(clazz);
try {
t = clazz.newInstance();
} catch (InstantiationException e) {
@ -239,7 +237,6 @@ public class BeanUtil {
*/
public static <T> T instantiateClass(Class<T> clazz,Object... params){
T t = null;
Assert.checkNonNull(clazz);
Class[] classes = new Class[params.length];
for (int i=0;i<params.length;i++){
classes[i] = params[i].getClass();

@ -7,10 +7,17 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/classes" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/test-classes" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.4" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.2" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.40" level="project" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.6" level="project" />

@ -5,7 +5,7 @@
<parent>
<artifactId>panda</artifactId>
<groupId>org.panda</groupId>
<version>2.0</version>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>panda-code</artifactId>

@ -6,10 +6,17 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/classes" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/test-classes" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.4" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.2" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.40" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.11" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="module" module-name="panda-code" />

@ -5,7 +5,7 @@
<parent>
<artifactId>panda</artifactId>
<groupId>org.panda</groupId>
<version>2.0</version>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

@ -89,14 +89,15 @@ public abstract class AbstractDbBuiler {
* @return
*/
public String countSql(String sql){
StringBuffer sb=new StringBuffer("select count(*) from ( ");
sql=sql.toLowerCase();
if (sql.lastIndexOf("order")>sql.lastIndexOf(")")){
sb.append(sql.substring(sql.indexOf("from")+4,sql.lastIndexOf("order")));
StringBuffer sb=new StringBuffer("SELECT COUNT(*) FROM ");
//SQL 转成大写适
String upperCaseSql = sql.toUpperCase();
//统计SQL排除排序SQL代码
if (sql.lastIndexOf(SqlConstant.ORDER_SQL)>sql.lastIndexOf(")")){
sb.append(sql.substring(upperCaseSql.indexOf(SqlConstant.FROM_SQL)+SqlConstant.FROM_SQL.length(),upperCaseSql.lastIndexOf(SqlConstant.ORDER_SQL)));
}else{
sb.append(sql.substring(sql.indexOf("from")+4));
sb.append(sql.substring(upperCaseSql.indexOf(SqlConstant.FROM_SQL)+SqlConstant.FROM_SQL.length()));
}
sb.append(")");
return sb.toString();
}

@ -0,0 +1,32 @@
package org.panda.jdbc.sql;
/**
* @Author: qi
* @Description:
* @Date: Create in 6:28 AM 2019/5/6
*/
public class SqlConstant {
/**
* SQL 切割符
*/
public static final String SQL_SYMBOL = "_";
/**
* 数据库类型常量mysql
*/
public static final String DB_TYPE_MYSQL = "mysql";
/**
* 数据库类型常量oracle
*/
public static final String DB_TYPE_ORACLE = "oracle";
/**
* 常用SQL 关键字:FROM
*/
public static final String FROM_SQL = "FROM ";
/**
* 常用SQL 关键字:order
*/
public static final String ORDER_SQL="ORDER";
}

@ -0,0 +1,14 @@
package org.panda.jdbc.sql.factory;
import org.panda.jdbc.sql.AbstractDbBuiler;
/**
* Sql 构造器工厂
* 作用解耦使用者与具体实现类关系
* @author qi
*/
public interface DbBuilerFactory {
AbstractDbBuiler getSqlBuilder(String dbType);
}

@ -0,0 +1,30 @@
package org.panda.jdbc.sql.factory.impl;
import org.panda.jdbc.sql.AbstractDbBuiler;
import org.panda.jdbc.sql.MysqlBuilder;
import org.panda.jdbc.sql.OracleBuiler;
import org.panda.jdbc.sql.SqlConstant;
import org.panda.jdbc.sql.factory.DbBuilerFactory;
/**
* @author qi
* dbBuilfer 生产工厂模式默认实现
*/
public class DefaultDbBuilerFactory implements DbBuilerFactory {
@Override
public AbstractDbBuiler getSqlBuilder(String dbType) {
AbstractDbBuiler abstractDbBuiler = null;
switch (dbType){
case SqlConstant
.DB_TYPE_MYSQL:
abstractDbBuiler = new MysqlBuilder();
break;
case SqlConstant.DB_TYPE_ORACLE:
abstractDbBuiler = new OracleBuiler();
break;
}
return abstractDbBuiler;
}
}

@ -6,10 +6,17 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/classes" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/test-classes" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.4" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.2" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.40" level="project" />
<orderEntry type="module" module-name="panda-code" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" />

@ -5,7 +5,7 @@
<parent>
<artifactId>panda</artifactId>
<groupId>org.panda</groupId>
<version>2.0</version>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

@ -7,7 +7,7 @@
<groupId>org.panda</groupId>
<artifactId>panda</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<version>2.0.0</version>
<modules>
<module>panda-code</module>
<module>panda-jdbc</module>

Loading…
Cancel
Save