CollectDao.xml 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 a.* , b.nickname as user_name,c.name as value_name
  20. from mall_collect a
  21. left join mall_user b on a.user_id = b.id
  22. left join mall_goods c on a.value_id = c.id
  23. WHERE 1=1
  24. <if test="name != null and name != ''">
  25. AND b.username LIKE concat('%',#{name},'%')
  26. </if>
  27. <choose>
  28. <when test="sidx != null and sidx.trim() != ''">
  29. order by ${sidx} ${order}
  30. </when>
  31. <otherwise>
  32. order by a.id desc
  33. </otherwise>
  34. </choose>
  35. <if test="offset != null and limit != null">
  36. limit #{offset}, #{limit}
  37. </if>
  38. </select>
  39. <select id="queryTotal" resultType="int">
  40. select count(a.id) from mall_collect a
  41. left join mall_user b on a.user_id = b.id
  42. WHERE 1=1
  43. <if test="name != null and name != ''">
  44. AND b.username LIKE concat('%',#{name},'%')
  45. </if>
  46. </select>
  47. <insert id="save" parameterType="com.kmall.admin.entity.CollectEntity" useGeneratedKeys="true" keyProperty="id">
  48. insert into mall_collect
  49. (
  50. `user_id`,
  51. `value_id`,
  52. `add_time`,
  53. `is_attention`,
  54. `type_id`
  55. )
  56. values
  57. (
  58. #{userId},
  59. #{valueId},
  60. #{addTime},
  61. #{isAttention},
  62. #{typeId}
  63. )
  64. </insert>
  65. <update id="update" parameterType="com.kmall.admin.entity.CollectEntity">
  66. update mall_collect
  67. <set>
  68. <if test="userId != null">`user_id` = #{userId},</if>
  69. <if test="valueId != null">`value_id` = #{valueId},</if>
  70. <if test="addTime != null">`add_time` = #{addTime},</if>
  71. <if test="isAttention != null">`is_attention` = #{isAttention},</if>
  72. <if test="typeId != null">`type_id` = #{typeId}</if>
  73. </set>
  74. where id = #{id}
  75. </update>
  76. <delete id="delete">
  77. delete from mall_collect where id = #{value}
  78. </delete>
  79. <delete id="deleteBatch">
  80. delete from mall_collect where id in
  81. <foreach item="id" collection="array" open="(" separator="," close=")">
  82. #{id}
  83. </foreach>
  84. </delete>
  85. </mapper>