From baacdea8338e10fb2779f39703a17074d06df683 Mon Sep 17 00:00:00 2001 From: qi_liang Date: Sat, 2 Nov 2019 02:55:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/panda/jdbc/sql/AbstractDbBuiler.java | 113 ------------------ .../jdbc/sql/factory/DbBuilerFactory.java | 2 +- .../factory/impl/DefaultDbBuilerFactory.java | 6 +- 3 files changed, 4 insertions(+), 117 deletions(-) delete mode 100644 panda-jdbc/src/main/java/org/panda/jdbc/sql/AbstractDbBuiler.java diff --git a/panda-jdbc/src/main/java/org/panda/jdbc/sql/AbstractDbBuiler.java b/panda-jdbc/src/main/java/org/panda/jdbc/sql/AbstractDbBuiler.java deleted file mode 100644 index 44c1a40..0000000 --- a/panda-jdbc/src/main/java/org/panda/jdbc/sql/AbstractDbBuiler.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.panda.jdbc.sql; - -import org.panda.jdbc.mode.Table; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author qi - * 抽象类-sql构造器 - * 实现的子类有: MysqlBuilder ,OragleBuilder (为应对不同数据库特点,有部分方法抽象,由子类实现) - * Created by qi_liang on 2018/6/2. - */ -public abstract class AbstractDbBuiler { - - /** - * 构建更新表结构sql - * @param classSet 实体类集合 - * @param tableList 数据库已存在表集合 - * @return - */ - abstract public String automaticUpdateDb(Set classSet, List tableList); - - /** - *  构建分页sql语句 - * @param sql - * @param pageInterface - * @return - */ - abstract public String concatPageSql(String sql, PageInterface pageInterface); - - - /** - * 构建创建表的sql语句 - * @param clazz 对象的class - * @return 构建好的创建表的sql(类型:String) - */ - abstract public String createTableStr(Class clazz); - - /** - * 构建新增sql语句 - * @param obj - * @return - */ - abstract public String insertSql(Object obj); - - /** - * 构建新增sql语句 - * @param obj - * @param fieldMap - * @return - */ - abstract public String insertSql(Object obj, Map fieldMap); - - /** - * 构建更新sql语句 - * @param obj - * @return - */ - abstract public String updateSql(Object obj); - - /** - * 构建更新sql语句 - * @param obj - * @param fieldMap - * @return - */ - abstract public String updateSql(Object obj, Map fieldMap); - - /** - * 构建删除sql - * @param obj - * @return - */ - abstract public String deleteSql(Object obj); - - /** - * 构建删除sql - * @param obj - * @param fieldMap - * @return - */ - abstract public String deleteSql(Object obj,Map fieldMap); - - /** - * 构建统计sql语句 - * @param sql - * @return - */ - public String countSql(String sql){ - 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(upperCaseSql.indexOf(SqlConstant.FROM_SQL)+SqlConstant.FROM_SQL.length())); - } - return sb.toString(); - } - - - - - - - - - - -} diff --git a/panda-jdbc/src/main/java/org/panda/jdbc/sql/factory/DbBuilerFactory.java b/panda-jdbc/src/main/java/org/panda/jdbc/sql/factory/DbBuilerFactory.java index 9bdbafa..5a9cd26 100644 --- a/panda-jdbc/src/main/java/org/panda/jdbc/sql/factory/DbBuilerFactory.java +++ b/panda-jdbc/src/main/java/org/panda/jdbc/sql/factory/DbBuilerFactory.java @@ -1,7 +1,7 @@ package org.panda.jdbc.sql.factory; -import org.panda.jdbc.sql.AbstractDbBuiler; +import org.panda.jdbc.sql.builder.AbstractDbBuiler; /** * Sql 构造器工厂 diff --git a/panda-jdbc/src/main/java/org/panda/jdbc/sql/factory/impl/DefaultDbBuilerFactory.java b/panda-jdbc/src/main/java/org/panda/jdbc/sql/factory/impl/DefaultDbBuilerFactory.java index 6da25bd..0d6f507 100644 --- a/panda-jdbc/src/main/java/org/panda/jdbc/sql/factory/impl/DefaultDbBuilerFactory.java +++ b/panda-jdbc/src/main/java/org/panda/jdbc/sql/factory/impl/DefaultDbBuilerFactory.java @@ -1,9 +1,9 @@ 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.builder.AbstractDbBuiler; +import org.panda.jdbc.sql.builder.MysqlBuilder; +import org.panda.jdbc.sql.builder.OracleBuiler; import org.panda.jdbc.sql.SqlConstant; import org.panda.jdbc.sql.factory.DbBuilerFactory;