From 8cd56e0d8686cd001c8f7f69a4a4179ea1c47994 Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期五, 19 八月 2022 18:29:35 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/main/java/com/hx/mybatisTool/SqlSentence.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/hx/mybatisTool/SqlSentence.java b/src/main/java/com/hx/mybatisTool/SqlSentence.java index a888e46..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,7 +13,11 @@ */ public class SqlSentence { + /**鎵ц璇彞*/ private String sqlSentence; + + /**鏂板瀛樺湪鏌ヨ鍒ゆ柇*/ + private String whereExist; private Map<String,Object> m; /**鎺掑簭*/ @@ -84,6 +89,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; + } + /************************************************************************/ @@ -132,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