<?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.course.mapper.FsCourseSopAppLinkMapper">

    <resultMap type="FsCourseSopAppLink" id="FsCourseSopAppLinkResult">
        <result property="id"    column="id"    />
        <result property="link"    column="link"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="companyId"    column="company_id"    />
        <result property="companyUserId"    column="company_user_id"    />
        <result property="qwUserId"    column="qw_user_id"    />
        <result property="qwUserName"    column="qw_user_name"    />
        <result property="corpId"    column="corp_id"    />
        <result property="courseId"    column="course_id"    />
        <result property="courseTitle"    column="course_title"    />
        <result property="courseUrl"    column="course_url"    />
        <result property="videoId"    column="video_id"    />
        <result property="videoTitle"    column="video_title"    />
        <result property="appRealLink"    column="app_real_Link"    />
        <result property="qwExternalId"    column="qw_external_id"    />
        <result property="isRead"    column="is_read"    />
    </resultMap>

    <sql id="selectFsCourseSopAppLinkVo">
        select id, link, create_time, update_time, company_id, company_user_id, qw_user_id, qw_user_name, corp_id, course_id, course_title, course_url, video_id, video_title, app_real_Link, qw_external_id,is_read from fs_course_sop_app_link
    </sql>

    <select id="selectFsCourseSopAppLinkList" parameterType="FsCourseSopAppLink" resultMap="FsCourseSopAppLinkResult">
        <include refid="selectFsCourseSopAppLinkVo"/>
        <where>
            <if test="link != null  and link != ''"> and link = #{link}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
            <if test="qwUserId != null  and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
            <if test="qwUserName != null  and qwUserName != ''"> and qw_user_name like concat('%', #{qwUserName}, '%')</if>
            <if test="corpId != null  and corpId != ''"> and corp_id = #{corpId}</if>
            <if test="courseId != null "> and course_id = #{courseId}</if>
            <if test="courseTitle != null  and courseTitle != ''"> and course_title = #{courseTitle}</if>
            <if test="courseUrl != null  and courseUrl != ''"> and course_url = #{courseUrl}</if>
            <if test="videoId != null "> and video_id = #{videoId}</if>
            <if test="videoTitle != null  and videoTitle != ''"> and video_title = #{videoTitle}</if>
            <if test="appRealLink != null  and appRealLink != ''"> and app_real_Link = #{appRealLink}</if>
            <if test="qwExternalId != null "> and qw_external_id = #{qwExternalId}</if>
            <if test="isRead != null "> and is_read = #{isRead}</if>
        </where>
    </select>

    <select id="selectFsCourseSopAppLinkById" parameterType="Long" resultMap="FsCourseSopAppLinkResult">
        <include refid="selectFsCourseSopAppLinkVo"/>
        where id = #{id}
    </select>

    <insert id="insertFsCourseSopAppLink" parameterType="FsCourseSopAppLink" useGeneratedKeys="true" keyProperty="id">
        insert into fs_course_sop_app_link
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="link != null">link,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="companyId != null">company_id,</if>
            <if test="companyUserId != null">company_user_id,</if>
            <if test="qwUserId != null">qw_user_id,</if>
            <if test="qwUserName != null">qw_user_name,</if>
            <if test="corpId != null">corp_id,</if>
            <if test="courseId != null">course_id,</if>
            <if test="courseTitle != null">course_title,</if>
            <if test="courseUrl != null">course_url,</if>
            <if test="videoId != null">video_id,</if>
            <if test="videoTitle != null">video_title,</if>
            <if test="appRealLink != null">app_real_Link,</if>
            <if test="qwExternalId != null">qw_external_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="link != null">#{link},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="companyUserId != null">#{companyUserId},</if>
            <if test="qwUserId != null">#{qwUserId},</if>
            <if test="qwUserName != null">#{qwUserName},</if>
            <if test="corpId != null">#{corpId},</if>
            <if test="courseId != null">#{courseId},</if>
            <if test="courseTitle != null">#{courseTitle},</if>
            <if test="courseUrl != null">#{courseUrl},</if>
            <if test="videoId != null">#{videoId},</if>
            <if test="videoTitle != null">#{videoTitle},</if>
            <if test="appRealLink != null">#{appRealLink},</if>
            <if test="qwExternalId != null">#{qwExternalId},</if>
         </trim>
    </insert>

    <insert id="insertFsCourseSopAppLinkBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO fs_course_sop_app_link
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="courseAppSopLinks != null and courseAppSopLinks.size() &gt; 0">
                <!-- 假设所有日志对象的字段一致 -->
                <!-- 动态生成列列表，基于第一个日志对象 -->
                <foreach collection="courseAppSopLinks" item="item" index="index" open="" close="" separator="">
                    <if test="index == 0">
                        <if test="item.link != null">link,</if>
                        <if test="item.createTime != null">create_time,</if>
                        <if test="item.updateTime != null">update_time,</if>
                        <if test="item.companyId != null">company_id,</if>
                        <if test="item.companyUserId != null">company_user_id,</if>
                        <if test="item.qwUserId != null">qw_user_id,</if>
                        <if test="item.qwUserName != null">qw_user_name,</if>
                        <if test="item.corpId != null">corp_id,</if>
                        <if test="item.courseId != null">course_id,</if>
                        <if test="item.courseTitle != null">course_title,</if>
                        <if test="item.courseUrl != null">course_url,</if>
                        <if test="item.videoId != null">video_id,</if>
                        <if test="item.videoTitle != null">video_title,</if>
                        <if test="item.appRealLink != null">app_real_Link,</if>
                        <if test="item.qwExternalId != null">qw_external_id,</if>
                        <if test="item.isRead != null">is_read,</if>
                    </if>
                </foreach>
            </if>
        </trim>
        <trim prefix="VALUES">
            <foreach collection="courseAppSopLinks" item="item" separator=",">
                (<trim suffixOverrides=",">
                <if test="item.link != null">#{item.link},</if>
                <if test="item.createTime != null">#{item.createTime},</if>
                <if test="item.updateTime != null">#{item.updateTime},</if>
                <if test="item.companyId != null">#{item.companyId},</if>
                <if test="item.companyUserId != null">#{item.companyUserId},</if>
                <if test="item.qwUserId != null">#{item.qwUserId},</if>
                <if test="item.qwUserName != null">#{item.qwUserName},</if>
                <if test="item.corpId != null">#{item.corpId},</if>
                <if test="item.courseId != null">#{item.courseId},</if>
                <if test="item.courseTitle != null">#{item.courseTitle},</if>
                <if test="item.courseUrl != null">#{item.courseUrl},</if>
                <if test="item.videoId != null">#{item.videoId},</if>
                <if test="item.videoTitle != null">#{item.videoTitle},</if>
                <if test="item.appRealLink != null">#{item.appRealLink},</if>
                <if test="item.qwExternalId != null">#{item.qwExternalId},</if>
                <if test="item.isRead != null">#{item.isRead},</if>
            </trim>)
            </foreach>
        </trim>
    </insert>


    <update id="updateFsCourseSopAppLink" parameterType="FsCourseSopAppLink">
        update fs_course_sop_app_link
        <trim prefix="SET" suffixOverrides=",">
            <if test="link != null">link = #{link},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
            <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
            <if test="qwUserName != null">qw_user_name = #{qwUserName},</if>
            <if test="corpId != null">corp_id = #{corpId},</if>
            <if test="courseId != null">course_id = #{courseId},</if>
            <if test="courseTitle != null">course_title = #{courseTitle},</if>
            <if test="courseUrl != null">course_url = #{courseUrl},</if>
            <if test="videoId != null">video_id = #{videoId},</if>
            <if test="videoTitle != null">video_title = #{videoTitle},</if>
            <if test="appRealLink != null">app_real_Link = #{appRealLink},</if>
            <if test="qwExternalId != null">qw_external_id = #{qwExternalId},</if>
            <if test="isRead != null">is_read = #{isRead},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsCourseSopAppLinkById" parameterType="Long">
        delete from fs_course_sop_app_link where id = #{id}
    </delete>

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