更新代码

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/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> <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" /> <excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <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="module" module-name="panda-code" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" 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: org.apache.commons:commons-lang3:3.4" level="project" />

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>panda</artifactId> <artifactId>panda</artifactId>
<groupId>org.panda</groupId> <groupId>org.panda</groupId>
<version>2.0</version> <version>2.0.0</version>
</parent> </parent>
<packaging>jar</packaging> <packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion> <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/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> <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" /> <excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <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: 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.ow2.asm:asm:7.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.ant:ant:1.10.3" level="project" /> <orderEntry type="library" name="Maven: org.apache.ant:ant:1.10.3" level="project" />

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>panda</artifactId> <artifactId>panda</artifactId>
<groupId>org.panda</groupId> <groupId>org.panda</groupId>
<version>2.0</version> <version>2.0.0</version>
</parent> </parent>
<version>${project.version}</version> <version>${project.version}</version>
<modelVersion>4.0.0</modelVersion> <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/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> <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" /> <excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <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="module" module-name="panda-code" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" 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: org.apache.commons:commons-lang3:3.4" level="project" />

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

@ -1,7 +1,6 @@
package org.panda.beans.util; package org.panda.beans.util;
import com.sun.tools.javac.util.Assert;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -218,7 +217,6 @@ public class BeanUtil {
*/ */
public static <T> T instantiateClass(Class<T> clazz){ public static <T> T instantiateClass(Class<T> clazz){
T t = null; T t = null;
Assert.checkNonNull(clazz);
try { try {
t = clazz.newInstance(); t = clazz.newInstance();
} catch (InstantiationException e) { } catch (InstantiationException e) {
@ -239,7 +237,6 @@ public class BeanUtil {
*/ */
public static <T> T instantiateClass(Class<T> clazz,Object... params){ public static <T> T instantiateClass(Class<T> clazz,Object... params){
T t = null; T t = null;
Assert.checkNonNull(clazz);
Class[] classes = new Class[params.length]; Class[] classes = new Class[params.length];
for (int i=0;i<params.length;i++){ for (int i=0;i<params.length;i++){
classes[i] = params[i].getClass(); 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/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> <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" /> <excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <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: 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: 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" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.6" level="project" />

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

@ -6,10 +6,17 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> <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" /> <excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <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: junit:junit:4.11" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="module" module-name="panda-code" /> <orderEntry type="module" module-name="panda-code" />

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

@ -89,14 +89,15 @@ public abstract class AbstractDbBuiler {
* @return * @return
*/ */
public String countSql(String sql){ public String countSql(String sql){
StringBuffer sb=new StringBuffer("select count(*) from ( "); StringBuffer sb=new StringBuffer("SELECT COUNT(*) FROM ");
sql=sql.toLowerCase(); //SQL 转成大写适
if (sql.lastIndexOf("order")>sql.lastIndexOf(")")){ String upperCaseSql = sql.toUpperCase();
sb.append(sql.substring(sql.indexOf("from")+4,sql.lastIndexOf("order"))); //统计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{ }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(); 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$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> <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" /> <excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <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="module" module-name="panda-code" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" 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: org.apache.commons:commons-lang3:3.4" level="project" />

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

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

Loading…
Cancel
Save