ChenJiaHe
2020-10-16 9338de936e527c7c8399e5225583745f76c6f441
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;
   //////////////////////////////////////////////////////////////
   /**正常*/
   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 存放的值如:values.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;
    }
}