ApiSearchHistoryMapper.xml 2.7 KB

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