ActiveMapper.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.caimei.modules.homepage.dao.ActiveDao">
  6. <insert id="insertActive" keyColumn="id" keyProperty="id" parameterType="com.caimei.modules.homepage.enity.Active"
  7. useGeneratedKeys="true">
  8. insert into cm_mall_active (organizeId, topic, enabledStatus, activeType, addTime)
  9. VALUES (#{organizeId}, #{topic}, #{enabledStatus}, #{activeType}, now())
  10. </insert>
  11. <insert id="insertImages" keyColumn="id" keyProperty="id"
  12. parameterType="com.caimei.modules.homepage.enity.ActiveImages"
  13. useGeneratedKeys="true">
  14. insert into cm_mall_active_image(activeId, image,topic)
  15. VALUES (#{activeId}, #{image},#{topic})
  16. </insert>
  17. <insert id="insertProducts">
  18. insert into cm_mall_active_product(activeId, productId, sort)
  19. VALUES (#{id}, #{productId}, #{sort})
  20. </insert>
  21. <insert id="insertImageProduct">
  22. insert into cm_mall_active_product(activeId, imageId, productId, sort)
  23. values (#{activeId}, #{imageId},#{productId}, #{sort})
  24. </insert>
  25. <update id="updateActive">
  26. update cm_mall_active
  27. <set>
  28. <if test="topic != null and topic !=''">
  29. topic = #{topic},
  30. </if>
  31. <if test="enabledStatus != null">
  32. enabledStatus = #{enabledStatus}
  33. </if>
  34. </set>
  35. where id = #{id}
  36. </update>
  37. <update id="checkActiveStatus">
  38. UPDATE cm_mall_active
  39. SET enabledStatus=
  40. (CASE
  41. WHEN enabledStatus = 1
  42. THEN 0
  43. ELSE 1 END)
  44. WHERE id = #{id}
  45. </update>
  46. <delete id="delProducts">
  47. delete
  48. from cm_mall_active_product
  49. where activeId = #{id}
  50. </delete>
  51. <delete id="delImages">
  52. delete
  53. from cm_mall_active_image
  54. where activeId = #{id}
  55. </delete>
  56. <delete id="delActive">
  57. delete
  58. from cm_mall_active
  59. where id = #{id}
  60. </delete>
  61. <delete id="delActiveImage">
  62. delete
  63. from cm_mall_active_image
  64. where activeId = #{id}
  65. </delete>
  66. <delete id="delActiveProduct">
  67. delete
  68. from cm_mall_active_product
  69. where activeId = #{id}
  70. </delete>
  71. <select id="findActiveList" resultType="com.caimei.modules.homepage.enity.Active">
  72. select id, organizeId, topic, enabledstatus, activeType, addtime
  73. from cm_mall_active
  74. <where>
  75. organizeID = #{organizeId}
  76. <if test="topic != null and topic != ''">
  77. AND topic LIKE concat('%',#{topic},'%')
  78. </if>
  79. <if test="enabledStatus != null">
  80. AND enabledStatus = #{enabledStatus}
  81. </if>
  82. <if test="activeType !=null">
  83. AND activeType = #{activeType}
  84. </if>
  85. </where>
  86. order by addTime desc
  87. </select>
  88. <select id="findActiveById" resultType="com.caimei.modules.homepage.enity.Active">
  89. select id, organizeId, topic, enabledStatus, activeType, addTime
  90. from cm_mall_active
  91. where id = #{id}
  92. </select>
  93. <select id="findImageList" resultType="com.caimei.modules.homepage.enity.ActiveImages">
  94. select id, image, topic
  95. from cm_mall_active_image
  96. where activeId = #{id}
  97. </select>
  98. <select id="findProducts" resultType="com.caimei.modules.homepage.enity.BackProduct">
  99. select DISTINCT p.name as productName,
  100. p.mainImage,
  101. cmop.productId as productId,
  102. cmop.validFlag,
  103. cmp.sort
  104. from cm_mall_active_product cmp
  105. left join cm_organize_product_info cmop on cmp.productId = cmop.productId
  106. left join product p on cmop.productId = p.productID
  107. where cmp.activeId = #{id} and cmop.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=p.productID)
  108. </select>
  109. <select id="findProductsByImage" resultType="com.caimei.modules.homepage.enity.BackProduct">
  110. select DISTINCT p.name as productName,
  111. p.mainImage,
  112. cmop.productId as productId,
  113. cmop.validFlag,
  114. cmp.sort
  115. from cm_mall_active_product cmp
  116. left join cm_organize_product_info cmop on cmp.productId = cmop.productId
  117. left join product p on cmop.productId = p.productID
  118. where cmp.imageId = #{id} and cmop.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=p.productID)
  119. </select>
  120. </mapper>