<?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.yiqi.app.mapper.AppNotifyMapper">

    <resultMap type="AppNotify" id="AppNotifyResult">
        <result property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="content" column="content"/>
        <result property="clickType" column="click_type"/>
        <result property="redirectContent" column="redirect_content"/>
        <result property="isRead" column="is_read"/>
        <result property="isAll" column="is_all"/>
        <result property="appUserId" column="app_user_id"/>
        <result property="createById" column="create_by_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateById" column="update_by_id"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
        <result property="notifyType" column="notify_type"/>
    </resultMap>

    <sql id="selectAppNotifyVo">
        select id, title, content, click_type, redirect_content, is_read, is_all, app_user_id, create_by_id, create_by, create_time, update_by_id, update_by, update_time, remark, notify_type
        from app_notify
    </sql>

    <sql id="selectAppNotifyQueryVo">
        select id, title, content, click_type, is_read, is_all, app_user_id, create_by_id, create_by, create_time, update_by_id, update_by, update_time, remark, notify_type
        from app_notify
    </sql>

    <select id="selectAppNotifyList" parameterType="AppNotify" resultMap="AppNotifyResult">
        <include refid="selectAppNotifyQueryVo"/>
        <where>
            <if test="title != null  and title != ''">
                and title = #{title}
            </if>
            <if test="content != null  and content != ''">
                and content = #{content}
            </if>
            <if test="clickType != null  and clickType != ''">
                and click_type = #{clickType}
            </if>
            <if test="redirectContent != null  and redirectContent != ''">
                and redirect_content = #{redirectContent}
            </if>
            <if test="isRead != null  and isRead != ''">
                and is_read = #{isRead}
            </if>
        </where>
        order by create_time desc
    </select>

    <select id="selectAppNotifyById" parameterType="Long"
            resultMap="AppNotifyResult">
        <include refid="selectAppNotifyVo"/>
        where id = #{id}
    </select>

    <insert id="insertAppNotify" parameterType="AppNotify" useGeneratedKeys="true"
            keyProperty="id">
        insert into app_notify
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,
            </if>
            <if test="content != null">content,
            </if>
            <if test="clickType != null">click_type,
            </if>
            <if test="redirectContent != null">redirect_content,
            </if>
            <if test="isRead != null">is_read,
            </if>
            <if test="isAll != null">is_all,
            </if>
            <if test="appUserId != null">app_user_id,
            </if>
            <if test="createById != null">create_by_id,
            </if>
            <if test="createBy != null">create_by,
            </if>
            <if test="createTime != null">create_time,
            </if>
            <if test="updateById != null">update_by_id,
            </if>
            <if test="updateBy != null">update_by,
            </if>
            <if test="updateTime != null">update_time,
            </if>
            <if test="remark != null">remark,
            </if>
            <if test="notifyType != null">notify_type,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},
            </if>
            <if test="content != null">#{content},
            </if>
            <if test="clickType != null">#{clickType},
            </if>
            <if test="redirectContent != null">#{redirectContent},
            </if>
            <if test="isRead != null">#{isRead},
            </if>
            <if test="isAll != null">#{isAll},
            </if>
            <if test="appUserId != null">#{appUserId},
            </if>
            <if test="createById != null">#{createById},
            </if>
            <if test="createBy != null">#{createBy},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
            <if test="updateById != null">#{updateById},
            </if>
            <if test="updateBy != null">#{updateBy},
            </if>
            <if test="updateTime != null">#{updateTime},
            </if>
            <if test="remark != null">#{remark},
            </if>
            <if test="notifyType != null">#{notifyType},
            </if>
        </trim>
    </insert>

    <update id="updateAppNotify" parameterType="AppNotify">
        update app_notify
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title =
                #{title},
            </if>
            <if test="content != null">content =
                #{content},
            </if>
            <if test="clickType != null">click_type =
                #{clickType},
            </if>
            <if test="redirectContent != null">redirect_content =
                #{redirectContent},
            </if>
            <if test="isRead != null">is_read =
                #{isRead},
            </if>
            <if test="isAll != null">is_all =
                #{isAll},
            </if>
            <if test="appUserId != null">app_user_id =
                #{appUserId},
            </if>
            <if test="createById != null">create_by_id =
                #{createById},
            </if>
            <if test="createBy != null">create_by =
                #{createBy},
            </if>
            <if test="createTime != null">create_time =
                #{createTime},
            </if>
            <if test="updateById != null">update_by_id =
                #{updateById},
            </if>
            <if test="updateBy != null">update_by =
                #{updateBy},
            </if>
            <if test="updateTime != null">update_time =
                #{updateTime},
            </if>
            <if test="remark != null">remark =
                #{remark},
            </if>
            <if test="notifyType != null">notify_type =
                #{notifyType},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppNotifyById" parameterType="Long">
            delete from app_notify where id = #{id}
        </delete>

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



</mapper>