<?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.FsCourseSopLogsMapper">

    <resultMap type="FsCourseSopLogs" id="FsCourseSopLogsResult">
        <result property="id"    column="id"    />
        <result property="qwUserid"    column="qw_userid"    />
        <result property="externalUserId"    column="external_user_id"    />
        <result property="watchStatus"    column="watch_status"    />
        <result property="contentJson"    column="content_json"    />
        <result property="sendStatus"    column="send_status"    />
        <result property="sendTime"    column="send_time"    />
        <result property="sendTimeJson"    column="send_time_json"    />
        <result property="companyId"    column="company_id"    />
        <result property="receivingStatus"    column="receiving_status"    />
        <result property="msgId"    column="msg_id"    />
        <result property="sopId"    column="sop_id"    />
        <result property="realSendTime"    column="real_send_time"    />
        <result property="sopType"    column="sop_type"    />
        <result property="businessId"    column="business_id"    />
        <result property="remark"    column="remark"    />
        <result property="companyUserId"    column="company_user_id"    />
        <result property="customerId"    column="customer_id"    />
        <result property="corpId"    column="corp_id"    />
    </resultMap>

    <sql id="selectFsCourseSopLogsVo">
        select id, qw_userid, external_user_id, watch_status, content_json, send_status, send_time, send_time_json, company_id, receiving_status, msg_id, sop_id, real_send_time, sop_type, business_id,remark, company_user_id,customer_id,corp_id from fs_course_sop_logs
    </sql>

    <select id="selectFsCourseSopLogsList" parameterType="FsCourseSopLogs" resultMap="FsCourseSopLogsResult">
        <include refid="selectFsCourseSopLogsVo"/>
        <where>
            <if test="qwUserid != null  and qwUserid != ''"> and qw_userid = #{qwUserid}</if>
            <if test="externalUserId != null  and externalUserId != ''"> and external_user_id = #{externalUserId}</if>
            <if test="watchStatus != null "> and watch_status = #{watchStatus}</if>
            <if test="contentJson != null  and contentJson != ''"> and content_json = #{contentJson}</if>
            <if test="sendStatus != null "> and send_status = #{sendStatus}</if>
            <if test="sendTime != null "> and send_time = #{sendTime}</if>
            <if test="sendTimeJson != null "> and send_time_json = #{sendTimeJson}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="receivingStatus != null "> and receiving_status = #{receivingStatus}</if>
            <if test="msgId != null  and msgId != ''"> and msg_id = #{msgId}</if>
            <if test="sopId != null "> and sop_id = #{sopId}</if>
            <if test="realSendTime != null "> and real_send_time = #{realSendTime}</if>
            <if test="sopType != null "> and sop_type = #{sopType}</if>
            <if test="businessId != null "> and business_id = #{businessId}</if>
            <if test="remark != null "> and remark = #{remark}</if>
            <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
            <if test="customerId != null "> and customer_id = #{customerId}</if>
            <if test="corpId != null "> and corp_id = #{corpId}</if>
        </where>
    </select>

    <select id="selectFsCourseSopLogsById" parameterType="Long" resultMap="FsCourseSopLogsResult">
        <include refid="selectFsCourseSopLogsVo"/>
        where id = #{id}
    </select>

    <insert id="insertFsCourseSopLogs" parameterType="FsCourseSopLogs" useGeneratedKeys="true" keyProperty="id">
        insert into fs_course_sop_logs
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="qwUserid != null">qw_userid,</if>
            <if test="externalUserId != null">external_user_id,</if>
            <if test="watchStatus != null">watch_status,</if>
            <if test="contentJson != null">content_json,</if>
            <if test="sendStatus != null">send_status,</if>
            <if test="sendTime != null">send_time,</if>
            <if test="sendTimeJson != null">send_time_json,</if>
            <if test="companyId != null">company_id,</if>
            <if test="receivingStatus != null">receiving_status,</if>
            <if test="msgId != null">msg_id,</if>
            <if test="sopId != null">sop_id,</if>
            <if test="realSendTime != null">real_send_time,</if>
            <if test="sopType != null">sop_type,</if>
            <if test="businessId != null">business_id,</if>
            <if test="remark != null">remark,</if>
            <if test="companyUserId != null">company_user_id,</if>
            <if test="customerId != null">customer_id,</if>
            <if test="corpId != null">corp_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="qwUserid != null">#{qwUserid},</if>
            <if test="externalUserId != null">#{externalUserId},</if>
            <if test="watchStatus != null">#{watchStatus},</if>
            <if test="contentJson != null">#{contentJson},</if>
            <if test="sendStatus != null">#{sendStatus},</if>
            <if test="sendTime != null">#{sendTime},</if>
            <if test="sendTimeJson != null">#{sendTimeJson},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="receivingStatus != null">#{receivingStatus},</if>
            <if test="msgId != null">#{msgId},</if>
            <if test="sopId != null">#{sopId},</if>
            <if test="realSendTime != null">#{realSendTime},</if>
            <if test="sopType != null">#{sopType},</if>
            <if test="businessId != null">#{businessId},</if>
            <if test="remark != null">#{remark},</if>
            <if test="companyUserId != null">#{companyUserId},</if>
            <if test="customerId != null">#{customerId},</if>
            <if test="corpId != null">#{corp_id},</if>
         </trim>
    </insert>

    <update id="updateFsCourseSopLogs" parameterType="FsCourseSopLogs">
        update fs_course_sop_logs
        <trim prefix="SET" suffixOverrides=",">
            <if test="qwUserid != null">qw_userid = #{qwUserid},</if>
            <if test="externalUserId != null">external_user_id = #{externalUserId},</if>
            <if test="watchStatus != null">watch_status = #{watchStatus},</if>
            <if test="contentJson != null">content_json = #{contentJson},</if>
            <if test="sendStatus != null">send_status = #{sendStatus},</if>
            <if test="sendTime != null">send_time = #{sendTime},</if>
            <if test="sendTimeJson != null">send_time_json = #{sendTimeJson},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="receivingStatus != null">receiving_status = #{receivingStatus},</if>
            <if test="msgId != null">msg_id = #{msgId},</if>
            <if test="sopId != null">sop_id = #{sopId},</if>
            <if test="realSendTime != null">real_send_time = #{realSendTime},</if>
            <if test="sopType != null">sop_type = #{sopType},</if>
            <if test="businessId != null">business_id = #{businessId},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
            <if test="customerId != null">customer_id = #{customerId},</if>
            <if test="corpId != null">corp_id = #{corpId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsCourseSopLogsById" parameterType="Long">
        delete from fs_course_sop_logs where id = #{id}
    </delete>

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