<?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.ruoyi.web.modules.architecture.mapper.BizEpidemicTreatmentStandardMapper">

    <resultMap type="com.ruoyi.web.modules.architecture.domain.BizEpidemicTreatmentStandard" id="BizEpidemicTreatmentStandardResult">
        <id     property="id"                 column="id"/>
        <result property="standardName"       column="standard_name"/>
        <result property="standardType"      column="standard_type"/>
        <result property="introduction"       column="introduction"/>
        <result property="contentFileUrl"    column="content_file_url"/>
        <result property="contentFilePath"   column="content_file_path"/>
        <result property="contentFileName"    column="content_file_name"/>
        <result property="coverFileUrl"      column="cover_file_url"/>
        <result property="coverFilePath"     column="cover_file_path"/>
        <result property="publishStatus"     column="publish_status"/>
        <result property="kbSyncStatus"      column="kb_sync_status"/>
        <result property="kbDocId"           column="kb_doc_id"/>
        <result property="publishTime"       column="publish_time"/>
        <result property="offlineTime"       column="offline_time"/>
        <result property="createBy"          column="create_by"/>
        <result property="createTime"        column="create_time"/>
        <result property="updateBy"          column="update_by"/>
        <result property="updateTime"        column="update_time"/>
        <result property="remark"            column="remark"/>
    </resultMap>

    <sql id="selectVo">
        select id, standard_name, standard_type, introduction,
               content_file_url, content_file_path, content_file_name,
               cover_file_url, cover_file_path,
               publish_status, kb_sync_status, kb_doc_id,
               publish_time, offline_time,
               create_by, create_time, update_by, update_time, remark
        from biz_epidemic_treatment_standard
    </sql>

    <select id="selectBizEpidemicTreatmentStandardById" parameterType="long" resultMap="BizEpidemicTreatmentStandardResult">
        <include refid="selectVo"/>
        where id = #{id}
    </select>

    <select id="selectBizEpidemicTreatmentStandardList" parameterType="com.ruoyi.web.modules.architecture.domain.BizEpidemicTreatmentStandard" resultMap="BizEpidemicTreatmentStandardResult">
        <include refid="selectVo"/>
        <where>
            <if test="keyword != null and keyword != ''">
                and (standard_name like concat('%', #{keyword}, '%')
                or introduction like concat('%', #{keyword}, '%'))
            </if>
            <if test="standardType != null">
                and standard_type = #{standardType}
            </if>
        </where>
        order by create_time desc, id desc
    </select>

    <insert id="insertBizEpidemicTreatmentStandard" parameterType="com.ruoyi.web.modules.architecture.domain.BizEpidemicTreatmentStandard" useGeneratedKeys="true" keyProperty="id">
        insert into biz_epidemic_treatment_standard (
            standard_name, standard_type, introduction,
            content_file_url, content_file_path, content_file_name,
            cover_file_url, cover_file_path,
            publish_status, kb_sync_status, kb_doc_id,
            publish_time, offline_time,
            create_by, create_time, remark
        ) values (
            #{standardName}, #{standardType}, #{introduction},
            #{contentFileUrl}, #{contentFilePath}, #{contentFileName},
            #{coverFileUrl}, #{coverFilePath},
            #{publishStatus}, #{kbSyncStatus}, #{kbDocId},
            #{publishTime}, #{offlineTime},
            #{createBy}, sysdate(), #{remark}
        )
    </insert>

    <update id="updateBizEpidemicTreatmentStandard" parameterType="com.ruoyi.web.modules.architecture.domain.BizEpidemicTreatmentStandard">
        update biz_epidemic_treatment_standard set
            standard_name = #{standardName},
            standard_type = #{standardType},
            introduction = #{introduction},
            content_file_url = #{contentFileUrl},
            content_file_path = #{contentFilePath},
            content_file_name = #{contentFileName},
            cover_file_url = #{coverFileUrl},
            cover_file_path = #{coverFilePath},
            publish_status = #{publishStatus},
            kb_sync_status = #{kbSyncStatus},
            kb_doc_id = #{kbDocId},
            publish_time = #{publishTime},
            offline_time = #{offlineTime},
            update_by = #{updateBy},
            update_time = sysdate(),
            remark = #{remark}
        where id = #{id}
    </update>

    <delete id="deleteBizEpidemicTreatmentStandardById" parameterType="long">
        delete from biz_epidemic_treatment_standard where id = #{id}
    </delete>

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