FootprintDao.xml 4.1 KB

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