<?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.jsowell.pile.mapper.PileReservationInfoMapper">
  <resultMap id="BaseResultMap" type="com.jsowell.pile.domain.PileReservationInfo">
    <!--@mbg.generated-->
    <!--@Table pile_reservation_info-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="member_id" jdbcType="VARCHAR" property="memberId" />
    <result column="pile_sn" jdbcType="VARCHAR" property="pileSn" />
    <result column="pile_connector_code" jdbcType="VARCHAR" property="pileConnectorCode" />
    <result column="status" jdbcType="VARCHAR" property="status" />
    <result column="reservation_type" jdbcType="VARCHAR" property="reservationType" />
    <result column="start_time" jdbcType="TIME" property="startTime" />
    <result column="end_time" jdbcType="TIME" property="endTime" />
    <result column="freq" jdbcType="VARCHAR" property="freq" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="del_flag" jdbcType="CHAR" property="delFlag" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, member_id, pile_sn, pile_connector_code, `status`, reservation_type, start_time,
    end_time, freq, create_by, create_time, update_by, update_time, del_flag
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from pile_reservation_info
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--@mbg.generated-->
    delete from pile_reservation_info
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservationInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into pile_reservation_info (member_id, pile_sn, pile_connector_code,
    `status`, reservation_type, start_time,
    end_time, freq, create_by,
    create_time, update_by, update_time,
    del_flag)
    values (#{memberId,jdbcType=VARCHAR}, #{pileSn,jdbcType=VARCHAR}, #{pileConnectorCode,jdbcType=VARCHAR},
    #{status,jdbcType=VARCHAR}, #{reservationType,jdbcType=VARCHAR}, #{startTime,jdbcType=TIME},
    #{endTime,jdbcType=TIME}, #{freq,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
    #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
    #{delFlag,jdbcType=CHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservationInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into pile_reservation_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="memberId != null">
        member_id,
      </if>
      <if test="pileSn != null">
        pile_sn,
      </if>
      <if test="pileConnectorCode != null">
        pile_connector_code,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="reservationType != null">
        reservation_type,
      </if>
      <if test="startTime != null">
        start_time,
      </if>
      <if test="endTime != null">
        end_time,
      </if>
      <if test="freq != null">
        freq,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateBy != null">
        update_by,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="delFlag != null">
        del_flag,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="memberId != null">
        #{memberId,jdbcType=VARCHAR},
      </if>
      <if test="pileSn != null">
        #{pileSn,jdbcType=VARCHAR},
      </if>
      <if test="pileConnectorCode != null">
        #{pileConnectorCode,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="reservationType != null">
        #{reservationType,jdbcType=VARCHAR},
      </if>
      <if test="startTime != null">
        #{startTime,jdbcType=TIME},
      </if>
      <if test="endTime != null">
        #{endTime,jdbcType=TIME},
      </if>
      <if test="freq != null">
        #{freq,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        #{delFlag,jdbcType=CHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.jsowell.pile.domain.PileReservationInfo">
    <!--@mbg.generated-->
    update pile_reservation_info
    <set>
      <if test="memberId != null">
        member_id = #{memberId,jdbcType=VARCHAR},
      </if>
      <if test="pileSn != null">
        pile_sn = #{pileSn,jdbcType=VARCHAR},
      </if>
      <if test="pileConnectorCode != null">
        pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        `status` = #{status,jdbcType=VARCHAR},
      </if>
      <if test="reservationType != null">
        reservation_type = #{reservationType,jdbcType=VARCHAR},
      </if>
      <if test="startTime != null">
        start_time = #{startTime,jdbcType=TIME},
      </if>
      <if test="endTime != null">
        end_time = #{endTime,jdbcType=TIME},
      </if>
      <if test="freq != null">
        freq = #{freq,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        del_flag = #{delFlag,jdbcType=CHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.jsowell.pile.domain.PileReservationInfo">
    <!--@mbg.generated-->
    update pile_reservation_info
    set member_id = #{memberId,jdbcType=VARCHAR},
    pile_sn = #{pileSn,jdbcType=VARCHAR},
    pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
    `status` = #{status,jdbcType=VARCHAR},
    reservation_type = #{reservationType,jdbcType=VARCHAR},
    start_time = #{startTime,jdbcType=TIME},
    end_time = #{endTime,jdbcType=TIME},
    freq = #{freq,jdbcType=VARCHAR},
    create_by = #{createBy,jdbcType=VARCHAR},
    create_time = #{createTime,jdbcType=TIMESTAMP},
    update_by = #{updateBy,jdbcType=VARCHAR},
    update_time = #{updateTime,jdbcType=TIMESTAMP},
    del_flag = #{delFlag,jdbcType=CHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update pile_reservation_info
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="member_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.memberId,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="pile_sn = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.pileSn,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="pile_connector_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.pileConnectorCode,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="`status` = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.status,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="reservation_type = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.reservationType,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="start_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.startTime,jdbcType=TIME}
        </foreach>
      </trim>
      <trim prefix="end_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.endTime,jdbcType=TIME}
        </foreach>
      </trim>
      <trim prefix="freq = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.freq,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="create_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.createBy,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="create_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="update_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.updateBy,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="update_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.updateTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="del_flag = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.delFlag,jdbcType=CHAR}
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=INTEGER}
    </foreach>
  </update>
  <update id="updateBatchSelective" parameterType="java.util.List">
    <!--@mbg.generated-->
    update pile_reservation_info
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="member_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.memberId != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.memberId,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="pile_sn = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.pileSn != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.pileSn,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="pile_connector_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.pileConnectorCode != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.pileConnectorCode,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="`status` = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.status != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.status,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="reservation_type = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.reservationType != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.reservationType,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="start_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.startTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.startTime,jdbcType=TIME}
          </if>
        </foreach>
      </trim>
      <trim prefix="end_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.endTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.endTime,jdbcType=TIME}
          </if>
        </foreach>
      </trim>
      <trim prefix="freq = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.freq != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.freq,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="create_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.createBy != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.createBy,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="create_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.createTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="update_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.updateBy != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.updateBy,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="update_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.updateTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.updateTime,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="del_flag = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.delFlag != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.delFlag,jdbcType=CHAR}
          </if>
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=INTEGER}
    </foreach>
  </update>
  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into pile_reservation_info
    (member_id, pile_sn, pile_connector_code, `status`, reservation_type, start_time, end_time,
      freq, create_by, create_time, update_by, update_time, del_flag)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.memberId,jdbcType=VARCHAR}, #{item.pileSn,jdbcType=VARCHAR}, #{item.pileConnectorCode,jdbcType=VARCHAR},
      #{item.status,jdbcType=VARCHAR}, #{item.reservationType,jdbcType=VARCHAR}, #{item.startTime,jdbcType=TIME},
      #{item.endTime,jdbcType=TIME}, #{item.freq,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR},
      #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateBy,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP},
      #{item.delFlag,jdbcType=CHAR})
    </foreach>
  </insert>
  <insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservationInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into pile_reservation_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      member_id,
      pile_sn,
      pile_connector_code,
      `status`,
      reservation_type,
      start_time,
      end_time,
      freq,
      create_by,
      create_time,
      update_by,
      update_time,
      del_flag,
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      #{memberId,jdbcType=VARCHAR},
      #{pileSn,jdbcType=VARCHAR},
      #{pileConnectorCode,jdbcType=VARCHAR},
      #{status,jdbcType=VARCHAR},
      #{reservationType,jdbcType=VARCHAR},
      #{startTime,jdbcType=TIME},
      #{endTime,jdbcType=TIME},
      #{freq,jdbcType=VARCHAR},
      #{createBy,jdbcType=VARCHAR},
      #{createTime,jdbcType=TIMESTAMP},
      #{updateBy,jdbcType=VARCHAR},
      #{updateTime,jdbcType=TIMESTAMP},
      #{delFlag,jdbcType=CHAR},
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      member_id = #{memberId,jdbcType=VARCHAR},
      pile_sn = #{pileSn,jdbcType=VARCHAR},
      pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
      `status` = #{status,jdbcType=VARCHAR},
      reservation_type = #{reservationType,jdbcType=VARCHAR},
      start_time = #{startTime,jdbcType=TIME},
      end_time = #{endTime,jdbcType=TIME},
      freq = #{freq,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_by = #{updateBy,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      del_flag = #{delFlag,jdbcType=CHAR},
    </trim>
  </insert>
  <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.PileReservationInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into pile_reservation_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="memberId != null">
        member_id,
      </if>
      <if test="pileSn != null">
        pile_sn,
      </if>
      <if test="pileConnectorCode != null">
        pile_connector_code,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="reservationType != null">
        reservation_type,
      </if>
      <if test="startTime != null">
        start_time,
      </if>
      <if test="endTime != null">
        end_time,
      </if>
      <if test="freq != null">
        freq,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateBy != null">
        update_by,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="delFlag != null">
        del_flag,
      </if>
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="memberId != null">
        #{memberId,jdbcType=VARCHAR},
      </if>
      <if test="pileSn != null">
        #{pileSn,jdbcType=VARCHAR},
      </if>
      <if test="pileConnectorCode != null">
        #{pileConnectorCode,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="reservationType != null">
        #{reservationType,jdbcType=VARCHAR},
      </if>
      <if test="startTime != null">
        #{startTime,jdbcType=TIME},
      </if>
      <if test="endTime != null">
        #{endTime,jdbcType=TIME},
      </if>
      <if test="freq != null">
        #{freq,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        #{delFlag,jdbcType=CHAR},
      </if>
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      <if test="memberId != null">
        member_id = #{memberId,jdbcType=VARCHAR},
      </if>
      <if test="pileSn != null">
        pile_sn = #{pileSn,jdbcType=VARCHAR},
      </if>
      <if test="pileConnectorCode != null">
        pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        `status` = #{status,jdbcType=VARCHAR},
      </if>
      <if test="reservationType != null">
        reservation_type = #{reservationType,jdbcType=VARCHAR},
      </if>
      <if test="startTime != null">
        start_time = #{startTime,jdbcType=TIME},
      </if>
      <if test="endTime != null">
        end_time = #{endTime,jdbcType=TIME},
      </if>
      <if test="freq != null">
        freq = #{freq,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        del_flag = #{delFlag,jdbcType=CHAR},
      </if>
    </trim>
  </insert>

  <select id="findByMemberIdAndPileSnAndStatus" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from pile_reservation_info
    where del_flag = '0'
    and member_id = #{memberId,jdbcType=VARCHAR}
    and pile_sn = #{pileSn,jdbcType=VARCHAR}
    and status = #{status,jdbcType=VARCHAR}
  </select>

  <select id="findByMemberIdAndPileSn" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from pile_reservation_info
    where del_flag = '0'
    and member_id = #{memberId,jdbcType=VARCHAR}
    and pile_sn = #{pileSn,jdbcType=VARCHAR}
  </select>

  <select id="selectActiveReservationByPileConnectorCode" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from pile_reservation_info
    where del_flag = '0'
    and reservation_type = 'single'
    and status = '1'
    and pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR}
  </select>
</mapper>