FreightDao.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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.FreightDao">
  4. <resultMap type="com.kmall.admin.entity.FreightEntity" id="freightMap">
  5. <result property="id" column="id"/>
  6. <result property="name" column="name"/>
  7. <result property="storeId" column="store_id"/>
  8. <result property="merchSn" column="merch_sn"/>
  9. <result property="templateType" column="template_type"/>
  10. <result property="pricingManner" column="pricing_manner"/>
  11. <result property="defaultFreight" column="default_freight"/>
  12. <result property="isDefault" column="is_default"/>
  13. <result property="storeName" column="storeName"/>
  14. <result column="merchName" property="merchName" />
  15. </resultMap>
  16. <select id="queryObject" resultType="com.kmall.admin.entity.FreightEntity">
  17. select
  18. `id`,
  19. `name`,
  20. `store_id`,
  21. `merch_sn`,
  22. `template_type`,
  23. `pricing_manner`,
  24. `default_freight`,
  25. `is_default`
  26. from mall_freight
  27. where id = #{id}
  28. </select>
  29. <select id="queryObjectByName" resultType="com.kmall.admin.entity.FreightEntity">
  30. select
  31. `id`,
  32. `name`,
  33. `store_id`,
  34. `merch_sn`,
  35. `template_type`,
  36. `pricing_manner`,
  37. `default_freight`,
  38. `is_default`
  39. from mall_freight
  40. where default_freight = #{defaultFreight}
  41. <if test="merchSn != null and merchSn.trim() != ''">
  42. AND merch_sn = #{merchSn}
  43. </if>
  44. </select>
  45. <select id="queryObjectByStoreId" resultType="com.kmall.admin.entity.FreightEntity">
  46. select
  47. `id`,
  48. `name`,
  49. `store_id`,
  50. `merch_sn`,
  51. `template_type`,
  52. `pricing_manner`,
  53. `default_freight`,
  54. `is_default`
  55. from mall_freight
  56. where store_id = #{storeId}
  57. </select>
  58. <select id="queryList" resultType="com.kmall.admin.entity.FreightEntity">
  59. select
  60. b.id,
  61. b.name,
  62. b.store_id,
  63. b.merch_sn,
  64. `template_type`,
  65. `pricing_manner`,
  66. `default_freight`,
  67. `is_default`,
  68. s.store_name storeName,
  69. m.merch_name merchName
  70. from mall_freight b
  71. left join mall_store s on b.store_id = s.id
  72. left join mall_merch m on b.merch_sn = m.merch_sn
  73. WHERE 1=1
  74. <if test="storeId != null and storeId != ''">
  75. AND b.store_id = #{storeId}
  76. </if>
  77. <if test="merchSn != null and merchSn.trim() != ''">
  78. AND b.merch_sn = #{merchSn}
  79. </if>
  80. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  81. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  82. </if>
  83. <if test="name != null and name.trim() != ''">
  84. AND b.name LIKE concat('%',#{name},'%')
  85. </if>
  86. <if test="id != null and id != ''">
  87. AND b.id LIKE concat('%',#{id},'%')
  88. </if>
  89. <choose>
  90. <when test="sidx != null and sidx.trim() != ''">
  91. order by ${sidx} ${order}
  92. </when>
  93. <otherwise>
  94. order by b.id desc
  95. </otherwise>
  96. </choose>
  97. <if test="offset != null and limit != null">
  98. limit #{offset}, #{limit}
  99. </if>
  100. </select>
  101. <select id="queryEntity" resultType="com.kmall.admin.entity.FreightEntity">
  102. select
  103. `id`,
  104. `name`,
  105. `store_id`,
  106. `merch_sn`,
  107. `template_type`,
  108. `pricing_manner`,
  109. `default_freight`,
  110. `is_default`
  111. from mall_freight
  112. WHERE 1=1
  113. <if test="storeId != null and storeId != ''">
  114. AND store_id = #{storeId}
  115. </if>
  116. <if test="merchSn != null and merchSn.trim() != ''">
  117. AND merch_sn = #{merchSn}
  118. </if>
  119. <if test="name != null and name != ''">
  120. AND name LIKE concat('%',#{name},'%')
  121. </if>
  122. <if test="id != null and id != ''">
  123. AND id NOT LIKE concat('%',#{id},'%')
  124. </if>
  125. <choose>
  126. <when test="sidx != null and sidx != ''">
  127. order by ${sidx} ${order}
  128. </when>
  129. <otherwise>
  130. order by id desc
  131. </otherwise>
  132. </choose>
  133. <if test="offset != null and limit != null">
  134. limit #{offset}, #{limit}
  135. </if>
  136. </select>
  137. <select id="queryTotal" resultType="int">
  138. select count(*) from mall_freight b
  139. left join mall_store s on b.store_id = s.id
  140. WHERE 1=1
  141. <if test="storeId != null and storeId != ''">
  142. AND b.store_id = #{storeId}
  143. </if>
  144. <if test="merchSn != null and merchSn.trim() != ''">
  145. AND b.merch_sn = #{merchSn}
  146. </if>
  147. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  148. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  149. </if>
  150. <if test="name != null and name.trim() != ''">
  151. AND b.name LIKE concat('%',#{name},'%')
  152. </if>
  153. <if test="id != null and id != ''">
  154. AND b.id NOT LIKE concat('%',#{id},'%')
  155. </if>
  156. </select>
  157. <insert id="save" parameterType="com.kmall.admin.entity.FreightEntity" useGeneratedKeys="true" keyProperty="id">
  158. insert into mall_freight(
  159. `name`,
  160. `store_id`,
  161. `merch_sn`,
  162. `template_type`,
  163. `pricing_manner`,
  164. `default_freight`,
  165. `is_default`)
  166. values(
  167. #{name},
  168. #{storeId},
  169. #{merchSn},
  170. #{templateType},
  171. #{pricingManner},
  172. #{defaultFreight},
  173. #{isDefault})
  174. </insert>
  175. <update id="update" parameterType="com.kmall.admin.entity.FreightEntity">
  176. update mall_freight
  177. <set>
  178. <if test="name != null">`name` = #{name}, </if>
  179. <if test="storeId != null">`store_id` = #{storeId}, </if>
  180. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  181. <if test="templateType != null">`template_type` = #{templateType}, </if>
  182. <if test="pricingManner != null">`pricing_manner` = #{pricingManner}, </if>
  183. <if test="defaultFreight != null">`default_freight` = #{defaultFreight},</if>
  184. <if test="isDefault != null">`is_default` = #{isDefault}</if>
  185. </set>
  186. where id = #{id}
  187. </update>
  188. <delete id="delete">
  189. delete from mall_freight where id = #{value}
  190. </delete>
  191. <delete id="deleteBatch">
  192. delete from mall_freight where id in
  193. <foreach item="id" collection="array" open="(" separator="," close=")">
  194. #{id}
  195. </foreach>
  196. </delete>
  197. <select id="queryMaxId" resultType="java.lang.Integer" parameterType="map">
  198. SELECT MAX(id) FROM mall_freight
  199. </select>
  200. </mapper>