BlowoutRecord.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.poyee.mapper.BlowoutRecordMapper">
  6. <resultMap id="BlowoutRecordResultMap" type="com.poyee.dto.BlowoutRecordDto">
  7. <!-- BlowoutDetailRecord 表映射 -->
  8. <id property="blowoutDetailRecord.id" column="t1_id"/>
  9. <result property="blowoutDetailRecord.url" column="t1_url"/>
  10. <result property="blowoutDetailRecord.images" column="t1_images"/>
  11. <result property="blowoutDetailRecord.configuration" column="t1_configuration"/>
  12. <result property="blowoutDetailRecord.productHighlights" column="t1_product_highlights"/>
  13. <result property="blowoutDetailRecord.boxBreak" column="t1_box_break"/>
  14. <result property="blowoutDetailRecord.releaseDate" column="t1_release_date"/>
  15. <result property="blowoutDetailRecord.productYear" column="t1_product_year"/>
  16. <result property="blowoutDetailRecord.brand" column="t1_brand"/>
  17. <result property="blowoutDetailRecord.sport" column="t1_sport"/>
  18. <result property="blowoutDetailRecord.boxStyle" column="t1_box_style"/>
  19. <result property="blowoutDetailRecord.promo" column="t1_promo"/>
  20. <result property="blowoutDetailRecord.gmtCreateTime" column="t1_gmt_create_time"/>
  21. <result property="blowoutDetailRecord.imageUri" column="t1_image_uri"/>
  22. <result property="blowoutDetailRecord.imageStat" column="t1_image_stat"/>
  23. <result property="blowoutDetailRecord.gmtModifiedTime" column="t1_gmt_modified_time"/>
  24. <!-- BlowoutRecordNewDailyNew 表映射 -->
  25. <result property="blowoutRecordNewDailyNew.id" column="t2_id"/>
  26. <result property="blowoutRecordNewDailyNew.img" column="t2_img"/>
  27. <result property="blowoutRecordNewDailyNew.title" column="t2_title"/>
  28. <result property="blowoutRecordNewDailyNew.price" column="t2_price"/>
  29. <result property="blowoutRecordNewDailyNew.suggestedPrice" column="t2_suggestedPrice"/>
  30. <result property="blowoutRecordNewDailyNew.href" column="t2_href"/>
  31. <result property="blowoutRecordNewDailyNew.category" column="t2_category"/>
  32. <result property="blowoutRecordNewDailyNew.preorder" column="t2_preorder"/>
  33. <result property="blowoutRecordNewDailyNew.newField" column="t2_newField"/>
  34. <result property="blowoutRecordNewDailyNew.detailState" column="t2_detailState"/>
  35. <result property="blowoutRecordNewDailyNew.lowState" column="t2_lowState"/>
  36. <result property="blowoutRecordNewDailyNew.firstCreateTime" column="t2_firstCreateTime"/>
  37. <result property="blowoutRecordNewDailyNew.gmtCreateTime" column="t2_gmtCreateTime"/>
  38. <result property="blowoutRecordNewDailyNew.gmtModifiedTime" column="t2_gmtModifiedTime"/>
  39. </resultMap>
  40. <resultMap id="BlowoutRecordGroupResultMap" type="com.poyee.dto.BlowoutRecordGroupDto">
  41. <result property="releaseDate" column="t1_release_date"/>
  42. <result property="productYear" column="t1_product_year"/>
  43. <result property="brand" column="t1_brand"/>
  44. <result property="sport" column="t1_sport"/>
  45. <result property="boxStyle" column="t1_box_style"/>
  46. <result property="title" column="t2_title"/>
  47. <result property="price" column="t2_price"/>
  48. <result property="suggestedPrice" column="t2_suggestedPrice"/>
  49. <result property="category" column="t2_category"/>
  50. </resultMap>
  51. <select id="getBlowoutRecordsByPage" resultMap="BlowoutRecordResultMap">
  52. SELECT
  53. t1.id as t1_id,
  54. t1.url as t1_url,
  55. t1.images as t1_images,
  56. t1.configuration as t1_configuration,
  57. t1.product_highlights as t1_product_highlights,
  58. t1.box_break as t1_box_break,
  59. t1.release_date as t1_release_date,
  60. t1.product_year as t1_product_year,
  61. t1.brand as t1_brand,
  62. t1.sport as t1_sport,
  63. t1.box_style as t1_box_style,
  64. t1.promo as t1_promo,
  65. t1.gmt_create_time as t1_gmt_create_time,
  66. t1.image_uri as t1_image_uri,
  67. t1.image_stat as t1_image_stat,
  68. t1.gmt_modified_time as t1_gmt_modified_time,
  69. t2.id as t2_id,
  70. t2.img as t2_img,
  71. t2.title as t2_title,
  72. t2.price as t2_price,
  73. t2.suggested_Price as t2_suggestedPrice,
  74. t2.href as t2_href,
  75. t2.category as t2_category,
  76. t2.preorder as t2_preorder,
  77. t2.new as t2_newField,
  78. t2.detail_State as t2_detailState,
  79. t2.low_State as t2_lowState,
  80. t2.first_Create_Time as t2_firstCreateTime,
  81. t2.gmt_Create_Time as t2_gmtCreateTime,
  82. t2.gmt_Modified_Time as t2_gmtModifiedTime
  83. FROM blowout_detail_record t1
  84. INNER JOIN blowout_record_new_daily_new t2 ON t1.url = 'https://www.blowoutcards.com' || t2.href
  85. <where>
  86. <if test="releaseDatePattern != null and releaseDatePattern != ''">
  87. t1.release_date LIKE CONCAT(#{releaseDatePattern}, '%')
  88. </if>
  89. <if test="productYear != null and productYear != ''">
  90. AND t1.product_year = #{productYear}
  91. </if>
  92. <if test="brand != null and brand != ''">
  93. AND LOWER(t1.brand) = LOWER(#{brand})
  94. </if>
  95. <if test="category != null and category != ''">
  96. AND LOWER(t2.category) = LOWER(#{category})
  97. </if>
  98. </where>
  99. ORDER BY t1.id DESC
  100. LIMIT #{limit} OFFSET #{offset};
  101. </select>
  102. <select id="getLatestBlowoutRecordsByGroup" resultMap="BlowoutRecordGroupResultMap">
  103. SELECT
  104. t1_release_date,
  105. t1_product_year,
  106. t1_brand,
  107. t1_sport,
  108. t1_box_style,
  109. t2_title,
  110. t2_price,
  111. t2_suggestedPrice,
  112. t2_category
  113. FROM (
  114. SELECT
  115. t1.release_date as t1_release_date,
  116. t1.product_year as t1_product_year,
  117. t1.brand as t1_brand,
  118. t1.sport as t1_sport,
  119. t1.box_style as t1_box_style,
  120. t2.title as t2_title,
  121. t2.price as t2_price,
  122. t2.suggested_Price as t2_suggestedPrice,
  123. t2.category as t2_category,
  124. ROW_NUMBER() OVER (
  125. PARTITION BY t1.product_year, t1.brand, t1.sport, t1.box_style, t2.title, t2.category
  126. ORDER BY t1.gmt_create_time DESC
  127. ) as rn
  128. FROM blowout_detail_record t1
  129. left JOIN blowout_record_new_daily_new t2 ON t1.url = 'https://www.blowoutcards.com' || t2.href
  130. <where>
  131. <if test="releaseDatePattern != null and releaseDatePattern != ''">
  132. t1.release_date LIKE CONCAT(#{releaseDatePattern}, '%')
  133. </if>
  134. <if test="productYear != null and productYear != ''">
  135. AND t1.product_year = #{productYear}
  136. </if>
  137. <if test="brand != null and brand != ''">
  138. AND LOWER(t1.brand) = LOWER(#{brand})
  139. </if>
  140. <if test="category != null and category != ''">
  141. AND LOWER(t1.sport) = LOWER(#{category})
  142. </if>
  143. </where>
  144. ) subquery
  145. WHERE rn = 1
  146. ORDER BY to_date(t1_release_date, 'Mon DD, YYYY') ASC;
  147. </select>
  148. </mapper>