<?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.miaxis.report.mapper.ReportInfoMapper">

    <resultMap type="ReportInfo" id="ReportInfoResult">
        <result property="id"    column="id"    />
        <result property="mobile"    column="mobile"    />
        <result property="reportContent"    column="report_content"    />
        <result property="reportType"    column="report_type"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="status"    column="status"    />
    </resultMap>

    <sql id="selectReportInfoVo">
        select id, mobile, report_content, report_type, create_time, update_time, status from report_info
    </sql>

    <select id="selectReportInfoList" parameterType="ReportInfo" resultMap="ReportInfoResult">
        <include refid="selectReportInfoVo"/>
        <where>
            <if test="mobile != null  and mobile != ''"> and mobile = #{mobile}</if>
            <if test="reportContent != null  and reportContent != ''"> and report_content = #{reportContent}</if>
            <if test="reportType != null "> and report_type = #{reportType}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>

    <select id="selectReportInfoById" parameterType="Long" resultMap="ReportInfoResult">
        <include refid="selectReportInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertReportInfo" parameterType="ReportInfo" useGeneratedKeys="true" keyProperty="id">
        insert into report_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="mobile != null">mobile,</if>
            <if test="reportContent != null">report_content,</if>
            <if test="reportType != null">report_type,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="status != null">status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="mobile != null">#{mobile},</if>
            <if test="reportContent != null">#{reportContent},</if>
            <if test="reportType != null">#{reportType},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="status != null">#{status},</if>
         </trim>
    </insert>

    <update id="updateReportInfo" parameterType="ReportInfo">
        update report_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="mobile != null">mobile = #{mobile},</if>
            <if test="reportContent != null">report_content = #{reportContent},</if>
            <if test="reportType != null">report_type = #{reportType},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="status != null">status = #{status},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteReportInfoById" parameterType="Long">
        delete from report_info where id = #{id}
    </delete>

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

</mapper>
