<?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.system.mapper.ZxSpeakMapper">
    
    <resultMap type="ZxSpeak" id="ZxSpeakResult">
        <result property="speakId"    column="speak_id"    />
        <result property="speakTitle"    column="speak_title"    />
        <result property="name"    column="name"    />
        <result property="userId"    column="user_id"    />
        <result property="inputName"    column="input_name"    />
        <result property="conferenceId"    column="conference_id"    />
        <result property="conferenceTitle"    column="conference_title"    />
        <result property="speakUnit"    column="speak_unit"    />
        <result property="deptId"    column="dept_id"    />
        <result property="speakType"    column="speak_type"    />
        <result property="speakTime"    column="speak_time"    />
        <result property="publishTime"    column="publish_time"    />
        <result property="speakStatus"    column="speak_status"    />
        <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="selectZxSpeakVo">
        select speak_id, speak_title, name,user_id, input_name, conference_id,conference_title, speak_unit,dept_id, speak_type, speak_time, publish_time, speak_status, create_by, create_time, update_by, update_time, remark from zx_speak
    </sql>

    <select id="selectZxSpeakList" parameterType="ZxSpeak" resultMap="ZxSpeakResult">
        <include refid="selectZxSpeakVo"/>
        <where>  
            <if test="speakTitle != null  and speakTitle != ''"> and speak_title = #{speakTitle}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="inputName != null  and inputName != ''"> and input_name like concat('%', #{inputName}, '%')</if>
            <if test="conferenceId != null "> and conference_id = #{conferenceId}</if>
            <if test="conferenceTitle != null and conferenceTitle != ''"> and conference_title = #{conferenceTitle}</if>
            <if test="speakUnit != null  and speakUnit != ''"> and speak_unit = #{speakUnit}</if>
            <if test="deptId != null  "> and dept_id = #{deptId}</if>
            <if test="speakType != null  and speakType != ''"> and speak_type = #{speakType}</if>
            <if test="speakTime != null "> and speak_time = #{speakTime}</if>
            <if test="publishTime != null "> and publish_time = #{publishTime}</if>
            <if test="speakStatus != null  and speakStatus != ''"> and speak_status = #{speakStatus}</if>
            <if test="userId != null  "> and user_id = #{userId}</if>
            <if test="year != null and year != ''"><!-- 开始时间检索 -->
                AND date_format(publish_time,'%Y') = #{year}
            </if>
        </where>
        order by publish_time DESC
    </select>
    
    <select id="selectZxSpeakBySpeakId" parameterType="Long" resultMap="ZxSpeakResult">
        <include refid="selectZxSpeakVo"/>
        where speak_id = #{speakId}
    </select>
        
    <insert id="insertZxSpeak" parameterType="ZxSpeak" useGeneratedKeys="true" keyProperty="speakId">
        insert into zx_speak
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="speakTitle != null and speakTitle != ''">speak_title,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="userId != null ">user_id,</if>
            <if test="inputName != null and inputName != ''">input_name,</if>
            <if test="conferenceId != null">conference_id,</if>
            <if test="conferenceTitle != null and conferenceTitle != ''">conference_title,</if>
            <if test="speakUnit != null and speakUnit != ''">speak_unit,</if>
            <if test="deptId != null ">dept_id,</if>
            <if test="speakType != null and speakType != ''">speak_type,</if>
            <if test="speakTime != null">speak_time,</if>
            <if test="publishTime != null">publish_time,</if>
            <if test="speakStatus != null">speak_status,</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">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="speakTitle != null and speakTitle != ''">#{speakTitle},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="userId != null and userId != ''">#{userId},</if>
            <if test="inputName != null and inputName != ''">#{inputName},</if>
            <if test="conferenceId != null">#{conferenceId},</if>
            <if test="conferenceTitle != null and conferenceTitle != ''">#{conferenceTitle},</if>
            <if test="speakUnit != null and speakUnit != ''">#{speakUnit},</if>
            <if test="deptId != null ">#{deptId},</if>
            <if test="speakType != null and speakType != ''">#{speakType},</if>
            <if test="speakTime != null">#{speakTime},</if>
            <if test="publishTime != null">#{publishTime},</if>
            <if test="speakStatus != null">#{speakStatus},</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">#{remark},</if>
         </trim>
    </insert>

    <update id="updateZxSpeak" parameterType="ZxSpeak">
        update zx_speak
        <trim prefix="SET" suffixOverrides=",">
            <if test="speakTitle != null and speakTitle != ''">speak_title = #{speakTitle},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="userId != null and userId != ''">user_id = #{userId},</if>
            <if test="inputName != null and inputName != ''">input_name = #{inputName},</if>
            <if test="conferenceId != null">conference_id = #{conferenceId},</if>
            <if test="conferenceTitle != null and conferenceTitle != ''">conference_title = #{conferenceTitle},</if>
            <if test="speakUnit != null and speakUnit != ''">speak_unit = #{speakUnit},</if>
            <if test="deptId != null ">dept_id = #{deptId},</if>
            <if test="speakType != null and speakType != ''">speak_type = #{speakType},</if>
            <if test="speakTime != null">speak_time = #{speakTime},</if>
            <if test="publishTime != null">publish_time = #{publishTime},</if>
            <if test="speakStatus != null">speak_status = #{speakStatus},</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">remark = #{remark},</if>
        </trim>
        where speak_id = #{speakId}
    </update>

    <delete id="deleteZxSpeakBySpeakId" parameterType="Long">
        delete from zx_speak where speak_id = #{speakId}
    </delete>

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