FreightDao.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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="name != null and name.trim() != ''">
  81. AND b.name LIKE concat('%',#{name},'%')
  82. </if>
  83. <if test="id != null and id != ''">
  84. AND b.id LIKE concat('%',#{id},'%')
  85. </if>
  86. <choose>
  87. <when test="sidx != null and sidx.trim() != ''">
  88. order by ${sidx} ${order}
  89. </when>
  90. <otherwise>
  91. order by b.id desc
  92. </otherwise>
  93. </choose>
  94. <if test="offset != null and limit != null">
  95. limit #{offset}, #{limit}
  96. </if>
  97. </select>
  98. <select id="queryEntity" resultType="com.kmall.admin.entity.FreightEntity">
  99. select
  100. `id`,
  101. `name`,
  102. `store_id`,
  103. `merch_sn`,
  104. `template_type`,
  105. `pricing_manner`,
  106. `default_freight`,
  107. `is_default`
  108. from mall_freight
  109. WHERE 1=1
  110. <if test="storeId != null and storeId != ''">
  111. AND store_id = #{storeId}
  112. </if>
  113. <if test="merchSn != null and merchSn.trim() != ''">
  114. AND merch_sn = #{merchSn}
  115. </if>
  116. <if test="name != null and name != ''">
  117. AND name LIKE concat('%',#{name},'%')
  118. </if>
  119. <if test="id != null and id != ''">
  120. AND id NOT LIKE concat('%',#{id},'%')
  121. </if>
  122. <choose>
  123. <when test="sidx != null and sidx != ''">
  124. order by ${sidx} ${order}
  125. </when>
  126. <otherwise>
  127. order by id desc
  128. </otherwise>
  129. </choose>
  130. <if test="offset != null and limit != null">
  131. limit #{offset}, #{limit}
  132. </if>
  133. </select>
  134. <select id="queryTotal" resultType="int">
  135. select count(*) from mall_freight
  136. WHERE 1=1
  137. <if test="storeId != null and storeId != ''">
  138. AND store_id = #{storeId}
  139. </if>
  140. <if test="merchSn != null and merchSn.trim() != ''">
  141. AND merch_sn = #{merchSn}
  142. </if>
  143. <if test="name != null and name.trim() != ''">
  144. AND name LIKE concat('%',#{name},'%')
  145. </if>
  146. <if test="id != null and id != ''">
  147. AND id NOT LIKE concat('%',#{id},'%')
  148. </if>
  149. </select>
  150. <insert id="save" parameterType="com.kmall.admin.entity.FreightEntity" useGeneratedKeys="true" keyProperty="id">
  151. insert into mall_freight(
  152. `name`,
  153. `store_id`,
  154. `merch_sn`,
  155. `template_type`,
  156. `pricing_manner`,
  157. `default_freight`,
  158. `is_default`)
  159. values(
  160. #{name},
  161. #{storeId},
  162. #{merchSn},
  163. #{templateType},
  164. #{pricingManner},
  165. #{defaultFreight},
  166. #{isDefault})
  167. </insert>
  168. <update id="update" parameterType="com.kmall.admin.entity.FreightEntity">
  169. update mall_freight
  170. <set>
  171. <if test="name != null">`name` = #{name}, </if>
  172. <if test="storeId != null">`store_id` = #{storeId}, </if>
  173. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  174. <if test="templateType != null">`template_type` = #{templateType}, </if>
  175. <if test="pricingManner != null">`pricing_manner` = #{pricingManner}, </if>
  176. <if test="defaultFreight != null">`default_freight` = #{defaultFreight},</if>
  177. <if test="isDefault != null">`is_default` = #{isDefault}</if>
  178. </set>
  179. where id = #{id}
  180. </update>
  181. <delete id="delete">
  182. delete from mall_freight where id = #{value}
  183. </delete>
  184. <delete id="deleteBatch">
  185. delete from mall_freight where id in
  186. <foreach item="id" collection="array" open="(" separator="," close=")">
  187. #{id}
  188. </foreach>
  189. </delete>
  190. <select id="queryMaxId" resultType="java.lang.Integer" parameterType="map">
  191. SELECT MAX(id) FROM mall_freight
  192. </select>
  193. </mapper>