1
0

ChannelDao.xml 2.6 KB

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