FootprintDao.xml 2.8 KB

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