<?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.house365.ws.dao.mapper.ReportLogMapper">

    <resultMap id="infoMap" type="com.house365.beans.entity.ReportLogEntity">
        <result property="id" column="id"/>
        <result property="relateId" column="relate_id"/>
        <result property="action" column="action"/>
        <result property="createId" column="create_id"/>
        <result property="createName" column="create_name"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <insert id="save" parameterType="com.house365.beans.entity.ReportLogEntity">
        INSERT INTO report_log (
            relate_id,
            action,
            create_id,
            create_name,
            create_time
        )
        VALUES (
            #{relateId},
            #{action},
            #{createId},
            #{createName},
            #{createTime}
        )
    </insert>

    <select id="getById" resultMap="infoMap" parameterType="map">
        SELECT
         *
        FROM
        report_log
        where  id = #{id}
    </select>

    <select id="queryByConditions" resultMap="infoMap" parameterType="map">
        SELECT
         *
        FROM
        report_log
        where 1 = 1
        <if test="action != null and action != ''">
            AND action LIKE CONCAT('',#{action},'%')
        </if>
        <if test="relateId != null and relateId > 0 ">
            AND relate_id = #{relateId}
        </if>
        ORDER BY id DESC
    </select>

</mapper>