From 9338de936e527c7c8399e5225583745f76c6f441 Mon Sep 17 00:00:00 2001
From: ChenJiaHe <763432473@qq.com>
Date: 星期五, 16 十月 2020 12:15:31 +0800
Subject: [PATCH] 优化

---
 /dev/null                                                       |   76 -------------------------
 src/main/java/com/hx/common/service/impl/CommonServiceImpl.java |   13 ++--
 src/main/java/com/hx/common/service/impl/CommonDaoImpl.java     |   13 ++--
 src/main/java/com/hx/mybatisTool/SqlSentence.java               |   31 ++++++++++
 src/main/java/com/hx/common/service/CommonService.java          |   13 ++--
 src/main/java/com/hx/common/dao/CommonDao.java                  |   13 ++--
 6 files changed, 54 insertions(+), 105 deletions(-)

diff --git a/src/main/java/com/hx/common/dao/CommonDao.java b/src/main/java/com/hx/common/dao/CommonDao.java
index 44f7419..138a0c5 100644
--- a/src/main/java/com/hx/common/dao/CommonDao.java
+++ b/src/main/java/com/hx/common/dao/CommonDao.java
@@ -1,5 +1,4 @@
 package com.hx.common.dao;
-import com.hx.mybatisTool.SqlParam;
 import com.hx.mybatisTool.SqlSentence;
 
 import java.io.Serializable;
@@ -23,10 +22,10 @@
 
 	/**鏌ヨ鏉℃暟
 	 * @param mapperClass mapper绫�
-	 * @param sqlParam  鏌ヨ鍙傛暟绫�
+	 * @param sqlSentence  鏌ヨ鍙傛暟绫�
 	 * @return 杩斿洖鏉℃暟
 	 */
-	<T extends Serializable> int selectCount(Class<?> mapperClass, SqlParam sqlParam);
+	<T extends Serializable> int selectCount(Class<?> mapperClass, SqlSentence sqlSentence);
 
 	/**鏌ヨ鍒楄〃锛岃繑鍥炲疄浣撶被鐨凩ist
 	 * @param mapperClass mapper绫�
@@ -72,10 +71,10 @@
 
 	/**鏇存柊锛岃繑鍥炴洿鏂版暟閲�
 	 * @param mapperClass mapper绫�
-	 * @param sqlParam 鏌ヨ鍙傛暟绫�
+	 * @param sqlSentence 鏌ヨ鍙傛暟绫�
 	 * @return 杩斿洖鏉℃暟
 	 */
-	<T extends Serializable> int updateWhere(Class<?> mapperClass, SqlParam sqlParam);
+	<T extends Serializable> int updateWhere(Class<?> mapperClass, SqlSentence sqlSentence);
 
 	/**鏇存柊锛岃繑鍥炴洿鏂版暟閲�
 	 * @param mapperClass mapper绫�
@@ -86,10 +85,10 @@
 
 	/**鍒犻櫎锛岃繑鍥炲垹闄ゆ暟閲�
 	 * @param mapperClass mapper绫�
-	 * @param sqlParam 鏌ヨ鍙傛暟绫�
+	 * @param sqlSentence 鏌ヨ鍙傛暟绫�
 	 * @return 杩斿洖鏉℃暟
 	 */
-	<T extends Serializable> int deleteWhere(Class<?> mapperClass, SqlParam sqlParam);
+	<T extends Serializable> int deleteWhere(Class<?> mapperClass, SqlSentence sqlSentence);
 
 	/**鍒犻櫎锛岃繑鍥炲垹闄ゆ暟閲�
 	 * @param mapperClass mapper绫�
diff --git a/src/main/java/com/hx/common/service/CommonService.java b/src/main/java/com/hx/common/service/CommonService.java
index 94fbdd9..64164ec 100644
--- a/src/main/java/com/hx/common/service/CommonService.java
+++ b/src/main/java/com/hx/common/service/CommonService.java
@@ -1,5 +1,4 @@
 package com.hx.common.service;
-import com.hx.mybatisTool.SqlParam;
 import com.hx.mybatisTool.SqlSentence;
 
 import java.io.Serializable;
@@ -23,10 +22,10 @@
 
 	/**鏌ヨ鏉℃暟
 	 * @param mapperClass mapper绫�
-	 * @param sqlParam  鏌ヨ鍙傛暟绫�
+	 * @param sqlSentence  鏌ヨ鍙傛暟绫�
 	 * @return 杩斿洖鏉℃暟
 	 */
-	<T extends Serializable> int selectCount(Class<?> mapperClass, SqlParam sqlParam);
+	<T extends Serializable> int selectCount(Class<?> mapperClass, SqlSentence sqlSentence);
 
 	/**鏌ヨ鍒楄〃锛岃繑鍥炲疄浣撶被鐨凩ist
 	 * @param mapperClass mapper绫�
@@ -72,10 +71,10 @@
 
 	/**鏇存柊锛岃繑鍥炴洿鏂版暟閲�
 	 * @param mapperClass mapper绫�
-	 * @param sqlParam 鏌ヨ鍙傛暟绫�
+	 * @param sqlSentence 鏌ヨ鍙傛暟绫�
 	 * @return 杩斿洖鏉℃暟
 	 */
-	<T extends Serializable> int updateWhere(Class<?> mapperClass, SqlParam sqlParam);
+	<T extends Serializable> int updateWhere(Class<?> mapperClass, SqlSentence sqlSentence);
 
 	/**鏇存柊锛岃繑鍥炴洿鏂版暟閲�
 	 * @param mapperClass mapper绫�
@@ -86,10 +85,10 @@
 
 	/**鍒犻櫎锛岃繑鍥炲垹闄ゆ暟閲�
 	 * @param mapperClass mapper绫�
-	 * @param sqlParam 鏌ヨ鍙傛暟绫�
+	 * @param sqlSentence 鏌ヨ鍙傛暟绫�
 	 * @return 杩斿洖鏉℃暟
 	 */
-	<T extends Serializable> int deleteWhere(Class<?> mapperClass, SqlParam sqlParam);
+	<T extends Serializable> int deleteWhere(Class<?> mapperClass, SqlSentence sqlSentence);
 
 	/**鍒犻櫎锛岃繑鍥炲垹闄ゆ暟閲�
 	 * @param mapperClass mapper绫�
diff --git a/src/main/java/com/hx/common/service/impl/CommonDaoImpl.java b/src/main/java/com/hx/common/service/impl/CommonDaoImpl.java
index 4bc281b..388fcd3 100644
--- a/src/main/java/com/hx/common/service/impl/CommonDaoImpl.java
+++ b/src/main/java/com/hx/common/service/impl/CommonDaoImpl.java
@@ -1,7 +1,6 @@
 package com.hx.common.service.impl;
 
 import com.hx.common.dao.CommonDao;
-import com.hx.mybatisTool.SqlParam;
 import com.hx.mybatisTool.SqlSentence;
 import org.apache.ibatis.session.SqlSessionFactory;
 import org.springframework.stereotype.Service;
@@ -31,8 +30,8 @@
 
     /**鑾峰彇鏉℃暟*/
     @Override
-    public <T extends Serializable> int selectCount(Class<?> mapperClass,SqlParam sqlParam) {
-        return sqlSessionFactory.openSession().selectOne(getStatement(mapperClass,"selectCount"),sqlParam);
+    public <T extends Serializable> int selectCount(Class<?> mapperClass,SqlSentence sqlSentence) {
+        return sqlSessionFactory.openSession().selectOne(getStatement(mapperClass,"selectCount"),sqlSentence);
     }
 
     /**鑾峰彇鍒楄〃*/
@@ -73,8 +72,8 @@
 
     /**鏇存柊*/
     @Override
-    public <T extends Serializable> int updateWhere(Class<?> mapperClass,SqlParam sqlParam) {
-        return sqlSessionFactory.openSession().update(getStatement(mapperClass,"updateWhere"),sqlParam);
+    public <T extends Serializable> int updateWhere(Class<?> mapperClass,SqlSentence sqlSentence) {
+        return sqlSessionFactory.openSession().update(getStatement(mapperClass,"updateWhere"),sqlSentence);
     }
 
     /**鍏ㄩ儴瀛楁鏇存柊*/
@@ -85,8 +84,8 @@
 
     /**鍒犻櫎*/
     @Override
-    public <T extends Serializable> int deleteWhere(Class<?> mapperClass,SqlParam sqlParam) {
-        return sqlSessionFactory.openSession().delete(getStatement(mapperClass,"deleteWhere"),sqlParam);
+    public <T extends Serializable> int deleteWhere(Class<?> mapperClass,SqlSentence sqlSentence) {
+        return sqlSessionFactory.openSession().delete(getStatement(mapperClass,"deleteWhere"),sqlSentence);
     }
 
     /**鍒犻櫎*/
diff --git a/src/main/java/com/hx/common/service/impl/CommonServiceImpl.java b/src/main/java/com/hx/common/service/impl/CommonServiceImpl.java
index 668f428..7d911eb 100644
--- a/src/main/java/com/hx/common/service/impl/CommonServiceImpl.java
+++ b/src/main/java/com/hx/common/service/impl/CommonServiceImpl.java
@@ -2,7 +2,6 @@
 
 import com.hx.common.dao.CommonDao;
 import com.hx.common.service.CommonService;
-import com.hx.mybatisTool.SqlParam;
 import com.hx.mybatisTool.SqlSentence;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -28,8 +27,8 @@
 
     /**鑾峰彇鏉℃暟*/
     @Override
-    public <T extends Serializable> int selectCount(Class<?> mapperClass,SqlParam sqlParam) {
-        return commonDao.selectCount(mapperClass,sqlParam);
+    public <T extends Serializable> int selectCount(Class<?> mapperClass,SqlSentence sqlSentence) {
+        return commonDao.selectCount(mapperClass,sqlSentence);
     }
 
     /**鑾峰彇鍒楄〃*/
@@ -70,8 +69,8 @@
 
     /**鏇存柊*/
     @Override
-    public <T extends Serializable> int updateWhere(Class<?> mapperClass,SqlParam sqlParam) {
-        return commonDao.updateWhere(mapperClass,sqlParam);
+    public <T extends Serializable> int updateWhere(Class<?> mapperClass,SqlSentence sqlSentence) {
+        return commonDao.updateWhere(mapperClass,sqlSentence);
     }
 
     /**鍏ㄩ儴瀛楁鏇存柊*/
@@ -82,8 +81,8 @@
 
     /**鍒犻櫎*/
     @Override
-    public <T extends Serializable> int deleteWhere(Class<?> mapperClass,SqlParam sqlParam) {
-        return commonDao.deleteWhere(mapperClass,sqlParam);
+    public <T extends Serializable> int deleteWhere(Class<?> mapperClass,SqlSentence sqlSentence) {
+        return commonDao.deleteWhere(mapperClass,sqlSentence);
     }
 
     /**鍒犻櫎*/
diff --git a/src/main/java/com/hx/mybatisTool/SqlParam.java b/src/main/java/com/hx/mybatisTool/SqlParam.java
deleted file mode 100644
index 2586164..0000000
--- a/src/main/java/com/hx/mybatisTool/SqlParam.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.hx.mybatisTool;
-
-import com.hx.exception.TipsException;
-import com.hx.util.SimpleTool;
-
-import java.util.Map;
-
-/**
- * mybatis 鑷畾涔夊鐞唖ql璇彞
- * @author chenjiahe
- * @Data: 2020-06-08
- */
-public class SqlParam {
-	
-	private String whereSentence = "1=1";
-	private String updateSentence;
-	private Map<String,Object> m;
-	
-	/********************mother****************************/
-	/**
-	 * 鏌ヨ鐨勮鍙�
-	 * @param sql 濡傦細id = #{m.userId} order by age
-	 * @param values 瀛樻斁鐨勫�煎锛歷alues.put("userId","123456")
-	 */
-	public void sqlWhere(String sql,Map<String,Object> values) {
-		if(!SimpleTool.checkNotNull(values)){
-			throw new TipsException("values is null");
-		}
-		if(!SimpleTool.checkNotNull(sql)) {
-			sql = "1=1";
-		}
-		whereSentence = sql;
-		m = values;
-	}
-	
-	/**
-	 * 鏇存柊璇彞鐨勮鍙�
-	 * @param sql 濡傦細name = #{m.name},age = ? Where id = #{m.id}
-	 * @param values 瀛樻斁鐨勫��
-	 */
-	public void sqlUpdate(String sql,Map<String,Object> values) {
-		if(!SimpleTool.checkNotNull(values)){
-			throw new TipsException("values is null");
-		}
-		m = values;
-		updateSentence = sql;
-	}
-	
-	/************************************************************************/
-
-	public String getWhereSentence() {
-		return whereSentence;
-	}
-
-	public void setWhereSentence(String whereSentence) {
-		this.whereSentence = whereSentence;
-	}
-
-	public String getUpdateSentence() {
-		return updateSentence;
-	}
-
-	public void setUpdateSentence(String updateSentence) {
-		this.updateSentence = updateSentence;
-	}
-
-	public Map<String, Object> getM() {
-		return m;
-	}
-
-	public void setM(Map<String, Object> m) {
-		this.m = m;
-	}
-
-}
-
diff --git a/src/main/java/com/hx/mybatisTool/SqlSentence.java b/src/main/java/com/hx/mybatisTool/SqlSentence.java
index a888e46..e0705c9 100644
--- a/src/main/java/com/hx/mybatisTool/SqlSentence.java
+++ b/src/main/java/com/hx/mybatisTool/SqlSentence.java
@@ -1,6 +1,7 @@
 package com.hx.mybatisTool;
 
 import com.hx.exception.TipsException;
+import com.hx.util.SimpleTool;
 import com.hx.util.StringUtils;
 
 import java.util.Map;
@@ -84,6 +85,35 @@
 		m = values;
 	}
 
+	/**
+	 * 鏌ヨ鐨勮鍙�
+	 * @param sql 濡傦細id = #{m.userId} order by age DESC
+	 * @param values 瀛樻斁鐨勫�煎锛歷alues.put("userId","123456")
+	 */
+	public void sqlWhere(String sql,Map<String,Object> values) {
+		if(!SimpleTool.checkNotNull(values)){
+			throw new TipsException("values is null");
+		}
+		if(!SimpleTool.checkNotNull(sql)) {
+			sql = "1=1";
+		}
+		sqlSentence = sql;
+		m = values;
+	}
+
+	/**
+	 * 鏇存柊璇彞鐨勮鍙�
+	 * @param sql 濡傦細name = #{m.name},age = ? WHERE id = #{m.id}
+	 * @param values 瀛樻斁鐨勫��
+	 */
+	public void sqlUpdate(String sql,Map<String,Object> values) {
+		if(!SimpleTool.checkNotNull(values)){
+			throw new TipsException("values is null");
+		}
+		m = values;
+		sqlSentence = sql;
+	}
+
 	
 	/************************************************************************/
 
@@ -131,7 +161,6 @@
     {
         return (startPage - 1) * pageNum;
     }
-
 }
 
 

--
Gitblit v1.8.0