BillMapper.xml

张创琦

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.zcq.dao.BillMapper">
  5. <sql id="selectSql"> SELECT
  6. b.id_ as id, b.title_ as title,
  7. b.bill_time_ as billTime, b.type_id_ as typeId,
  8. b.price_ as price,
  9. b.explain_ as `explain`,
  10. t.name_ as typeName FROM
  11. bill_ as b left join
  12. bill_type_ as t
  13. on
  14. b.type_id_ = t.id_
  15. </sql>
  16. <select id="select" resultType="bill">
  17. <include refid="selectSql"/>
  18. <where>
  19. <if test="typeId !=null"> b.type_id_ = #{typeId}
  20. </if>
  21. <if test="title !=null">
  22. and b.title_ like '%${title}%'
  23. </if>
  24. <if test="date1 !=null">
  25. and b.bill_time_ &gt;= #{date1}
  26. </if>
  27. <if test="date2 !=null">
  28. and b.bill_time_ &lt;= #{date2}
  29. </if>
  30. </where>
  31. </select>
  32. </mapper>