CollectDao.xml 4.0 KB

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