<?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.IntroductionMapper">
    
    <resultMap type="Introduction" id="IntroductionResult">
        <result property="introId"       column="intro_id"       />
        <result property="title"         column="title"          />
        <result property="summary"       column="summary"        />
        <result property="images"        column="images"         />
        <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="selectIntroductionVo">
        select intro_id, title, summary, images, status, create_by, create_time, update_by, update_time, remark 
		from introduction
    </sql>
    
    <select id="selectIntroductionById" parameterType="Long" resultMap="IntroductionResult">
        <include refid="selectIntroductionVo"/>
        where intro_id = #{introId}
    </select>
    
    <select id="selectIntroductionOne" resultMap="IntroductionResult">
        <include refid="selectIntroductionVo"/>
        limit 1
    </select>
    
    <insert id="insertIntroduction" parameterType="Introduction">
        insert into introduction (
			<if test="title != null and title != ''">title, </if>
			<if test="summary != null and summary != '' ">summary, </if>
			<if test="images != null and images != '' ">images, </if>
			<if test="status != null and status != '' ">status, </if>
			<if test="remark != null and remark != ''">remark,</if>
 			<if test="createBy != null and createBy != ''">create_by,</if>
 			create_time
 		)values(
			<if test="title != null and title != ''">#{title}, </if>
			<if test="summary != null and summary != ''">#{summary}, </if>
			<if test="images != null and images != ''">#{images}, </if>
			<if test="status != null and status != ''">#{status}, </if>
			<if test="remark != null and remark != ''">#{remark},</if>
 			<if test="createBy != null and createBy != ''">#{createBy},</if>
 			sysdate()
		)
    </insert>
	 
    <update id="updateIntroduction" parameterType="Introduction">
        update introduction 
        <set>
            <if test="title != null and title != ''">title = #{title}, </if>
            <if test="summary != null">summary = #{summary}, </if>
            <if test="images != null">images = #{images}, </if>
            <if test="status != null and status != ''">status = #{status}, </if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
 			update_time = sysdate()
        </set>
        where intro_id = #{introId}
    </update>
	
    <delete id="deleteIntroductionById" parameterType="Long">
        delete from introduction where intro_id = #{introId}
    </delete>
    
</mapper>
