FreightDao.xml 4.9 KB

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