<?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.yunfeiyun.agmp.common.web.system.mapper.SysNoticeMapper">
    
    <resultMap type="SysNotice" id="SysNoticeResult">
        <result property="noticeId"       column="noticeId"       />
        <result property="noticeTitle"    column="noticeTitle"    />
        <result property="noticeType"     column="noticeType"     />
        <result property="noticeContent"  column="noticeContent"  />
        <result property="noticeShowstatus"         column="noticeShowstatus"          />
        <result property="noticeCreator"       column="noticeCreator"       />
        <result property="noticeCreateddate"     column="noticeCreateddate"     />
        <result property="noticeModifier"       column="noticeModifier"       />
        <result property="noticeModifieddate"     column="noticeModifieddate"     />
        <result property="noticeRemark"         column="noticeRemark"          />
    </resultMap>
    
    <sql id="selectNoticeVo">
        select noticeId, noticeTitle, noticeType, cast(noticeContent as char) as noticeContent, noticeShowstatus, noticeCreator, noticeCreateddate, noticeModifieddate, noticeModifieddate, noticeRemark
		from SysNotice
    </sql>
    
    <select id="selectNoticeById" parameterType="String" resultMap="SysNoticeResult">
        <include refid="selectNoticeVo"/>
        where noticeId = #{noticeId}
    </select>
    
    <select id="selectNoticeList" parameterType="SysNotice" resultMap="SysNoticeResult">
        <include refid="selectNoticeVo"/>
        <where>
			<if test="noticeTitle != null and noticeTitle != ''">
				AND noticeTitle like concat('%', #{noticeTitle}, '%')
			</if>
			<if test="noticeType != null and noticeType != ''">
				AND noticeType = #{noticeType}
			</if>
			<if test="noticeCreator != null and noticeCreator != ''">
				AND noticeCreator like concat('%', #{noticeCreator}, '%')
			</if>
		</where>
    </select>
    
    <insert id="insertNotice" parameterType="SysNotice">
        insert into SysNotice (
            <if test="noticeId != null and noticeId != '' ">noticeId, </if>
			<if test="noticeTitle != null and noticeTitle != '' ">noticeTitle, </if>
			<if test="noticeType != null and noticeType != '' ">noticeType, </if>
			<if test="noticeContent != null and noticeContent != '' ">noticeContent, </if>
			<if test="noticeShowstatus != null and noticeShowstatus != '' ">noticeShowstatus, </if>
			<if test="noticeRemark != null and noticeRemark != ''">noticeRemark,</if>
 			<if test="noticeCreator != null and noticeCreator != ''">noticeCreator,</if>
        noticeCreateddate
 		)values(
            <if test="noticeId != null and noticeId != '' ">#{noticeId}, </if>
			<if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle}, </if>
			<if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
			<if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if>
			<if test="noticeShowstatus != null and noticeShowstatus != ''">#{noticeShowstatus}, </if>
			<if test="noticeRemark != null and noticeRemark != ''">#{noticeRemark},</if>
 			<if test="noticeCreator != null and noticeCreator != ''">#{noticeCreator},</if>
        date_format(sysdate(),'%Y-%m-%d %H:%i:%s')
		)
    </insert>
	 
    <update id="updateNotice" parameterType="SysNotice">
        update SysNotice
        <set>
            <if test="noticeTitle != null and noticeTitle != ''">noticeTitle = #{noticeTitle}, </if>
            <if test="noticeType != null and noticeType != ''">noticeType = #{noticeType}, </if>
            <if test="noticeContent != null">noticeContent = #{noticeContent}, </if>
            <if test="noticeShowstatus != null and noticeShowstatus != ''">noticeShowstatus = #{noticeShowstatus}, </if>
            <if test="noticeModifier != null and noticeModifier != ''">noticeModifier = #{noticeModifier},</if>
            noticeModifieddate = date_format(sysdate(),'%Y-%m-%d %H:%i:%s')
        </set>
        where noticeId = #{noticeId}
    </update>
	
    <delete id="deleteNoticeById" parameterType="String">
        delete from SysNotice where noticeId = #{noticeId}
    </delete>
    
    <delete id="deleteNoticeByIds" parameterType="String">
        delete from SysNotice where noticeId in
        <foreach item="noticeId" collection="array" open="(" separator="," close=")">
            #{noticeId}
        </foreach>
    </delete>
    
</mapper>