<?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.api.manage.dao.operationManagement.SysNotificationManagementDao">
    <select id="list" parameterType="com.api.model.operationManagement.SearchNotificationManagement" resultType="com.api.vo.operationManagement.VoNotificationManagement">
        select snm.*,su.actual_name as create_name,
        (
            case snm.modify_date is null when true then snm.create_date else snm.modify_date end
        ) as update_date
        from sys_notification_management as snm,sys_user as su
        where snm.create_id = su.id
    </select>

    <insert id="insert" parameterType="com.api.model.operationManagement.NotificationManagement">
        insert into sys_notification_management(
            id,
            title,
            content,
            suffix,
            reading_volume,
            push_status,
            push_object,
            <if test="pushDate != null">
                push_date,
            </if>
            <if test="timingPush != null">
                timing_push,
            </if>
            create_id,
            create_date
        ) values (
            #{id},
            #{title},
            #{content},
            #{suffix},
            #{readingVolume},
            #{pushStatus},
            #{pushObject},
            <if test="pushDate != null">
                #{pushDate},
            </if>
            <if test="timingPush != null">
                #{timingPush},
            </if>
            #{createId},
            #{createDate}
        )
    </insert>

    <select id="findById" parameterType="java.lang.Integer" resultType="com.api.vo.operationManagement.VoFindByIdNotificationManagement">
        select * from sys_notification_management where id =#{id}
    </select>

    <update id="update" parameterType="com.api.model.operationManagement.NotificationManagement">
        update sys_notification_management
        <set>
            <if test="title != null and title != ''">
                title = #{title},
            </if>
            <if test="content != null and content != ''">
                content = #{content},
            </if>
            <if test="suffix != null and  suffix != ''">
                suffix = #{suffix},
            </if>
            <if test="pushObject != null">
                push_object = #{pushObject},
            </if>
            <if test="timingPush != null">
                timing_push = #{timingPush},
            </if>
            modify_id = #{modifyId},
            modify_date = #{modifyDate}
        </set>
        where id = #{id}
    </update>

    <delete id="delete" parameterType="java.lang.Integer">
        delete from sys_notification_management where id =#{id}
    </delete>
</mapper>