NewPageRecommendProductMapper.xml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.newhome.dao.NewPageRecommendProductDao">
  4. <insert id="addProducts">
  5. insert into cm_page_recommend_product (productId)
  6. values
  7. <foreach collection="split" item="item" index="index" separator=",">
  8. (#{item})
  9. </foreach>
  10. </insert>
  11. <update id="updateSorts">
  12. update cm_page_recommend_product
  13. set sort = #{sort}
  14. where productId = #{id}
  15. </update>
  16. <delete id="delProduct">
  17. delete from cm_page_recommend_product
  18. where productId = #{productId}
  19. </delete>
  20. <select id="findRecommendList" resultType="com.caimei.modules.product.entity.Product">
  21. select cpp.sort as sortIndex, p.mainImage, p.name, p.productID, s.name as shopName
  22. from cm_page_recommend_product cpp
  23. left join product p on cpp.productId = p.productID
  24. left join shop s on p.shopId = s.shopId
  25. where p.productCategory = 1
  26. group by p.productID
  27. <choose>
  28. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  29. ORDER BY ${page.orderBy},cpp.sort asc
  30. </when>
  31. <otherwise>
  32. order by cpp.sort asc
  33. </otherwise>
  34. </choose>
  35. </select>
  36. <select id="findProductList" resultType="com.caimei.modules.product.entity.Product">
  37. SELECT a.mainImage, a.name, a.productID,s.name as "shopName"
  38. FROM product a
  39. left join cm_organize_product_info copi on copi.productId = a.productID
  40. left join shop s on a.shopId = s.shopID
  41. left join cm_page_recommend_product nsp ON a.productId = nsp.productId
  42. <where>
  43. nsp.productId is null
  44. and
  45. copi.validFlag in (2,3,9)
  46. <if test="productID !=null and productID !=''">
  47. AND a.productID=#{productID}
  48. </if>
  49. <if test="name != null and name != ''">
  50. AND a.name LIKE concat('%',#{name},'%')
  51. </if>
  52. <if test="shopName != null and shopName != ''">
  53. AND s.name LIKE concat('%',#{shopName},'%')
  54. </if>
  55. and a.productCategory = 1
  56. </where>
  57. group by a.productID
  58. <choose>
  59. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  60. ORDER BY ${page.orderBy}
  61. </when>
  62. <otherwise>
  63. order by a.productID desc
  64. </otherwise>
  65. </choose>
  66. </select>
  67. </mapper>