CmHeheFloorProductMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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.hehe.dao.CmHeheFloorProductDao">
  4. <sql id="cmHeheFloorProductColumns">
  5. a.id AS "id",
  6. a.floorId,
  7. a.productId,
  8. a.validFlag,
  9. a.recommend,
  10. a.sort AS "sort",
  11. a.addTime,
  12. p.mainImage,
  13. p.name as productName,
  14. s.name as shopName
  15. </sql>
  16. <sql id="cmHeheFloorProductJoins">
  17. left join cm_hehe_product cp on a.productId = cp.id
  18. left join cm_hehe_floor cf on a.floorId = cf.id
  19. left join product p on cp.productId = p.productID
  20. left join shop s on p.shopID = s.shopID
  21. </sql>
  22. <update id="updateSort">
  23. update cm_hehe_floor_product set sort = #{sort} where id = #{id}
  24. </update>
  25. <select id="get" resultType="cmHeheFloorProduct">
  26. SELECT
  27. <include refid="cmHeheFloorProductColumns"/>
  28. FROM cm_hehe_floor_product a
  29. <include refid="cmHeheFloorProductJoins"/>
  30. WHERE a.id = #{id}
  31. </select>
  32. <select id="findList" resultType="cmHeheFloorProduct">
  33. SELECT
  34. <include refid="cmHeheFloorProductColumns"/>
  35. FROM cm_hehe_floor_product a
  36. <include refid="cmHeheFloorProductJoins"/>
  37. <where>
  38. a.floorId = #{floorId}
  39. <if test="productId != null">
  40. and cp.id = #{productId}
  41. </if>
  42. <if test="productName != null and productName != ''">
  43. and p.name like concat('%',#{productName},'%')
  44. </if>
  45. <if test="shopName != null and shopName != ''">
  46. and s.name like concat('%',#{shopName},'%')
  47. </if>
  48. <if test="validFlag != null">
  49. and a.validFlag = #{validFlag}
  50. </if>
  51. <if test="recommend != null">
  52. and a.recommend = #{recommend}
  53. </if>
  54. </where>
  55. <choose>
  56. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  57. ORDER BY ${page.orderBy}
  58. </when>
  59. <otherwise>
  60. order by a.sort asc,a.addTime desc,a.productId desc
  61. </otherwise>
  62. </choose>
  63. </select>
  64. <select id="findAllList" resultType="cmHeheFloorProduct">
  65. SELECT
  66. <include refid="cmHeheFloorProductColumns"/>
  67. FROM cm_hehe_floor_product a
  68. <include refid="cmHeheFloorProductJoins"/>
  69. <where>
  70. </where>
  71. <choose>
  72. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  73. ORDER BY ${page.orderBy}
  74. </when>
  75. <otherwise>
  76. </otherwise>
  77. </choose>
  78. </select>
  79. <select id="findFloorProductId" resultType="java.lang.Integer">
  80. select productId from cm_hehe_floor_product where floorId = #{floorId}
  81. </select>
  82. <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
  83. select hp.id as productID,p.mainImage,p.name,s.name as shopName
  84. from cm_hehe_product hp left join product p on hp.productId = p.productID
  85. left join shop s on p.shopID = s.shopID
  86. <where>
  87. hp.validFlag = 1
  88. <if test="productID != null" >
  89. AND hp.id = #{productID}
  90. </if>
  91. <if test="name != null and name != ''">
  92. AND p.name LIKE concat('%',#{name},'%')
  93. </if>
  94. <if test="shopName != null and shopName != ''">
  95. AND s.name LIKE concat('%',#{shopName},'%')
  96. </if>
  97. <if test="ids != null and ids.size() > 0 ">
  98. AND hp.id NOT IN
  99. <foreach collection="ids" open="(" close=")" item="id" separator=",">
  100. #{id}
  101. </foreach>
  102. </if>
  103. </where>
  104. <choose>
  105. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  106. ORDER BY ${page.orderBy}
  107. </when>
  108. <otherwise>
  109. order by hp.id
  110. </otherwise>
  111. </choose>
  112. </select>
  113. <insert id="insert" parameterType="cmHeheFloorProduct" keyProperty="id" useGeneratedKeys="true">
  114. INSERT INTO cm_hehe_floor_product(
  115. floorId, productId, validFlag, recommend, sort, addTime
  116. ) VALUES (
  117. #{floorId},
  118. #{productId},
  119. #{validFlag},
  120. #{recommend},
  121. #{sort},
  122. #{addTime}
  123. )
  124. </insert>
  125. <update id="update" parameterType="cmHeheFloorProduct">
  126. update cm_hehe_floor_product set validFlag = #{validFlag},recommend = #{recommend},sort = #{sort}
  127. where id = #{id}
  128. </update>
  129. <!-- <update id="updateStatusByFloorId">-->
  130. <!-- update cm_hehe_floor_product set status = #{status} where id = #{floorId}-->
  131. <!-- </update>-->
  132. <!-- -->
  133. <!-- <update id="saveSort">-->
  134. <!-- update cm_hehe_floor_product set sort = #{sort} where id = #{floorId}-->
  135. <!-- </update>-->
  136. <delete id="delete">
  137. DELETE FROM cm_hehe_floor_product
  138. WHERE id = #{id}
  139. </delete>
  140. </mapper>