SearchHistoryDao.xml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.SearchHistoryDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.admin.entity.SearchHistoryEntity" id="searchHistoryMap">
  6. <result property="id" column="id"/>
  7. <result property="keyword" column="keyword"/>
  8. <result property="from" column="from"/>
  9. <result property="addTime" column="add_time"/>
  10. <result property="userId" column="user_id"/>
  11. <result property="userName" column="user_name"/>
  12. </resultMap>
  13. <select id="queryObject" resultType="com.kmall.admin.entity.SearchHistoryEntity">
  14. select * from mall_search_history where id = #{value}
  15. </select>
  16. <select id="queryList" resultMap="searchHistoryMap">
  17. select a.* ,b.nickname as user_name
  18. from mall_search_history a
  19. left join mall_user b on a.user_id = b.id
  20. <choose>
  21. <when test="sidx != null and sidx.trim() != ''">
  22. order by ${sidx} ${order}
  23. </when>
  24. <otherwise>
  25. order by a.id desc
  26. </otherwise>
  27. </choose>
  28. <if test="offset != null and limit != null">
  29. limit #{offset}, #{limit}
  30. </if>
  31. </select>
  32. <select id="queryTotal" resultType="int">
  33. select count(*) from mall_search_history
  34. </select>
  35. <insert id="save" parameterType="com.kmall.admin.entity.SearchHistoryEntity" useGeneratedKeys="true" keyProperty="id">
  36. insert into mall_search_history
  37. (
  38. `keyword`,
  39. `from`,
  40. `add_time`,
  41. `user_id`
  42. )
  43. values
  44. (
  45. #{keyword},
  46. #{from},
  47. #{addTime},
  48. #{userId}
  49. )
  50. </insert>
  51. <update id="update" parameterType="com.kmall.admin.entity.SearchHistoryEntity">
  52. update mall_search_history
  53. <set>
  54. <if test="keyword != null">`keyword` = #{keyword},</if>
  55. <if test="from != null">`from` = #{from},</if>
  56. <if test="addTime != null">`add_time` = #{addTime},</if>
  57. <if test="userId != null">`user_id` = #{userId}</if>
  58. </set>
  59. where id = #{id}
  60. </update>
  61. <delete id="delete">
  62. delete from mall_search_history where id = #{value}
  63. </delete>
  64. <delete id="deleteBatch">
  65. delete from mall_search_history where id in
  66. <foreach item="id" collection="array" open="(" separator="," close=")">
  67. #{id}
  68. </foreach>
  69. </delete>
  70. </mapper>