ApiCollectMapper.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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.api.dao.ApiCollectMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.api.entity.CollectVo" id="collectMap">
  6. <result property="id" column="id"/>
  7. <result property="user_id" column="user_id"/>
  8. <result property="value_id" column="value_id"/>
  9. <result property="add_time" column="add_time"/>
  10. <result property="is_attention" column="is_attention"/>
  11. <result property="type_id" column="type_id"/>
  12. <result property="name" column="name"/>
  13. <result property="list_pic_url" column="list_pic_url"/>
  14. <result property="goods_brief" column="goods_brief"/>
  15. <result property="retail_price" column="retail_price"/>
  16. </resultMap>
  17. <select id="queryObject" resultMap="collectMap">
  18. select *
  19. from mall_collect where id = #{value}
  20. </select>
  21. <select id="queryList" resultMap="collectMap">
  22. select c.*,g.name, g.list_pic_url as list_pic_url, g.goods_brief as goods_brief, psr1.retail_price as retail_price
  23. from mall_collect c
  24. left join mall_goods g on c.value_id = g.id
  25. LEFT JOIN mall_product_store_rela psr1 ON g.id = psr1.goods_id
  26. where 1 = 1 and psr1.id is not null
  27. <if test="user_id != null and user_id != ''">
  28. and c.user_id = #{user_id}
  29. </if>
  30. <if test="value_id != null and value_id != ''">
  31. and c.value_id = #{value_id}
  32. </if>
  33. <if test="type_id != null and type_id != ''">
  34. and c.type_id = #{type_id}
  35. </if>
  36. <if test="store_id != null and store_id != ''">
  37. and psr1.store_id = #{store_id}
  38. </if>
  39. <choose>
  40. <when test="sidx != null and sidx.trim() != ''">
  41. order by ${sidx} ${order}
  42. </when>
  43. <otherwise>
  44. order by c.id desc
  45. </otherwise>
  46. </choose>
  47. <if test="offset != null and limit != null">
  48. limit #{offset}, #{limit}
  49. </if>
  50. </select>
  51. <select id="queryTotal" resultType="int">
  52. select count(*)
  53. from mall_collect c
  54. left join mall_goods g on c.value_id = g.id
  55. LEFT JOIN mall_product_store_rela psr1 ON g.id = psr1.goods_id
  56. where 1 = 1 and psr1.id is not null
  57. <if test="user_id != null and user_id != ''">
  58. and c.user_id = #{user_id}
  59. </if>
  60. <if test="value_id != null and value_id != ''">
  61. and c.value_id = #{value_id}
  62. </if>
  63. <if test="type_id != null and type_id != ''">
  64. and c.type_id = #{type_id}
  65. </if>
  66. <if test="store_id != null and store_id != ''">
  67. and psr1.store_id = #{store_id}
  68. </if>
  69. </select>
  70. <insert id="save" parameterType="com.kmall.api.entity.CollectVo" useGeneratedKeys="true" keyProperty="id">
  71. insert into mall_collect
  72. (
  73. `user_id`,
  74. `value_id`,
  75. `add_time`,
  76. `is_attention`,
  77. `type_id`
  78. )
  79. values
  80. (
  81. #{user_id},
  82. #{value_id},
  83. #{add_time},
  84. #{is_attention},
  85. #{type_id}
  86. )
  87. </insert>
  88. <update id="update" parameterType="com.kmall.api.entity.CollectVo">
  89. update mall_collect
  90. <set>
  91. <if test="user_id != null">`user_id` = #{user_id},</if>
  92. <if test="value_id != null">`value_id` = #{value_id},</if>
  93. <if test="add_time != null">`add_time` = #{add_time},</if>
  94. <if test="is_attention != null">`is_attention` = #{is_attention},</if>
  95. <if test="type_id != null">`type_id` = #{type_id}</if>
  96. </set>
  97. where id = #{id}
  98. </update>
  99. <delete id="delete">
  100. delete from mall_collect where id = #{value}
  101. </delete>
  102. <delete id="deleteBatch">
  103. delete from mall_collect where id in
  104. <foreach item="id" collection="array" open="(" separator="," close=")">
  105. #{id}
  106. </foreach>
  107. </delete>
  108. </mapper>