chenjiahe
2023-07-17 d4fa5269e214e8bbe1f7dd79a922cefe9fc9916b
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 存放的值如:values.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;
   }
}