HouseMapper.xml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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)
  27. as roomId ,
  28. h.room_price AS price,
  29. h.visible AS visible,
  30. h.number AS count,
  31. h.room_type AS type,
  32. h.id as id
  33. FROM
  34. house h
  35. <where>
  36. h.deleted=0
  37. <if test="keyWord != null and keyWord != ''">
  38. AND h.room_type = #{type}
  39. </if>
  40. </where>
  41. ) h1
  42. <where>
  43. <if test="keyWord != null and keyWord != ''">
  44. and h1.roomId LIKE concat('%',#{keyWord},'%')
  45. </if>
  46. </where>
  47. </select>
  48. <select id="details" resultType="com.template.model.vo.HousedetailsVo">
  49. SELECT h.*,
  50. (SELECT GROUP_CONCAT(DISTINCT hn.room_number )
  51. FROM house_number hn
  52. WHERE hn.house_id = h.id
  53. and hn.deleted = 0) AS roomIds
  54. FROM `house` h
  55. WHERE h.id = #{houseId}
  56. AND h.deleted = 0
  57. </select>
  58. <select id="roomType" resultType="com.template.model.vo.RoomTypeVo">
  59. SELECT id, room_name, room_type, room_price
  60. FROM `house`
  61. where deleted = 0
  62. GROUP BY room_name, room_type, room_price, id
  63. </select>
  64. </mapper>