<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.tmerclub.cloud.delivery.mapper.TransfeeFreeMapper">
  <resultMap id="transfeeFreeMap" type="com.tmerclub.cloud.delivery.model.TransfeeFree">
    <id column="transfee_free_id" property="transfeeFreeId" />
    <result column="create_time" property="createTime"/>
    <result column="update_time" property="updateTime"/>
    <result column="transport_id" property="transportId"/>
    <result column="free_type" property="freeType"/>
    <result column="amount" property="amount"/>
    <result column="piece" property="piece"/>
  </resultMap>
  <sql id="Vo_Column_List">
    `transfee_free_id`,`create_time`,`update_time`,`transport_id`,`free_type`,`amount`,`piece`
  </sql>
  <select id="list" resultType="com.tmerclub.cloud.common.order.vo.TransfeeFreeVO">
    select <include refid="Vo_Column_List"/> from transfee_free order by transfee_free_id desc
  </select>
  <select id="getByTransfeeFreeId" resultType="com.tmerclub.cloud.common.order.vo.TransfeeFreeVO">
    select <include refid="Vo_Column_List"/> from transfee_free where transfee_free_id = #{transfeeFreeId}
  </select>

  <insert id="saveBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="transfeeFreeId">
    insert into transfee_free (`transport_id`,`free_type`,`amount`,`piece`) values
    <foreach collection="transFeeFrees" item="transFeeFree" separator=",">
      (#{transFeeFree.transportId},#{transFeeFree.freeType},#{transFeeFree.amount},#{transFeeFree.piece})
    </foreach>
  </insert>

  <delete id="deleteTransFeeFreesByTransportId">
    delete from transfee_free where transport_id = #{transportId}
  </delete>

</mapper>
