<?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.microservices.system.mapper.ForgeUserActionMapper">

    <resultMap type="com.microservices.system.domain.ForgeUserAction" id="ForgeUserActionsResult">
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="actionType" column="action_type"/>
        <result property="actionId" column="action_id"/>
        <result property="createdAt" column="created_at"/>
        <result property="updatedAt" column="updated_at"/>
        <result property="ip" column="ip"/>
        <result property="dataBank" column="data_bank"/>
    </resultMap>

    <sql id="selectForgeUserActionsVo">
        select id,
               user_id,
               action_type,
               action_id,
               created_at,
               updated_at,
               ip,
               data_bank
        from user_actions
    </sql>
    <select id="selectForgeUserActionList"
            parameterType="com.microservices.system.domain.vo.ForgeUserActionSearchVo"
            resultMap="ForgeUserActionsResult">
        <include refid="selectForgeUserActionsVo"/>
        <where>
            and action_type = #{actionType}
            <if test="startTime != null  and endTime != null">
                and created_at between #{startTime} and #{endTime}
            </if>
        </where>

    </select>
</mapper>