package com.hx.mybatisTool; import java.util.Map; import com.hx.exception.TipsException; import com.hx.util.SimpleTool; /** * mybatis 自定义处理sql语句 * @author chenjiahe * @Data: 2020-06-08 */ public class SqlParam { private String whereSentence = "1=1"; private String updateSentence; private Map m; /********************mother****************************/ /** * 查询的语句 * @param sql 如:id = #{m.userId} order by age * @param values 存放的值如:values.put("userId","123456") */ public void sqlWhere(String sql,Map values) { if(!SimpleTool.checkNotNull(values)){ throw new TipsException("values is null"); } if(!SimpleTool.checkNotNull(sql)) { sql = "1=1"; } whereSentence = sql; m = values; } /** * 更新语句的语句 * @param sql 如:name = #{m.name},age = ? Where id = #{m.id} * @param values 存放的值 */ public void sqlUpdate(String sql,Map values) { if(!SimpleTool.checkNotNull(values)){ throw new TipsException("values is null"); } m = values; updateSentence = sql; } /************************************************************************/ public String getWhereSentence() { return whereSentence; } public void setWhereSentence(String whereSentence) { this.whereSentence = whereSentence; } public String getUpdateSentence() { return updateSentence; } public void setUpdateSentence(String updateSentence) { this.updateSentence = updateSentence; } public Map getM() { return m; } public void setM(Map m) { this.m = m; } }