HouseMapper.xml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.template.mapper.HouseMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.template.model.pojo.House" id="HouseTypeMapper">
  6. <result property="id" column="id"/>
  7. <result property="number" column="number"/>
  8. <result property="roomName" column="room_name"/>
  9. <result property="roomType" column="room_type"/>
  10. <result property="roomPrice" column="room_price"/>
  11. <result property="roomArea" column="room_area"/>
  12. <result property="roomLiveTime" column="room_live_time"/>
  13. <result property="receivingTime" column="receiving_time"/>
  14. <result property="visible" column="visible"/>
  15. <result property="roomConfiguration" column="room_configuration"/>
  16. <result property="roomPicture" column="room_picture"/>
  17. </resultMap>
  18. <select id="getPage" resultType="com.template.model.vo.HouseVo">
  19. SELECT
  20. *
  21. FROM
  22. (
  23. SELECT
  24. h.room_live_time AS time,
  25. h.room_name AS `name`,
  26. (SELECT GROUP_CONCAT( DISTINCT hn.room_number ) FROM house_number hn WHERE hn.house_id =h.id and hn.deleted=0) as roomId ,
  27. h.room_price AS price,
  28. h.visible AS visible,
  29. h.number AS count,
  30. h.room_type AS type,
  31. h.id as id
  32. FROM
  33. house h
  34. <where>
  35. h.deleted=0
  36. <if test="keyWord != null and keyWord != ''">
  37. AND h.room_type = #{type}
  38. </if>
  39. </where>
  40. ) h1
  41. <where>
  42. <if test="keyWord != null and keyWord != ''">
  43. and h1.roomId LIKE concat('%',#{keyWord},'%')
  44. </if>
  45. </where>
  46. </select>
  47. <select id="details" resultType="com.template.model.vo.HousedetailsVo">
  48. SELECT
  49. h.*,
  50. ( SELECT GROUP_CONCAT( DISTINCT hn.room_number ) FROM house_number hn WHERE hn.house_id = h.id and hn.deleted=0 ) AS roomIds
  51. FROM
  52. `house` h
  53. WHERE
  54. h.id = #{houseId} AND h.deleted=0
  55. </select>
  56. <select id="roomType" resultType="com.template.model.vo.RoomTypeVo">
  57. SELECT id,room_name,room_type,room_price FROM `house` GROUP BY room_name,room_type,room_price,id
  58. </select>
  59. </mapper>