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

---
 src/main/java/com/hx/mybatisTool/SqlSentence.java |   47 ++++++++++++++++++++++++++---------------------
 1 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/src/main/java/com/hx/mybatisTool/SqlSentence.java b/src/main/java/com/hx/mybatisTool/SqlSentence.java
index 280ef0a..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;
@@ -15,8 +16,6 @@
 	private String sqlSentence;
 
 	private Map<String,Object> m;
-	/**绫诲瀷*/
-	private Integer type = TYPE_NORMAL;
     /**鎺掑簭*/
 	private String orderBy;
     /**寮�濮嬮〉鏁�*/
@@ -25,10 +24,6 @@
 	private Integer pageNum = 0;
 
 	//////////////////////////////////////////////////////////////
-	/**姝e父*/
-	public static final int TYPE_NORMAL = 0;
-	/**鍔ㄦ��*/
-	public static final int TYPE_DYN = 1;
 
 	/********************mother****************************/
 
@@ -91,13 +86,32 @@
 	}
 
 	/**
-	 * 璁剧疆鍔ㄦ�佹煡璇�
-	 * @param map 鏌ヨ
+	 * 鏌ヨ鐨勮鍙�
+	 * @param sql 濡傦細id = #{m.userId} order by age DESC
+	 * @param values 瀛樻斁鐨勫�煎锛歷alues.put("userId","123456")
 	 */
-	public void setDynSql(Map<String, Object> map)
-	{
-		this.type = TYPE_DYN;
-		this.m = map;
+	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;
 	}
 
 	
@@ -117,14 +131,6 @@
 
 	public void setSqlSentence(String sqlSentence) {
 		this.sqlSentence = sqlSentence;
-	}
-
-	public Integer getType() {
-		return type;
-	}
-
-	public void setType(Integer type) {
-		this.type = type;
 	}
 
     public String getOrderBy() {
@@ -155,7 +161,6 @@
     {
         return (startPage - 1) * pageNum;
     }
-
 }
 
 

--
Gitblit v1.8.0