<?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.fs.live.mapper.LiveCompanyCodeMapper">

    <resultMap type="LiveCompanyCode" id="LiveCompanyCodeResult">
        <result property="id"    column="id"    />
        <result property="liveId"    column="live_id"    />
        <result property="companyId"    column="company_id"    />
        <result property="companyUserId"    column="company_user_id"    />
        <result property="liveCodeUrl"    column="live_code_url"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectLiveCompanyCodeVo">
        select id, live_id, company_id, company_user_id, live_code_url, create_time, update_time from live_company_code
    </sql>

    <select id="selectLiveCompanyCodeList" parameterType="LiveCompanyCode" resultMap="LiveCompanyCodeResult">
        <include refid="selectLiveCompanyCodeVo"/>
        <where>
            <if test="liveId != null "> and live_id = #{liveId}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
            <if test="liveCodeUrl != null  and liveCodeUrl != ''"> and live_code_url = #{liveCodeUrl}</if>
        </where>
    </select>

    <select id="selectLiveCompanyCodeById" parameterType="Long" resultMap="LiveCompanyCodeResult">
        <include refid="selectLiveCompanyCodeVo"/>
        where id = #{id}
    </select>

    <insert id="insertLiveCompanyCode" parameterType="LiveCompanyCode">
        insert into live_company_code
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="liveId != null">live_id,</if>
            <if test="companyId != null">company_id,</if>
            <if test="companyUserId != null">company_user_id,</if>
            <if test="liveCodeUrl != null">live_code_url,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="liveId != null">#{liveId},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="companyUserId != null">#{companyUserId},</if>
            <if test="liveCodeUrl != null">#{liveCodeUrl},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateLiveCompanyCode" parameterType="LiveCompanyCode">
        update live_company_code
        <trim prefix="SET" suffixOverrides=",">
            <if test="liveId != null">live_id = #{liveId},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
            <if test="liveCodeUrl != null">live_code_url = #{liveCodeUrl},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteLiveCompanyCodeById" parameterType="Long">
        delete from live_company_code where id = #{id}
    </delete>

    <delete id="deleteLiveCompanyCodeByIds" parameterType="String">
        delete from live_company_code where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
