1
0

FootprintDao.xml 3.3 KB

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