FreightDao.xml 4.0 KB

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