<?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.xinda.itsm.mapper.ExampleReportMapper">
    
    <resultMap type="ExampleReport" id="ExampleReportResult">
        <result property="exampleReportId"    column="example_report_id"    />
        <result property="type"    column="type"    />
        <result property="cycle"    column="cycle"    />
        <result property="content"    column="content"    />
        <result property="pushMethod"    column="push_method"    />
        <result property="userId"    column="user_id"    />
        <result property="receiver"    column="receiver"    />
        <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="startDate"    column="start_date"    />
        <result property="endDate"    column="end_date"    />
    </resultMap>

    <sql id="selectExampleReportVo">
        select example_report_id, type, cycle, content, push_method, user_id, receiver, create_by, create_time, update_by, update_time, start_date, end_date from example_report
    </sql>

    <select id="selectExampleReportList" parameterType="ExampleReport" resultMap="ExampleReportResult">
        <include refid="selectExampleReportVo"/>
        <where>  
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="cycle != null  and cycle != ''"> and cycle = #{cycle}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="pushMethod != null  and pushMethod != ''"> and push_method = #{pushMethod}</if>
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
            <if test="receiver != null  and receiver != ''"> and receiver = #{receiver}</if>
            <if test="startDate != null "> and start_date = #{startDate}</if>
            <if test="endDate != null "> and end_date = #{endDate}</if>
        </where>
    </select>
    
    <select id="selectExampleReportByExampleReportId" parameterType="Long" resultMap="ExampleReportResult">
        <include refid="selectExampleReportVo"/>
        where example_report_id = #{exampleReportId}
    </select>
        
    <insert id="insertExampleReport" parameterType="ExampleReport">
        insert into example_report
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="exampleReportId != null">example_report_id,</if>
            <if test="type != null">type,</if>
            <if test="cycle != null">cycle,</if>
            <if test="content != null">content,</if>
            <if test="pushMethod != null">push_method,</if>
            <if test="userId != null">user_id,</if>
            <if test="receiver != null">receiver,</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="startDate != null">start_date,</if>
            <if test="endDate != null">end_date,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="exampleReportId != null">#{exampleReportId},</if>
            <if test="type != null">#{type},</if>
            <if test="cycle != null">#{cycle},</if>
            <if test="content != null">#{content},</if>
            <if test="pushMethod != null">#{pushMethod},</if>
            <if test="userId != null">#{userId},</if>
            <if test="receiver != null">#{receiver},</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="startDate != null">#{startDate},</if>
            <if test="endDate != null">#{endDate},</if>
         </trim>
    </insert>

    <update id="updateExampleReport" parameterType="ExampleReport">
        update example_report
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">type = #{type},</if>
            <if test="cycle != null">cycle = #{cycle},</if>
            <if test="content != null">content = #{content},</if>
            <if test="pushMethod != null">push_method = #{pushMethod},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="receiver != null">receiver = #{receiver},</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="startDate != null">start_date = #{startDate},</if>
            <if test="endDate != null">end_date = #{endDate},</if>
        </trim>
        where example_report_id = #{exampleReportId}
    </update>

    <delete id="deleteExampleReportByExampleReportId" parameterType="Long">
        delete from example_report where example_report_id = #{exampleReportId}
    </delete>

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