1
0

StoreTopicDao.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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.kmall.admin.dao.mk.store.StoreTopicDao">
  4. <resultMap type="com.kmall.admin.entity.mk.store.StoreTopicEntity" id="storeTopicMap">
  5. <result property="id" column="id"/>
  6. <result property="title" column="title"/>
  7. <result property="content" column="content"/>
  8. <result property="itemPicUrl" column="item_pic_url"/>
  9. <result property="subtitle" column="subtitle"/>
  10. <result property="promTypeId" column="prom_type_id"/>
  11. <result property="topicPrice" column="topic_price"/>
  12. <result property="storeId" column="store_id"/>
  13. <result property="thirdMerchSn" column="third_merch_sn"/>
  14. <result property="isValid" column="is_valid"/>
  15. <result property="note" column="note"/>
  16. <result property="createrSn" column="creater_sn"/>
  17. <result property="createTime" column="create_time"/>
  18. <result property="moderSn" column="moder_sn"/>
  19. <result property="modTime" column="mod_time"/>
  20. <result property="tstm" column="tstm"/>
  21. </resultMap>
  22. <select id="queryObject" resultType="com.kmall.admin.entity.mk.store.StoreTopicEntity">
  23. select
  24. `id`,
  25. `title`,
  26. `content`,
  27. `item_pic_url`,
  28. `subtitle`,
  29. `prom_type_id`,
  30. `topic_price`,
  31. `store_id`,
  32. `third_merch_sn`,
  33. `is_valid`,
  34. `note`,
  35. `creater_sn`,
  36. `create_time`,
  37. `moder_sn`,
  38. `mod_time`,
  39. `tstm`
  40. from mall_store_topic
  41. where id = #{id}
  42. </select>
  43. <select id="queryList" resultType="com.kmall.admin.entity.mk.store.StoreTopicEntity">
  44. SELECT
  45. d.`id`,
  46. d.`title`,
  47. d.`content`,
  48. d.`item_pic_url`,
  49. d.`subtitle`,
  50. d.`prom_type_id`,
  51. pt.prom_type_name 'promTypeName',
  52. d.`topic_price`,
  53. d.`store_id`,
  54. s.store_name 'storeName',
  55. d.`third_merch_sn`,
  56. t.third_party_merch_name 'thirdPartyMerchName',
  57. d.`is_valid`,
  58. d.`note`,
  59. d.`creater_sn`,
  60. d.`create_time`,
  61. d.`moder_sn`,
  62. d.`mod_time`,
  63. d.`tstm`
  64. FROM
  65. mall_store_topic d
  66. LEFT JOIN third_merchant_biz t ON d.third_merch_sn = t.third_merch_sn
  67. LEFT JOIN mk_store_prom_type pt ON d.prom_type_id = pt.prom_type_id
  68. left join mall_store s on d.store_id = s.id
  69. WHERE 1=1
  70. <if test="storeName != null and storeName.trim() != ''">
  71. AND s.store_name LIKE concat('%',#{storeName},'%')
  72. </if>
  73. <if test="storeId != null and storeId != ''">
  74. and d.store_id = #{storeId}
  75. </if>
  76. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  77. and d.third_merch_sn = #{thirdMerchSn}
  78. </if>
  79. <if test="merchSn != null and merchSn != ''">
  80. and t.merch_sn = #{merchSn}
  81. </if>
  82. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode != ''">
  83. AND t.third_party_merch_code = #{thirdPartyMerchCode}
  84. </if>
  85. <choose>
  86. <when test="sidx != null and sidx.trim() != ''">
  87. order by ${sidx} ${order}
  88. </when>
  89. <otherwise>
  90. order by d.id desc
  91. </otherwise>
  92. </choose>
  93. <if test="offset != null and limit != null">
  94. limit #{offset}, #{limit}
  95. </if>
  96. </select>
  97. <select id="queryTotal" resultType="int">
  98. select count(*)
  99. from mall_store_topic d
  100. left join third_merchant_biz t on d.third_merch_sn = t.third_merch_sn
  101. left join mall_store s on d.store_id = s.id
  102. WHERE 1=1
  103. <if test="storeName != null and storeName.trim() != ''">
  104. AND s.store_name LIKE concat('%',#{storeName},'%')
  105. </if>
  106. <if test="storeId != null and storeId != ''">
  107. and d.store_id = #{storeId}
  108. </if>
  109. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  110. and d.third_merch_sn = #{thirdMerchSn}
  111. </if>
  112. <if test="merchSn != null and merchSn != ''">
  113. and t.merch_sn = #{merchSn}
  114. </if>
  115. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode != ''">
  116. AND t.third_party_merch_code = #{thirdPartyMerchCode}
  117. </if>
  118. </select>
  119. <insert id="save" parameterType="com.kmall.admin.entity.mk.store.StoreTopicEntity" useGeneratedKeys="true" keyProperty="id">
  120. insert into mall_store_topic(
  121. `title`,
  122. `content`,
  123. `item_pic_url`,
  124. `subtitle`,
  125. `prom_type_id`,
  126. `topic_price`,
  127. `store_id`,
  128. `third_merch_sn`,
  129. `is_valid`,
  130. `note`,
  131. `creater_sn`,
  132. `create_time`,
  133. `moder_sn`,
  134. `mod_time`,
  135. `tstm`)
  136. values(
  137. #{title},
  138. #{content},
  139. #{itemPicUrl},
  140. #{subtitle},
  141. #{promTypeId},
  142. #{topicPrice},
  143. #{storeId},
  144. #{thirdMerchSn},
  145. #{isValid},
  146. #{note},
  147. #{createrSn},
  148. #{createTime},
  149. #{moderSn},
  150. #{modTime},
  151. #{tstm})
  152. </insert>
  153. <update id="update" parameterType="com.kmall.admin.entity.mk.store.StoreTopicEntity">
  154. update mall_store_topic
  155. <set>
  156. <if test="title != null">`title` = #{title}, </if>
  157. <if test="content != null">`content` = #{content}, </if>
  158. <if test="itemPicUrl != null">`item_pic_url` = #{itemPicUrl}, </if>
  159. <if test="subtitle != null">`subtitle` = #{subtitle}, </if>
  160. <if test="promTypeId != null">`prom_type_id` = #{promTypeId}, </if>
  161. <if test="topicPrice != null">`topic_price` = #{topicPrice}, </if>
  162. <if test="storeId != null">`store_id` = #{storeId}, </if>
  163. <if test="thirdMerchSn != null">`third_merch_sn` = #{thirdMerchSn}, </if>
  164. <if test="isValid != null">`is_valid` = #{isValid}, </if>
  165. <if test="note != null">`note` = #{note}, </if>
  166. <if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
  167. <if test="createTime != null">`create_time` = #{createTime}, </if>
  168. <if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
  169. <if test="modTime != null">`mod_time` = #{modTime}, </if>
  170. <if test="tstm != null">`tstm` = #{tstm}</if>
  171. </set>
  172. where id = #{id}
  173. </update>
  174. <delete id="delete">
  175. delete from mall_store_topic where id = #{value}
  176. </delete>
  177. <delete id="deleteBatch">
  178. delete from mall_store_topic where id in
  179. <foreach item="id" collection="array" open="(" separator="," close=")">
  180. #{id}
  181. </foreach>
  182. </delete>
  183. <select id="queryByStoreIdAndType" resultType="com.kmall.admin.entity.mk.store.StoreTopicEntity">
  184. select
  185. `id`,
  186. `title`,
  187. `content`,
  188. `item_pic_url`,
  189. `subtitle`,
  190. `prom_type_id`,
  191. `topic_price`,
  192. `store_id`,
  193. `third_merch_sn`,
  194. `is_valid`,
  195. `note`,
  196. `creater_sn`,
  197. `create_time`,
  198. `moder_sn`,
  199. `mod_time`,
  200. `tstm`
  201. from mall_store_topic
  202. where prom_type_id = #{promTypeId} and store_id = #{storeId} and is_valid = 0 limit 1
  203. </select>
  204. </mapper>