<?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.THiddenLibraryMapper">
    
    <resultMap type="THiddenLibrary" id="THiddenLibraryResult">
        <result property="libraryId"    column="library_id"    />
        <result property="libraryName"    column="library_name"    />
        <result property="libraryContent"    column="library_content"    />
    </resultMap>

    <sql id="selectTHiddenLibraryVo">
        select library_id, library_name, library_content from t_hidden_library
    </sql>

    <select id="selectTHiddenLibraryList" parameterType="THiddenLibrary" resultMap="THiddenLibraryResult">
        <include refid="selectTHiddenLibraryVo"/>
        <where>  
            <if test="libraryName != null  and libraryName != ''"> and library_name like concat('%', #{libraryName}, '%')</if>
        </where>
    </select>
    
    <select id="selectTHiddenLibraryById" parameterType="Long" resultMap="THiddenLibraryResult">
        <include refid="selectTHiddenLibraryVo"/>
        where library_id = #{libraryId}
    </select>
        
    <insert id="insertTHiddenLibrary" parameterType="THiddenLibrary" useGeneratedKeys="true" keyProperty="libraryId">
        insert into t_hidden_library
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="libraryName != null and libraryName != ''">library_name,</if>
            <if test="libraryContent != null and libraryContent != ''">library_content,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="libraryName != null and libraryName != ''">#{libraryName},</if>
            <if test="libraryContent != null and libraryContent != ''">#{libraryContent},</if>
         </trim>
    </insert>

    <update id="updateTHiddenLibrary" parameterType="THiddenLibrary">
        update t_hidden_library
        <trim prefix="SET" suffixOverrides=",">
            <if test="libraryName != null and libraryName != ''">library_name = #{libraryName},</if>
            <if test="libraryContent != null and libraryContent != ''">library_content = #{libraryContent},</if>
        </trim>
        where library_id = #{libraryId}
    </update>

    <delete id="deleteTHiddenLibraryById" parameterType="Long">
        delete from t_hidden_library where library_id = #{libraryId}
    </delete>

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