<?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.WelfareGuideMapper">
    
    <resultMap type="WelfareGuide" id="WelfareGuideResult">
        <result property="id"    column="id"    />
        <result property="photoPath"    column="photo_path"    />
        <result property="welfareTitle"    column="welfare_title"    />
        <result property="welfareProfile"    column="welfare_profile"    />
        <result property="welfareContent"    column="welfare_content"    />
        <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="selectWelfareGuideVo">
        select id,photo_path, welfare_title, welfare_profile, welfare_content, status, create_by, create_time, update_by, update_time, remark from welfare_guide
    </sql>

    <select id="selectWelfareGuideList" parameterType="WelfareGuide" resultMap="WelfareGuideResult">
        <include refid="selectWelfareGuideVo"/>
        <where>  
            <if test="welfareTitle != null  and welfareTitle != ''"> and welfare_title = #{welfareTitle}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectWelfareGuideById" parameterType="Long" resultMap="WelfareGuideResult">
        <include refid="selectWelfareGuideVo"/>
        where id = #{id}
    </select>
    <select id="getInfoNew" parameterType="Long" resultMap="WelfareGuideResult">
        <include refid="selectWelfareGuideVo"/>
        order by update_time desc
        limit 1
    </select>

    <insert id="insertWelfareGuide" parameterType="WelfareGuide" useGeneratedKeys="true" keyProperty="id">
        insert into welfare_guide
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="photoPath != null">photo_path,</if>
            <if test="welfareTitle != null">welfare_title,</if>
            <if test="welfareProfile != null">welfare_profile,</if>
            <if test="welfareContent != null">welfare_content,</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="photoPath != null">#{photoPath},</if>
            <if test="welfareTitle != null">#{welfareTitle},</if>
            <if test="welfareProfile != null">#{welfareProfile},</if>
            <if test="welfareContent != null">#{welfareContent},</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="updateWelfareGuide" parameterType="WelfareGuide">
        update welfare_guide
        <trim prefix="SET" suffixOverrides=",">
            <if test="photoPath != null">photo_path = #{photoPath},</if>
            <if test="welfareTitle != null">welfare_title = #{welfareTitle},</if>
            <if test="welfareProfile != null">welfare_profile = #{welfareProfile},</if>
            <if test="welfareContent != null">welfare_content = #{welfareContent},</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="deleteWelfareGuideById" parameterType="Long">
        delete from welfare_guide where id = #{id}
    </delete>

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