<?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.UseGuideMapper">
    
    <resultMap type="UseGuide" id="UseGuideResult">
        <result property="id"    column="id"    />
        <result property="useTitle"    column="use_title"    />
        <result property="useProfile"    column="use_profile"    />
        <result property="useContent"    column="use_content"    />
        <result property="useVersion"    column="use_version"    />
        <result property="status"    column="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="selectUseGuideVo">
        select id, use_title, use_profile, use_content, use_version, status, create_by, create_time, update_by, update_time, remark from use_guide
    </sql>

    <select id="selectUseGuideList" parameterType="UseGuide" resultMap="UseGuideResult">
        <include refid="selectUseGuideVo"/>
        <where>  
            <if test="useVersion != null  and useVersion != ''"> and use_version = #{useVersion}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectUseGuideById" parameterType="Long" resultMap="UseGuideResult">
        <include refid="selectUseGuideVo"/>
        where id = #{id}
    </select>
    <select id="getInfoNew" parameterType="Long" resultMap="UseGuideResult">
        <include refid="selectUseGuideVo"/>
        order by update_time desc
        limit 1
    </select>

    <insert id="insertUseGuide" parameterType="UseGuide" useGeneratedKeys="true" keyProperty="id">
        insert into use_guide
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="useTitle != null">use_title,</if>
            <if test="useProfile != null">use_profile,</if>
            <if test="useContent != null">use_content,</if>
            <if test="useVersion != null">use_version,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
            create_time,update_time
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="useTitle != null">#{useTitle},</if>
            <if test="useProfile != null">#{useProfile},</if>
            <if test="useContent != null">#{useContent},</if>
            <if test="useVersion != null">#{useVersion},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
            sysdate(),sysdate()
         </trim>
    </insert>

    <update id="updateUseGuide" parameterType="UseGuide">
        update use_guide
        <trim prefix="SET" suffixOverrides=",">
            <if test="useTitle != null">use_title = #{useTitle},</if>
            <if test="useProfile != null">use_profile = #{useProfile},</if>
            <if test="useContent != null">use_content = #{useContent},</if>
            <if test="useVersion != null">use_version = #{useVersion},</if>
            <if test="status != null">status = #{status},</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 id = #{id}
    </update>

    <delete id="deleteUseGuideById" parameterType="Long">
        delete from use_guide where id = #{id}
    </delete>

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