<?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.ym.mec.biz.dal.dao.PageMonitorDao">

    <resultMap type="com.ym.mec.biz.dal.entity.PageMonitor" id="PageMonitor">
        <result column="id_" property="id"/>
        <result property="updateTime" column="update_time_"/>
        <result property="userId" column="user_id_"/>
        <result property="times" column="times_"/>
        <result property="event" column="event_"/>
        <result property="eventName" column="event_name_"/>
        <result property="pageName" column="page_name_"/>
        <result property="pageUrl" column="page_url_"/>
    </resultMap>

    <!-- 根据主键查询一条记录 -->
    <select id="get" resultMap="PageMonitor">
		SELECT * FROM page_monitor WHERE id_ = #{id} 
	</select>

    <!-- 全查询 -->
    <select id="findAll" resultMap="PageMonitor">
		SELECT * FROM page_monitor ORDER BY id_
	</select>
    <select id="findByUserIdAndEvent" resultMap="PageMonitor">
        SELECT * FROM page_monitor WHERE user_id_ = #{userId} AND event_ = #{event} LIMIT 1 FOR UPDATE
    </select>

    <!-- 向数据库增加一条记录 -->
    <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.PageMonitor" useGeneratedKeys="true" keyColumn="id"
            keyProperty="id">
        INSERT INTO page_monitor (page_name_,page_url_,event_,event_name_,user_id_,times_,update_time_)
        VALUES(#{pageName},#{pageUrl},#{event},#{eventName},#{userId},#{times},NOW())
    </insert>

    <!-- 根据主键查询一条记录 -->
    <update id="update" parameterType="com.ym.mec.biz.dal.entity.Organization">
        UPDATE page_monitor
        <set>
            <if test="pageName != null">
                page_name_ = #{pageName},
            </if>
            <if test="pageUrl != null">
                page_url_ = #{pageUrl},
            </if>
            <if test="event != null">
                event_ = #{event},
            </if>
            <if test="eventName != null">
                event_name_ = #{eventName},
            </if>
            <if test="userId != null">
                user_id_ = #{userId},
            </if>
            <if test="times != null">
                times_ = #{times},
            </if>
            <if test="updateTime != null">
                update_time_ = #{updateTime}
            </if>
        </set>
        WHERE id_ = #{id}
    </update>
</mapper>
