-
admin
2024-05-17 1ccd6932893e47722574e6d1147e63b2ec4972c1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?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.jcdm.system.mapper.SysLogininforMapper">
 
    <resultMap type="SysLogininfor" id="SysLogininforResult">
        <id     property="infoId"        column="info_id"           />
        <result property="userName"      column="user_name"         />
        <result property="status"        column="status"            />
        <result property="ipaddr"        column="ipaddr"            />
        <result property="loginLocation" column="login_location"    />
        <result property="browser"       column="browser"           />
        <result property="os"            column="os"                />
        <result property="msg"           column="msg"               />
        <result property="loginTime"     column="login_time"        />
    </resultMap>
 
    <insert id="insertLogininfor" parameterType="SysLogininfor">
        insert into sys_logininfor (user_name, status, ipaddr, login_location, browser, os, msg, login_time)
        values (#{userName}, #{status}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{msg}, getdate())
    </insert>
 
    <select id="selectLogininforList" parameterType="SysLogininfor" resultMap="SysLogininforResult">
        select info_id, user_name, ipaddr, login_location, browser, os, status, msg, login_time from sys_logininfor
        <where>
            <if test="ipaddr != null and ipaddr != ''">
                AND ipaddr like concat('%', #{ipaddr}, '%')
            </if>
            <if test="status != null and status != ''">
                AND status = #{status}
            </if>
            <if test="userName != null and userName != ''">
                AND user_name like concat('%', #{userName}, '%')
            </if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                <!--                and <![CDATA[ login_time >= convert(datetime, #{params.beginTime}, 20)]]>-->
                and datediff(d, login_time, #{params.beginTime}) <![CDATA[<=]]> 0
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                <!--                and <![CDATA[ login_time <= convert(datetime, #{params.endTime}, 20)]]>-->
                and datediff(d, login_time, #{params.endTime}) <![CDATA[>=]]> 0
            </if>
        </where>
        order by info_id desc
    </select>
 
    <delete id="deleteLogininforByIds" parameterType="Long">
        delete from sys_logininfor where info_id in
        <foreach collection="array" item="infoId" open="(" separator="," close=")">
            #{infoId}
        </foreach>
    </delete>
 
    <update id="cleanLogininfor">
        truncate table sys_logininfor
    </update>
 
</mapper>