SupplierDao.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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.SupplierDao">
  4. <resultMap type="com.kmall.admin.entity.SupplierEntity" id="supplierMap">
  5. <result property="id" column="id"/>
  6. <result property="levelMerchSn" column="level_merch_sn"/>
  7. <result property="levelMerchFlag" column="level_merch_flag"/>
  8. <result property="childSupplierName" column="child_supplier_name"/>
  9. <result property="childSupplierFlag" column="child_supplier_flag"/>
  10. <result property="sortOrder" column="sort_order"/>
  11. <result property="isShow" column="is_show"/>
  12. <result property="thirdPartyMerchCode" column="third_party_merch_code"/>
  13. <result property="createTime" column="create_time"/>
  14. </resultMap>
  15. <select id="queryObject" resultType="com.kmall.admin.entity.SupplierEntity">
  16. select
  17. `id`,
  18. `level_merch_sn`,
  19. `level_merch_flag`,
  20. `child_supplier_name`,
  21. `child_supplier_flag`,
  22. `sort_order`,
  23. `is_show`,
  24. third_party_merch_code,
  25. `create_time`
  26. from mall_supplier
  27. where id = #{id}
  28. </select>
  29. <select id="queryObjectByName" resultType="com.kmall.admin.entity.SupplierEntity">
  30. select
  31. `id`,
  32. `level_merch_sn`,
  33. `level_merch_flag`,
  34. `child_supplier_name`,
  35. `child_supplier_flag`,
  36. `sort_order`,
  37. `is_show`,
  38. third_party_merch_code,
  39. `create_time`
  40. from mall_supplier
  41. where child_supplier_name = #{supplierName}
  42. <if test="merchSn != null and merchSn.trim() != ''">
  43. AND level_merch_sn = #{merchSn}
  44. </if>
  45. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  46. AND third_party_merch_code = #{thirdPartyMerchCode}
  47. </if>
  48. </select>
  49. <select id="queryList" resultType="com.kmall.admin.entity.SupplierEntity">
  50. select
  51. s.`id`,
  52. s.`level_merch_sn`,
  53. s.`level_merch_flag`,
  54. s.`child_supplier_name`,
  55. s.`child_supplier_flag`,
  56. s.`sort_order`,
  57. s.`is_show`,s.third_party_merch_code,
  58. s.`create_time`
  59. from mall_supplier s left join third_merchant_biz t on s.third_party_merch_code = t.third_party_merch_code
  60. WHERE 1=1
  61. <if test="name != null and name.trim() != ''">
  62. AND s.child_supplier_name like concat('%',#{name},'%')
  63. </if>
  64. <if test="merchSn != null and merchSn.trim() != ''">
  65. AND s.level_merch_sn = #{merchSn}
  66. </if>
  67. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  68. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  69. </if>
  70. <if test="thirdMerchSn != null and thirdMerchSn.trim() != ''">
  71. AND t.third_merch_sn = #{thirdMerchSn}
  72. </if>
  73. <if test="supplierId != null and supplierId != ''">
  74. AND s.id = #{supplierId}
  75. </if>
  76. <choose>
  77. <when test="sidx != null and sidx.trim() != ''">
  78. order by ${sidx} ${order}
  79. </when>
  80. <otherwise>
  81. order by s.id desc
  82. </otherwise>
  83. </choose>
  84. <if test="offset != null and limit != null">
  85. limit #{offset}, #{limit}
  86. </if>
  87. </select>
  88. <select id="queryTotal" resultType="int">
  89. select count(*) from mall_supplier
  90. WHERE 1=1
  91. <if test="name != null and name.trim() != ''">
  92. AND child_supplier_name like concat('%',#{name},'%')
  93. </if>
  94. <if test="merchSn != null and merchSn.trim() != ''">
  95. AND level_merch_sn = #{merchSn}
  96. </if>
  97. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  98. AND third_party_merch_code = #{thirdPartyMerchCode}
  99. </if>
  100. </select>
  101. <insert id="save" parameterType="com.kmall.admin.entity.SupplierEntity" useGeneratedKeys="true" keyProperty="id">
  102. insert into mall_supplier(
  103. `level_merch_sn`,
  104. `level_merch_flag`,
  105. `child_supplier_name`,
  106. `child_supplier_flag`,
  107. `sort_order`,
  108. `is_show`,third_party_merch_code, `create_time`)
  109. values(
  110. #{levelMerchSn},
  111. #{levelMerchFlag},
  112. #{childSupplierName},
  113. #{childSupplierFlag},
  114. #{sortOrder},
  115. #{isShow},#{thirdPartyMerchCode}, #{createTime})
  116. </insert>
  117. <update id="update" parameterType="com.kmall.admin.entity.SupplierEntity">
  118. update mall_supplier
  119. <set>
  120. <if test="levelMerchSn != null">`level_merch_sn` = #{levelMerchSn}, </if>
  121. <if test="levelMerchFlag != null">`level_merch_flag` = #{levelMerchFlag}, </if>
  122. <if test="childSupplierName != null">`child_supplier_name` = #{childSupplierName}, </if>
  123. <if test="childSupplierFlag != null">`child_supplier_flag` = #{childSupplierFlag}, </if>
  124. <if test="sortOrder != null">`sort_order` = #{sortOrder}, </if>
  125. <if test="isShow != null">`is_show` = #{isShow},</if>
  126. <if test="thirdPartyMerchCode != null">`third_party_merch_code` = #{thirdPartyMerchCode}</if>
  127. </set>
  128. where id = #{id}
  129. </update>
  130. <delete id="delete">
  131. delete from mall_supplier where id = #{value}
  132. </delete>
  133. <delete id="deleteBatch">
  134. delete from mall_supplier where id in
  135. <foreach item="id" collection="array" open="(" separator="," close=")">
  136. #{id}
  137. </foreach>
  138. </delete>
  139. <insert id="saveBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
  140. insert into mall_supplier(
  141. `level_merch_sn`,
  142. `level_merch_flag`,
  143. `child_supplier_name`,
  144. `child_supplier_flag`,
  145. `sort_order`,
  146. `is_show`,third_party_merch_code, `create_time`)
  147. values
  148. <foreach collection="list" index="index" item="item" separator=",">
  149. (
  150. #{item.levelMerchSn},
  151. #{item.levelMerchFlag},
  152. #{item.childSupplierName},
  153. #{item.childSupplierFlag},
  154. #{item.sortOrder},
  155. #{item.isShow},
  156. #{item.thirdPartyMerchCode},
  157. #{item.createTime}
  158. )
  159. </foreach>
  160. </insert>
  161. </mapper>