1
0

ApiBrandMapper.xml 3.9 KB

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