<?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.ConsultInfoMapper">
    
    <resultMap type="ConsultInfo" id="ConsultInfoResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="subTitle"    column="sub_title"    />
        <result property="bannerImg"    column="banner_img"    />
        <result property="rotaImg"    column="rota_img"    />
        <result property="content"    column="content"    />
        <result property="author"    column="author"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectConsultInfoVo">
        select id, title, sub_title, banner_img, rota_img, content, author, create_time, update_time, is_del from consult_info
    </sql>

    <select id="selectConsultInfoList" parameterType="ConsultInfo" resultMap="ConsultInfoResult">
        <include refid="selectConsultInfoVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="subTitle != null  and subTitle != ''"> and sub_title = #{subTitle}</if>
            <if test="bannerImg != null  and bannerImg != ''"> and banner_img = #{bannerImg}</if>
            <if test="rotaImg != null  and rotaImg != ''"> and rota_img = #{rotaImg}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="author != null  and author != ''"> and author = #{author}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectConsultInfoById" parameterType="String" resultMap="ConsultInfoResult">
        <include refid="selectConsultInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertConsultInfo" parameterType="ConsultInfo" useGeneratedKeys="true" keyProperty="id">
        insert into consult_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,</if>
            <if test="subTitle != null">sub_title,</if>
            <if test="bannerImg != null">banner_img,</if>
            <if test="rotaImg != null">rota_img,</if>
            <if test="content != null">content,</if>
            <if test="author != null">author,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},</if>
            <if test="subTitle != null">#{subTitle},</if>
            <if test="bannerImg != null">#{bannerImg},</if>
            <if test="rotaImg != null">#{rotaImg},</if>
            <if test="content != null">#{content},</if>
            <if test="author != null">#{author},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
         </trim>
    </insert>

    <update id="updateConsultInfo" parameterType="ConsultInfo">
        update consult_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="subTitle != null">sub_title = #{subTitle},</if>
            <if test="bannerImg != null">banner_img = #{bannerImg},</if>
            <if test="rotaImg != null">rota_img = #{rotaImg},</if>
            <if test="content != null">content = #{content},</if>
            <if test="author != null">author = #{author},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteConsultInfoById" parameterType="String">
        delete from consult_info where id = #{id}
    </delete>

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