KeywordsDao.xml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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.KeywordsDao">
  4. <resultMap type="com.kmall.admin.entity.KeywordsEntity" id="keywordsMap">
  5. <result property="id" column="id"/>
  6. <result property="keyword" column="keyword"/>
  7. <result property="isHot" column="is_hot"/>
  8. <result property="isDefault" column="is_default"/>
  9. <result property="isShow" column="is_show"/>
  10. <result property="sortOrder" column="sort_order"/>
  11. <result property="schemeUrl" column="scheme_url"/>
  12. <result property="type" column="type"/>
  13. </resultMap>
  14. <select id="queryObject" resultType="com.kmall.admin.entity.KeywordsEntity">
  15. select
  16. `id`,
  17. `keyword`,
  18. `is_hot`,
  19. `is_default`,
  20. `is_show`,
  21. `sort_order`,
  22. `scheme_url`,
  23. `type`
  24. from mall_keywords
  25. where id = #{id}
  26. </select>
  27. <select id="queryList" resultType="com.kmall.admin.entity.KeywordsEntity">
  28. select
  29. `id`,
  30. `keyword`,
  31. `is_hot`,
  32. `is_default`,
  33. `is_show`,
  34. `sort_order`,
  35. `scheme_url`,
  36. `type`
  37. from mall_keywords
  38. WHERE 1=1
  39. <if test="keyword != null and keyword.trim() != ''">
  40. AND keyword LIKE concat('%',#{keyword},'%')
  41. </if>
  42. <choose>
  43. <when test="sidx != null and sidx.trim() != ''">
  44. order by ${sidx} ${order}
  45. </when>
  46. <otherwise>
  47. order by id desc
  48. </otherwise>
  49. </choose>
  50. <if test="offset != null and limit != null">
  51. limit #{offset}, #{limit}
  52. </if>
  53. </select>
  54. <select id="queryTotal" resultType="int">
  55. select count(*) from mall_keywords
  56. WHERE 1=1
  57. <if test="keyword != null and keyword.trim() != ''">
  58. AND keyword LIKE concat('%',#{keyword},'%')
  59. </if>
  60. </select>
  61. <insert id="save" parameterType="com.kmall.admin.entity.KeywordsEntity" useGeneratedKeys="true" keyProperty="id">
  62. insert into mall_keywords(
  63. `keyword`,
  64. `is_hot`,
  65. `is_default`,
  66. `is_show`,
  67. `sort_order`,
  68. `scheme_url`,
  69. `type`)
  70. values(
  71. #{keyword},
  72. #{isHot},
  73. #{isDefault},
  74. #{isShow},
  75. #{sortOrder},
  76. #{schemeUrl},
  77. #{type})
  78. </insert>
  79. <update id="update" parameterType="com.kmall.admin.entity.KeywordsEntity">
  80. update mall_keywords
  81. <set>
  82. <if test="keyword != null">`keyword` = #{keyword}, </if>
  83. <if test="isHot != null">`is_hot` = #{isHot}, </if>
  84. <if test="isDefault != null">`is_default` = #{isDefault}, </if>
  85. <if test="isShow != null">`is_show` = #{isShow}, </if>
  86. <if test="sortOrder != null">`sort_order` = #{sortOrder}, </if>
  87. <if test="schemeUrl != null">`scheme_url` = #{schemeUrl}, </if>
  88. <if test="type != null">`type` = #{type}</if>
  89. </set>
  90. where id = #{id}
  91. </update>
  92. <delete id="delete">
  93. delete from mall_keywords where id = #{value}
  94. </delete>
  95. <delete id="deleteBatch">
  96. delete from mall_keywords where id in
  97. <foreach item="id" collection="array" open="(" separator="," close=")">
  98. #{id}
  99. </foreach>
  100. </delete>
  101. </mapper>