FreightDao.xml 3.7 KB

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