From 3295a41694171ab6695894887c3728efb094e5ad Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期三, 06 四月 2022 15:53:47 +0800
Subject: [PATCH] 优化

---
 src/main/java/com/hx/mybatisTool/SqlSentence.java |   60 ++++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/src/main/java/com/hx/mybatisTool/SqlSentence.java b/src/main/java/com/hx/mybatisTool/SqlSentence.java
index 280ef0a..dd7c9a7 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;
@@ -12,11 +13,13 @@
  */
 public class SqlSentence {
 
+	/**鎵ц璇彞*/
 	private String sqlSentence;
 
+	/**鏂板瀛樺湪鏌ヨ鍒ゆ柇*/
+	private String whereExist;
+
 	private Map<String,Object> m;
-	/**绫诲瀷*/
-	private Integer type = TYPE_NORMAL;
     /**鎺掑簭*/
 	private String orderBy;
     /**寮�濮嬮〉鏁�*/
@@ -25,10 +28,6 @@
 	private Integer pageNum = 0;
 
 	//////////////////////////////////////////////////////////////
-	/**姝e父*/
-	public static final int TYPE_NORMAL = 0;
-	/**鍔ㄦ��*/
-	public static final int TYPE_DYN = 1;
 
 	/********************mother****************************/
 
@@ -91,13 +90,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 +135,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() {
@@ -156,6 +166,16 @@
         return (startPage - 1) * pageNum;
     }
 
+	public String getWhereExist() {
+		return whereExist;
+	}
+
+	public void setWhereExist(String whereExist) {
+		if(StringUtils.isNull(whereExist)){
+			whereExist = null;
+		}
+		this.whereExist = whereExist;
+	}
 }
 
 

--
Gitblit v1.8.0