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