UserEventDao.xml 4.53 KB
<?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.diligrp.assistant.logging.dao.UserEventDao">
    <resultMap id="UserEventMap" type="com.diligrp.assistant.logging.model.UserEventDo">
        <id column="id" property="id"/>
        <result column="group_id" property="groupId"/>
        <result column="module_id" property="moduleId"/>
        <result column="action" property="action"/>
        <result column="object_id" property="objectId"/>
        <result column="object_name" property="objectName"/>
        <result column="event" property="event"/>
        <result column="when" property="when"/>
        <result column="user_id" property="userId"/>
        <result column="user_name" property="userName"/>
        <result column="source" property="source"/>
        <result column="created_time" property="createdTime"/>
    </resultMap>

    <insert id="insertUserEvent" parameterType="com.diligrp.assistant.sms.model.SmsTemplateDo">
        INSERT INTO logging_user_event
            (`group_id`, `module_id`, `action`, `object_id`, `object_name`, `event`, `when`, `user_id`, `user_name`, `source`, `created_time`)
        VALUES
            (#{groupId}, #{moduleId}, #{action}, #{objectId}, #{objectName}, #{event}, #{when}, #{userId}, #{userName}, #{source}, #{createdTime})
    </insert>

    <insert id="insertUserEvents">
        INSERT INTO logging_user_event
            (`group_id`, `module_id`, `action`, `object_id`, `object_name`, `event`, `when`, `user_id`, `user_name`, `source`, `created_time`)
        VALUES
            <foreach collection="list" item="item" separator=",">
                (#{item.groupId}, #{item.moduleId}, #{item.action}, #{item.objectId}, #{item.objectName}, #{item.event}, #{item.when}, #{item.userId}, #{item.userName}, #{item.source}, #{item.createdTime})
            </foreach>
    </insert>

    <select id="countUserEvents" parameterType="com.diligrp.assistant.logging.domain.EventPageQuery" resultType="long">
        SELECT
            COUNT(*)
        FROM
            logging_user_event
        <where>
            <if test="groupId != null">
                AND `group_id` = #{groupId}
            </if>
            <if test="moduleId != null">
                AND `module_id` = #{moduleId}
            </if>
            <if test="action != null">
                AND `action` = #{action}
            </if>
            <if test="objectId != null">
                AND `object_id` = #{objectId}
            </if>
            <if test="objectName != null">
                AND `object_name` = #{objectName}
            </if>
            <if test="userId != null">
                AND `user_id` = #{userId}
            </if>
            <if test="userName != null">
                AND `user_name` = #{userName}
            </if>
            <if test="source != null">
                AND `source` = #{source}
            </if>
            <if test="startTime != null">
                <![CDATA[AND `when` >= #{startTime}]]>
            </if>
            <if test="endTime != null">
                <![CDATA[AND `when` <= #{endTime}]]>
            </if>
        </where>
    </select>

    <select id="listUserEvents" parameterType="com.diligrp.assistant.logging.domain.EventPageQuery" resultMap="UserEventMap">
        SELECT
            *
        FROM
            logging_user_event
        <where>
            <if test="groupId != null">
                AND `group_id` = #{groupId}
            </if>
            <if test="moduleId != null">
                AND `module_id` = #{moduleId}
            </if>
            <if test="action != null">
                AND `action` = #{action}
            </if>
            <if test="objectId != null">
                AND `object_id` = #{objectId}
            </if>
            <if test="objectName != null">
                AND `object_name` = #{objectName}
            </if>
            <if test="userId != null">
                AND `user_id` = #{userId}
            </if>
            <if test="userName != null">
                AND `user_name` = #{userName}
            </if>
            <if test="source != null">
                AND `source` = #{source}
            </if>
            <if test="startTime != null">
                <![CDATA[AND `when` >= #{startTime}]]>
            </if>
            <if test="endTime != null">
                <![CDATA[AND `when` <= #{endTime}]]>
            </if>
        </where>
        ORDER BY id DESC
        LIMIT #{start}, #{limit}
    </select>
</mapper>