<?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.dgtly.wxportal.mapper.HelpCenterMapper">
    
    <resultMap type="com.dgtly.wxportal.domain.HelpCenter" id="HelpCenterResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="describe"    column="describ"    />
        <result property="fileUrl"    column="file_url"    />
        <result property="fileType"    column="file_type"    />
        <result property="classifyTitle"    column="classify_title"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectHelpCenterVo">
        select id, title, describ, file_url, file_type, classify_title, del_flag from help_center
    </sql>

    <select id="selectHelpCenterList" parameterType="com.dgtly.wxportal.domain.HelpCenter" resultMap="HelpCenterResult">
        <include refid="selectHelpCenterVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title like concat('%', #{title}, '%')</if>
            <if test="describe != null  and describe != ''"> and describ like concat('%', #{describe}, '%')</if>
            <if test="fileUrl != null  and fileUrl != ''"> and file_url like concat('%', #{fileUrl}, '%')</if>
            <if test="fileType != null  and fileType != ''"> and file_type like concat('%', #{fileType}, '%')</if>
            <if test="classifyTitle != null  and classifyTitle != ''"> and classify_title like concat('%', #{classifyTitle}, '%')</if>
            <if test="delFlag != null "> and del_flag = #{delFlag}</if>
        </where>
    </select>
    
    <select id="selectHelpCenterById" parameterType="Long" resultMap="HelpCenterResult">
        <include refid="selectHelpCenterVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertHelpCenter" parameterType="com.dgtly.wxportal.domain.HelpCenter" useGeneratedKeys="true" keyProperty="id">
        insert into help_center
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null  and title != ''">title,</if>
            <if test="describe != null  and describe != ''">describ,</if>
            <if test="fileUrl != null  and fileUrl != ''">file_url,</if>
            <if test="fileType != null  and fileType != ''">file_type,</if>
            <if test="classifyTitle != null  and classifyTitle != ''">classify_title,</if>
            <if test="delFlag != null ">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null  and title != ''">#{title},</if>
            <if test="describe != null  and describe != ''">#{describe},</if>
            <if test="fileUrl != null  and fileUrl != ''">#{fileUrl},</if>
            <if test="fileType != null  and fileType != ''">#{fileType},</if>
            <if test="classifyTitle != null  and classifyTitle != ''">#{classifyTitle},</if>
            <if test="delFlag != null ">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateHelpCenter" parameterType="com.dgtly.wxportal.domain.HelpCenter">
        update help_center
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null  and title != ''">title = #{title},</if>
            <if test="describe != null  and describe != ''">describ = #{describe},</if>
            <if test="fileUrl != null  and fileUrl != ''">file_url = #{fileUrl},</if>
            <if test="fileType != null  and fileType != ''">file_type = #{fileType},</if>
            <if test="classifyTitle != null  and classifyTitle != ''">classify_title = #{classifyTitle},</if>
            <if test="delFlag != null ">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteHelpCenterById" parameterType="Long">
        delete from help_center where id = #{id}
    </delete>

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