CollectDao.xml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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="name != null and name != ''">
  33. AND b.username LIKE concat('%',#{name},'%')
  34. </if>
  35. <choose>
  36. <when test="sidx != null and sidx.trim() != ''">
  37. order by ${sidx} ${order}
  38. </when>
  39. <otherwise>
  40. order by a.id desc
  41. </otherwise>
  42. </choose>
  43. <if test="offset != null and limit != null">
  44. limit #{offset}, #{limit}
  45. </if>
  46. </select>
  47. <select id="queryTotal" resultType="int">
  48. select count(distinct a.id) from mall_collect a
  49. left join mall_user b on a.user_id = b.id
  50. LEFT JOIN mall_merch_user d ON a.user_id=d.user_id
  51. WHERE 1=1
  52. <if test="storeId != null">
  53. and d.store_id = #{storeId}
  54. </if>
  55. <if test="merchSn != null and merchSn.trim() != ''">
  56. and d.merch_sn = #{merchSn}
  57. </if>
  58. <if test="name != null and name != ''">
  59. AND b.username LIKE concat('%',#{name},'%')
  60. </if>
  61. </select>
  62. <insert id="save" parameterType="com.kmall.admin.entity.CollectEntity" useGeneratedKeys="true" keyProperty="id">
  63. insert into mall_collect
  64. (
  65. `user_id`,
  66. `value_id`,
  67. `add_time`,
  68. `is_attention`,
  69. `type_id`
  70. )
  71. values
  72. (
  73. #{userId},
  74. #{valueId},
  75. #{addTime},
  76. #{isAttention},
  77. #{typeId}
  78. )
  79. </insert>
  80. <update id="update" parameterType="com.kmall.admin.entity.CollectEntity">
  81. update mall_collect
  82. <set>
  83. <if test="userId != null">`user_id` = #{userId},</if>
  84. <if test="valueId != null">`value_id` = #{valueId},</if>
  85. <if test="addTime != null">`add_time` = #{addTime},</if>
  86. <if test="isAttention != null">`is_attention` = #{isAttention},</if>
  87. <if test="typeId != null">`type_id` = #{typeId}</if>
  88. </set>
  89. where id = #{id}
  90. </update>
  91. <delete id="delete">
  92. delete from mall_collect where id = #{value}
  93. </delete>
  94. <delete id="deleteBatch">
  95. delete from mall_collect where id in
  96. <foreach item="id" collection="array" open="(" separator="," close=")">
  97. #{id}
  98. </foreach>
  99. </delete>
  100. </mapper>