<?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.zehong.system.mapper.TSecurityDisseminateMapper">
    
    <resultMap type="TSecurityDisseminate" id="TSecurityDisseminateResult">
        <result property="securityId"    column="security_id"    />
        <result property="securityType"    column="security_type"    />
        <result property="title"    column="title"    />
        <result property="content"    column="content"    />
        <result property="filePath"    column="file_path"    />
        <result property="people"    column="people"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectTSecurityDisseminateVo">
        select security_id, security_type, title, content, file_path, people, create_time from t_security_disseminate
    </sql>

    <select id="selectTSecurityDisseminateList" parameterType="TSecurityDisseminate" resultMap="TSecurityDisseminateResult">
        <include refid="selectTSecurityDisseminateVo"/>
        <where>  
            <if test="securityType != null  and securityType != ''"> and security_type = #{securityType}</if>
            <if test="title != null  and title != ''"> and title like concat('%',#{title},'%')  </if>
            <if test="people != null  and people != ''"> and people like concat('%',#{people},'%')</if>
        </where>
    </select>
    
    <select id="selectTSecurityDisseminateById" parameterType="Long" resultMap="TSecurityDisseminateResult">
        <include refid="selectTSecurityDisseminateVo"/>
        where security_id = #{securityId}
    </select>
        
    <insert id="insertTSecurityDisseminate" parameterType="TSecurityDisseminate" useGeneratedKeys="true" keyProperty="securityId">
        insert into t_security_disseminate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="securityType != null and securityType != ''">security_type,</if>
            <if test="title != null and title != ''">title,</if>
            <if test="content != null and content != ''">content,</if>
            <if test="filePath != null">file_path,</if>
            <if test="people != null and people != ''">people,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="securityType != null and securityType != ''">#{securityType},</if>
            <if test="title != null and title != ''">#{title},</if>
            <if test="content != null and content != ''">#{content},</if>
            <if test="filePath != null">#{filePath},</if>
            <if test="people != null and people != ''">#{people},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateTSecurityDisseminate" parameterType="TSecurityDisseminate">
        update t_security_disseminate
        <trim prefix="SET" suffixOverrides=",">
            <if test="securityType != null and securityType != ''">security_type = #{securityType},</if>
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="content != null and content != ''">content = #{content},</if>
            <if test="filePath != null">file_path = #{filePath},</if>
            <if test="people != null and people != ''">people = #{people},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where security_id = #{securityId}
    </update>

    <delete id="deleteTSecurityDisseminateById" parameterType="Long">
        delete from t_security_disseminate where security_id = #{securityId}
    </delete>

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