<?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.younike.system.mapper.PersonalMerchantSettleResourceMapper">
  <resultMap id="PersonalMerchantSettleResourceResult" type="com.younike.system.domain.PersonalMerchantSettleResource">
    <id column="personal_merchant_settle_resource_id" property="personalMerchantSettleResourceId" />
    <result column="personal_settle_id" property="personalSettleId" />
    <result column="resource_url" property="resourceUrl" />
    <result column="del_flag" property="delFlag" />
    <result column="create_by" property="createBy" />
    <result column="create_time" property="createTime" />
    <result column="update_by" property="updateBy" />
    <result column="update_time" property="updateTime" />
    <result column="remark" property="remark" />
  </resultMap>

  <sql id="Base_Column_List">
    select personal_merchant_settle_resource_id, personal_settle_id, resource_url, del_flag, create_by, create_time, update_by, update_time, remark from personal_merchant_settle_resource
  </sql>

  <select id="selectPersonalMerchantSettleResourceList" resultMap="PersonalMerchantSettleResourceResult">
    <include refid="Base_Column_List"/>
    where del_flag = '0'
    and personal_settle_id = #{personalSettleId}
  </select>

  <insert id="insertPersonalMerchantSettleResource" parameterType="com.younike.system.domain.PersonalMerchantSettleResource" useGeneratedKeys="true" keyProperty="personalMerchantSettleResourceId">
    insert into personal_merchant_settle_resource
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="personalSettleId != null">personal_settle_id,</if>
      <if test="resourceUrl != null and resourceUrl != ''">resource_url,</if>
      <if test="delFlag != null">del_flag,</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="remark != null and remark != ''">remark,</if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="personalSettleId != null">#{personalSettleId},</if>
      <if test="resourceUrl != null and resourceUrl != ''">#{resourceUrl},</if>
      <if test="delFlag != null">#{delFlag},</if>
      <if test="createBy != null">#{createBy},</if>
      <if test="createTime != null">#{createTime},</if>
      <if test="updateBy != null">#{updateBy},</if>
      <if test="updateTime != null">#{updateTime},</if>
      <if test="remark != null and remark != ''">#{remark},</if>
    </trim>
  </insert>

  <update id="updatePersonalMerchantSettleResource" parameterType="com.younike.system.domain.PersonalMerchantSettleResource">
    update personal_merchant_settle_resource
    <trim prefix="SET" suffixOverrides=",">
      <if test="personalSettleId != null">personal_settle_id = #{personalSettleId},</if>
      <if test="resourceUrl != null and resourceUrl != ''">resource_url = #{resourceUrl},</if>
      <if test="delFlag != null">del_flag = #{delFlag},</if>
      <if test="createBy != null">create_by = #{createBy},</if>
      <if test="createTime != null">create_time = #{createTime},</if>
      <if test="updateBy != null">update_by = #{updateBy},</if>
      <if test="updateTime != null">update_time = #{updateTime},</if>
      <if test="remark != null and remark != ''">remark = #{remark},</if>
    </trim>
    where personal_merchant_settle_resource_id = #{personalMerchantSettleResourceId}
  </update>

  <delete id="deleteByPersonalMerchantSettleResourceId" parameterType="Long">
    delete from personal_merchant_settle_resource where personal_merchant_settle_resource_id = #{personalMerchantSettleResourceId}
  </delete>

  <insert id="insertBatch" parameterType="com.younike.system.domain.PersonalMerchantSettleResource" >
    insert into personal_merchant_settle_resource
    (personal_settle_id, resource_url, create_by, update_by, remark)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.personalSettleId}, #{item.resourceUrl}, #{item.createBy}, #{item.updateBy}, #{item.remark})
    </foreach>
    ;
  </insert>

</mapper>