1
0

ApiBrandMapper.xml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.ApiBrandMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.api.entity.BrandVo" id="brandMap">
  6. <result property="id" column="id"/>
  7. <result property="name" column="name"/>
  8. <result property="list_pic_url" column="list_pic_url"/>
  9. <result property="simple_desc" column="simple_desc"/>
  10. <result property="pic_url" column="pic_url"/>
  11. <result property="sort_order" column="sort_order"/>
  12. <result property="is_show" column="is_show"/>
  13. <result property="floor_price" column="floor_price"/>
  14. <result property="app_list_pic_url" column="app_list_pic_url"/>
  15. <result property="is_new" column="is_new"/>
  16. <result property="new_pic_url" column="new_pic_url"/>
  17. <result property="new_sort_order" column="new_sort_order"/>
  18. </resultMap>
  19. <select id="queryObject" resultMap="brandMap">
  20. select * from mall_brand where id = #{value}
  21. </select>
  22. <select id="queryList" resultMap="brandMap">
  23. select
  24. <if test="fields != null and fields != ''">
  25. ${fields}
  26. </if>
  27. <if test="fields == null or fields == ''">
  28. *
  29. </if>
  30. from mall_brand
  31. <choose>
  32. <when test="sidx != null and sidx.trim() != ''">
  33. order by ${sidx} ${order}
  34. </when>
  35. <otherwise>
  36. order by id desc
  37. </otherwise>
  38. </choose>
  39. <if test="offset != null and limit != null">
  40. limit #{offset}, #{limit}
  41. </if>
  42. </select>
  43. <select id="queryTotal" resultType="int">
  44. select count(*) from mall_brand
  45. </select>
  46. <insert id="save" parameterType="com.kmall.api.entity.BrandVo" useGeneratedKeys="true" keyProperty="id">
  47. insert into mall_brand
  48. (
  49. `name`,
  50. `list_pic_url`,
  51. `simple_desc`,
  52. `pic_url`,
  53. `sort_order`,
  54. `is_show`,
  55. `floor_price`,
  56. `app_list_pic_url`,
  57. `is_new`,
  58. `new_pic_url`,
  59. `new_sort_order`
  60. )
  61. values
  62. (
  63. #{name},
  64. #{list_pic_url},
  65. #{simple_desc},
  66. #{pic_url},
  67. #{sort_order},
  68. #{is_show},
  69. #{floor_price},
  70. #{app_list_pic_url},
  71. #{is_new},
  72. #{new_pic_url},
  73. #{new_sort_order}
  74. )
  75. </insert>
  76. <update id="update" parameterType="com.kmall.api.entity.BrandVo">
  77. update mall_brand
  78. <set>
  79. <if test="name != null">`name` = #{name},</if>
  80. <if test="list_pic_url != null">`list_pic_url` = #{list_pic_url},</if>
  81. <if test="simple_desc != null">`simple_desc` = #{simple_desc},</if>
  82. <if test="pic_url != null">`pic_url` = #{pic_url},</if>
  83. <if test="sort_order != null">`sort_order` = #{sort_order},</if>
  84. <if test="is_show != null">`is_show` = #{is_show},</if>
  85. <if test="floor_price != null">`floor_price` = #{floor_price},</if>
  86. <if test="app_list_pic_url != null">`app_list_pic_url` = #{app_list_pic_url},</if>
  87. <if test="is_new != null">`is_new` = #{is_new},</if>
  88. <if test="new_pic_url != null">`new_pic_url` = #{new_pic_url},</if>
  89. <if test="new_sort_order != null">`new_sort_order` = #{new_sort_order}</if>
  90. </set>
  91. where id = #{id}
  92. </update>
  93. <delete id="delete">
  94. delete from mall_brand where id = #{value}
  95. </delete>
  96. <delete id="deleteBatch">
  97. delete from mall_brand where id in
  98. <foreach item="id" collection="array" open="(" separator="," close=")">
  99. #{id}
  100. </foreach>
  101. </delete>
  102. </mapper>