CmPageCentreMapper.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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.caimei.modules.cmpage.dao.CmPageCentreDao">
  4. <sql id="cmPageCentreColumns">
  5. a.id AS "id",
  6. a.pageId AS "pageId",
  7. a.title AS "title",
  8. a.link AS "link",
  9. a.sort AS "sort",
  10. a.description AS "description",
  11. a.enabledStatus AS "enabledStatus",
  12. a.crmEnabledStatus AS "crmEnabledStatus",
  13. a.createBy AS "createBy.id",
  14. a.createDate AS "createDate",
  15. a.updateBy AS "updateBy.id",
  16. a.updateDate AS "updateDate",
  17. (SELECT count(1) FROM cm_page_centre_image a1 WHERE a1.centreId = a.id ) imageNum
  18. </sql>
  19. <sql id="cmPageCentreJoins">
  20. </sql>
  21. <select id="get" resultType="CmPageCentre">
  22. SELECT
  23. <include refid="cmPageCentreColumns"/>
  24. FROM cm_page_centre a
  25. <include refid="cmPageCentreJoins"/>
  26. WHERE a.id = #{id}
  27. </select>
  28. <select id="findList" resultType="CmPageCentre">
  29. SELECT
  30. <include refid="cmPageCentreColumns"/>
  31. FROM cm_page_centre a
  32. <include refid="cmPageCentreJoins"/>
  33. <where>
  34. <if test="pageId != null and pageId != ''">
  35. AND a.pageId = #{pageId}
  36. </if>
  37. <if test="title != null and title != ''">
  38. AND a.title LIKE
  39. <if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
  40. <if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
  41. <if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
  42. </if>
  43. </where>
  44. <choose>
  45. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  46. ORDER BY ${page.orderBy}
  47. </when>
  48. <otherwise>
  49. ORDER BY -a.sort DESC,a.createDate DESC
  50. </otherwise>
  51. </choose>
  52. </select>
  53. <select id="findAllList" resultType="CmPageCentre">
  54. SELECT
  55. <include refid="cmPageCentreColumns"/>
  56. FROM cm_page_centre a
  57. <include refid="cmPageCentreJoins"/>
  58. <where>
  59. </where>
  60. <choose>
  61. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  62. ORDER BY ${page.orderBy}
  63. </when>
  64. <otherwise>
  65. </otherwise>
  66. </choose>
  67. </select>
  68. <insert id="insert" parameterType="CmPageCentre" keyProperty="id" useGeneratedKeys="true">
  69. INSERT INTO cm_page_centre(
  70. pageId,
  71. title,
  72. link,
  73. sort,
  74. description,
  75. enabledStatus,
  76. crmEnabledStatus,
  77. createBy,
  78. createDate,
  79. updateBy,
  80. updateDate
  81. ) VALUES (
  82. #{pageId},
  83. #{title},
  84. #{link},
  85. #{sort},
  86. #{description},
  87. #{enabledStatus},
  88. #{crmEnabledStatus},
  89. #{createBy.id},
  90. #{createDate},
  91. #{updateBy.id},
  92. #{updateDate}
  93. )
  94. </insert>
  95. <update id="update">
  96. UPDATE cm_page_centre SET
  97. pageId = #{pageId},
  98. title = #{title},
  99. link = #{link},
  100. sort = #{sort},
  101. description = #{description},
  102. enabledStatus = #{enabledStatus},
  103. crmEnabledStatus = #{crmEnabledStatus},
  104. updateBy = #{updateBy.id},
  105. updateDate = #{updateDate}
  106. WHERE id = #{id}
  107. </update>
  108. <delete id="delete">
  109. DELETE FROM cm_page_centre
  110. WHERE id = #{id}
  111. </delete>
  112. <update id="updateEnabledStatusByIds">
  113. UPDATE cm_page_centre a SET a.enabledStatus = #{param1}
  114. WHERE a.id IN
  115. <foreach collection="param2" item="id" index="index" open="(" separator="," close=")">
  116. #{id}
  117. </foreach>
  118. </update>
  119. <delete id="deletePageCentreImage">
  120. DELETE FROM cm_page_centre_image
  121. WHERE centreId = #{param1}
  122. </delete>
  123. <insert id="insertPageCentreImage">
  124. INSERT INTO cm_page_centre_image(centreId, imageId)
  125. <foreach collection="param2" item="imageId" separator=" union all ">
  126. SELECT #{param1}, #{imageId}
  127. </foreach>
  128. </insert>
  129. <insert id="insetImageActivity">
  130. INSERT INTO cm_page_image_activity(actTypeId, imageId) VALUES(#{actTypeId},#{imageId})
  131. </insert>
  132. <delete id="deleteImageActivity">
  133. DELETE FROM cm_page_image_activity
  134. WHERE imageId = #{imageId}
  135. </delete>
  136. <update id="updateCrmEnabledStatusByIds">
  137. UPDATE cm_page_centre a SET a.crmEnabledStatus = #{param1}
  138. WHERE a.id IN
  139. <foreach collection="param2" item="id" index="index" open="(" separator="," close=")" >
  140. #{id}
  141. </foreach>
  142. </update>
  143. <update id="saveSort">
  144. UPDATE cm_page_centre SET
  145. sort = #{sort}
  146. WHERE id = #{id}
  147. </update>
  148. <select id="findFloorContentByCentreId" resultType="com.caimei.modules.newhome.entity.NewPageFloorContent">
  149. SELECT
  150. npfc.*,
  151. cpc.title AS floorTitle
  152. FROM
  153. cm_page_centre cpc
  154. LEFT JOIN new_page_floor_content npfc ON npfc.centreId = cpc.id
  155. WHERE
  156. cpc.id = #{centreId}
  157. </select>
  158. <select id="findFloorImage" resultType="com.caimei.modules.newhome.entity.NewPageFloorImage">
  159. SELECT
  160. a.id,
  161. a.floorId,
  162. a.centreId,
  163. a.productId,
  164. IF(a.productId IS NULL, a.name, p.name) AS name,
  165. a.content,
  166. a.link,
  167. IF(a.productId IS NULL, a.image, p.mainImage) AS image,
  168. a.appletsImage,
  169. a.adsImage,
  170. a.`label`,
  171. a.pcStatus,
  172. a.appletsStatus,
  173. a.recommend,
  174. a.sort,
  175. a.displaySort,
  176. DATE_FORMAT(a.createDate, '%Y-%m-%d %H:%i:%S') AS createDate,
  177. copi.validFlag,
  178. s.name as shopName
  179. FROM
  180. new_page_floor_image a
  181. LEFT JOIN product p ON a.productId = p.productID
  182. left join cm_organize_product_info copi on copi.productId = p.productID
  183. LEFT JOIN shop s on p.shopID = s.shopID
  184. left join cm_hehe_product chp on a.productId = chp.productId
  185. WHERE
  186. a.centreId = #{centreId}
  187. <if test="type != null and type == '8'">
  188. and chp.id is not null
  189. </if>
  190. group by p.productID
  191. </select>
  192. <select id="findPageTitle" resultType="java.lang.String">
  193. select title from cm_page where id = #{pageId}
  194. </select>
  195. <delete id="deletePageImage">
  196. DELETE cpi,cpci FROM
  197. cm_page_image cpi,
  198. cm_page_centre_image cpci
  199. WHERE
  200. cpi.id = cpci.imageId
  201. AND cpci.centreId = #{centreId}
  202. </delete>
  203. </mapper>