<?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.vetti.hotake.mapper.HotakeSysNoticeMapper">

    <resultMap type="HotakeSysNotice" id="HotakeSysNoticeResult">
        <result property="id" column="id"/>
        <result property="noticeTypeId" column="notice_type_id"/>
        <result property="cvId" column="cv_id"/>
        <result property="noticeTitle" column="notice_title"/>
        <result property="noticeContent" column="notice_content"/>
        <result property="sendUserId" column="send_user_id"/>
        <result property="receiveUserId" column="receive_user_id"/>
        <result property="isView" column="is_view"/>
        <result property="imagePath" column="image_path" typeHandler="com.vetti.common.handle.JsonTypeHandler"/>
        <result property="isDel" column="is_del"/>
        <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="selectHotakeSysNoticeVo">
        select id,
               notice_type_id,
               cv_id,
               notice_title,
               notice_content,
               send_user_id,
               receive_user_id,
               is_view,
               is_del,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from hotake_sys_notice
    </sql>

    <select id="selectHotakeSysNoticeList" parameterType="HotakeSysNotice" resultMap="HotakeSysNoticeResult">
        <include refid="selectHotakeSysNoticeVo"/>
        <where>
            <if test="noticeTypeId != null ">and notice_type_id = #{noticeTypeId}</if>
            <if test="cvId != null ">and cv_id = #{cvId}</if>
            <if test="noticeTitle != null  and noticeTitle != ''">and notice_title = #{noticeTitle}</if>
            <if test="noticeContent != null  and noticeContent != ''">and notice_content = #{noticeContent}</if>
            <if test="sendUserId != null ">and send_user_id = #{sendUserId}</if>
            <if test="receiveUserId != null ">and receive_user_id = #{receiveUserId}</if>
            <if test="isView != null  and isView != ''">and is_view = #{isView}</if>
            <if test="isDel != null  and isDel != ''">and is_del = #{isDel}</if>
        </where>
    </select>

    <select id="selectHotakeSysNoticeById" parameterType="Long" resultMap="HotakeSysNoticeResult">
        <include refid="selectHotakeSysNoticeVo"/>
        where id = #{id}
    </select>

    <insert id="insertHotakeSysNotice" parameterType="HotakeSysNotice" useGeneratedKeys="true" keyProperty="id">
        insert into hotake_sys_notice
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="noticeTypeId != null">notice_type_id,</if>
            <if test="cvId != null">cv_id,</if>
            <if test="noticeTitle != null">notice_title,</if>
            <if test="noticeContent != null">notice_content,</if>
            <if test="sendUserId != null">send_user_id,</if>
            <if test="receiveUserId != null">receive_user_id,</if>
            <if test="isView != null">is_view,</if>
            <if test="imagePath != null">image_path,</if>
            <if test="isDel != null">is_del,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="noticeTypeId != null">#{noticeTypeId},</if>
            <if test="cvId != null">#{cvId},</if>
            <if test="noticeTitle != null">#{noticeTitle},</if>
            <if test="noticeContent != null">#{noticeContent},</if>
            <if test="sendUserId != null">#{sendUserId},</if>
            <if test="receiveUserId != null">#{receiveUserId},</if>
            <if test="isView != null">#{isView},</if>
            <if test="imagePath != null">#{imagePath, typeHandler=com.vetti.common.handle.JsonTypeHandler},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateHotakeSysNotice" parameterType="HotakeSysNotice">
        update hotake_sys_notice
        <trim prefix="SET" suffixOverrides=",">
            <if test="noticeTypeId != null">notice_type_id = #{noticeTypeId},</if>
            <if test="cvId != null">cv_id = #{cvId},</if>
            <if test="noticeTitle != null">notice_title = #{noticeTitle},</if>
            <if test="noticeContent != null">notice_content = #{noticeContent},</if>
            <if test="sendUserId != null">send_user_id = #{sendUserId},</if>
            <if test="receiveUserId != null">receive_user_id = #{receiveUserId},</if>
            <if test="isView != null">is_view = #{isView},</if>
            <if test="imagePath != null">image_path =
                #{imagePath, typeHandler=com.vetti.common.handle.JsonTypeHandler},
            </if>
            <if test="isDel != null">is_del = #{isDel},</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="deleteHotakeSysNoticeById" parameterType="Long">
        delete
        from hotake_sys_notice
        where id = #{id}
    </delete>

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

    <insert id="batchInsertHotakeSysNotice">
        insert into hotake_sys_notice( id, notice_type_id, cv_id, notice_title, notice_content, send_user_id,
        receive_user_id, is_view,image_path, is_del, create_by, create_time, update_by, update_time, remark,) values
        <foreach item="item" index="index" collection="list" separator=",">
            ( #{item.id}, #{item.noticeTypeId}, #{item.cvId}, #{item.noticeTitle}, #{item.noticeContent},
            #{item.sendUserId}, #{item.receiveUserId},
            #{item.isView},#{item.imagePath, typeHandler=com.vetti.common.handle.JsonTypeHandler}, #{item.isDel},
            #{item.createBy},
            #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark},)
        </foreach>
    </insert>
</mapper>