1
0

ApiFreightMapper.xml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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.api.dao.ApiFreightMapper">
  4. <resultMap type="com.kmall.api.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="isDefault" column="is_default"/>
  10. <result property="defaultFreight" column="default_freight"/>
  11. </resultMap>
  12. <select id="queryObject" resultType="com.kmall.api.entity.FreightEntity">
  13. select
  14. `id`,
  15. `name`,
  16. `template_type`,
  17. `pricing_manner`,
  18. `is_default`,default_freight
  19. from mall_freight
  20. where id = #{id}
  21. </select>
  22. <select id="queryObjectByGoodsId" resultType="com.kmall.api.entity.FreightEntity">
  23. select f.* from mall_freight f inner join mall_goods g on g.freight_id = f.id where g.id=#{goodsId}
  24. </select>
  25. <select id="queryList" resultType="com.kmall.api.entity.FreightEntity">
  26. select
  27. `id`,
  28. `name`,
  29. `template_type`,
  30. `pricing_manner`,
  31. `is_default`,default_freight
  32. from mall_freight
  33. WHERE 1=1
  34. <if test="name != null and name.trim() != ''">
  35. AND name LIKE concat('%',#{name},'%')
  36. </if>
  37. <choose>
  38. <when test="sidx != null and sidx.trim() != ''">
  39. order by ${sidx} ${order}
  40. </when>
  41. <otherwise>
  42. order by id desc
  43. </otherwise>
  44. </choose>
  45. <if test="offset != null and limit != null">
  46. limit #{offset}, #{limit}
  47. </if>
  48. </select>
  49. <select id="queryTotal" resultType="int">
  50. select count(*) from mall_freight
  51. WHERE 1=1
  52. <if test="name != null and name.trim() != ''">
  53. AND name LIKE concat('%',#{name},'%')
  54. </if>
  55. </select>
  56. <insert id="save" parameterType="com.kmall.api.entity.FreightEntity" useGeneratedKeys="true" keyProperty="id">
  57. insert into mall_freight(
  58. `name`,
  59. `template_type`,
  60. `pricing_manner`,
  61. `is_default`,
  62. `default_freight`)
  63. values(
  64. #{name},
  65. #{templateType},
  66. #{pricingManner},
  67. #{isDefault},
  68. #{defaultFreight})
  69. </insert>
  70. <update id="update" parameterType="com.kmall.api.entity.FreightEntity">
  71. update mall_freight
  72. <set>
  73. <if test="name != null">`name` = #{name}, </if>
  74. <if test="templateType != null">`template_type` = #{templateType}, </if>
  75. <if test="pricingManner != null">`pricing_manner` = #{pricingManner}, </if>
  76. <if test="isDefault != null">`is_default` = #{isDefault}</if>
  77. <if test="defaultFreight != null">`default_freight` = #{defaultFreight}</if>
  78. </set>
  79. where id = #{id}
  80. </update>
  81. <delete id="delete">
  82. delete from mall_freight where id = #{value}
  83. </delete>
  84. <delete id="deleteBatch">
  85. delete from mall_freight where id in
  86. <foreach item="id" collection="array" open="(" separator="," close=")">
  87. #{id}
  88. </foreach>
  89. </delete>
  90. </mapper>