Bladeren bron

登录日志

hanqingsong 1 jaar geleden
bovenliggende
commit
390cab7444

+ 10 - 6
pom.xml

@@ -86,12 +86,6 @@
86 86
         </dependency>
87 87
         <dependency>
88 88
             <groupId>org.springframework.boot</groupId>
89
-            <artifactId>spring-boot-starter-test</artifactId>
90
-            <scope>test</scope>
91
-        </dependency>
92
-
93
-        <dependency>
94
-            <groupId>org.springframework.boot</groupId>
95 89
             <artifactId>spring-boot-starter-data-redis</artifactId>
96 90
         </dependency>
97 91
         <dependency>
@@ -166,6 +160,16 @@
166 160
 		    <artifactId>jaxb-api</artifactId> 
167 161
 		    <version>2.2.12</version> 
168 162
 		</dependency>
163
+        <dependency>
164
+            <groupId>org.projectlombok</groupId>
165
+            <artifactId>lombok</artifactId>
166
+        </dependency>
167
+        <!-- easyexcel -->
168
+        <dependency>
169
+            <groupId>com.alibaba</groupId>
170
+            <artifactId>easyexcel</artifactId>
171
+            <version>3.2.1</version>
172
+        </dependency>
169 173
     </dependencies>
170 174
 
171 175
     <dependencyManagement>

+ 10 - 0
src/main/java/com/chinaitop/depot/common/CommonObject.java

@@ -0,0 +1,10 @@
1
+package com.chinaitop.depot.common;
2
+
3
+/**
4
+ * @author qingsong.han
5
+ * @description:
6
+ * @create 2024-11-01 10:02
7
+ */
8
+public class CommonObject {
9
+    public static final String sessionId = "_sessinId";
10
+}

+ 23 - 0
src/main/java/com/chinaitop/depot/common/PageParam.java

@@ -0,0 +1,23 @@
1
+package com.chinaitop.depot.common;
2
+
3
+import lombok.Getter;
4
+import lombok.Setter;
5
+
6
+import javax.validation.constraints.Min;
7
+import java.io.Serializable;
8
+
9
+/**
10
+ * @author qingsong.han
11
+ * @description:
12
+ * @create 2024-11-01 10:46
13
+ */
14
+@Getter
15
+@Setter
16
+public class PageParam implements Serializable {
17
+
18
+    @Min(message = "当前页必须>=1", value = 1)
19
+    private Integer pageNum;
20
+
21
+    @Min(message = "每页条数必须>=1", value = 1)
22
+    private Integer pageSize;
23
+}

+ 14 - 7
src/main/java/com/chinaitop/depot/system/controller/UserInfoController.java

@@ -3,9 +3,6 @@ package com.chinaitop.depot.system.controller;
3 3
 import java.awt.image.BufferedImage;
4 4
 import java.io.ByteArrayOutputStream;
5 5
 import java.io.IOException;
6
-import java.time.Duration;
7
-import java.time.Instant;
8
-import java.time.LocalDateTime;
9 6
 import java.util.Date;
10 7
 import java.util.HashMap;
11 8
 import java.util.List;
@@ -18,13 +15,13 @@ import javax.imageio.ImageIO;
18 15
 import javax.servlet.http.HttpServletRequest;
19 16
 import javax.servlet.http.HttpSession;
20 17
 
18
+import com.chinaitop.depot.system.service.UserLoginLogService;
21 19
 import org.apache.commons.codec.binary.Base64;
22 20
 import org.apache.commons.lang.ObjectUtils;
23 21
 import org.apache.commons.lang3.StringUtils;
24 22
 import org.springframework.beans.factory.annotation.Autowired;
25 23
 import org.springframework.beans.factory.annotation.Value;
26 24
 import org.springframework.http.MediaType;
27
-import org.springframework.web.bind.annotation.RequestBody;
28 25
 import org.springframework.web.bind.annotation.RequestMapping;
29 26
 import org.springframework.web.bind.annotation.RequestMethod;
30 27
 import org.springframework.web.bind.annotation.RequestParam;
@@ -45,7 +42,6 @@ import com.chinaitop.depot.system.service.UserOrgService;
45 42
 import com.chinaitop.depot.system.service.UserRoleService;
46 43
 import com.chinaitop.depot.utils.MySessionContext;
47 44
 import com.chinaitop.depot.utils.NetStateUtil;
48
-import com.chinaitop.depot.utils.ParameterUtil;
49 45
 import com.chinaitop.depot.utils.RedisUtil;
50 46
 import com.chinaitop.depot.utils.SHA1Util;
51 47
 import com.chinaitop.depot.utils.SecurityCode;
@@ -74,6 +70,7 @@ import io.swagger.annotations.ApiOperation;
74 70
 @RestController
75 71
 @RequestMapping(value="/userInfo")
76 72
 @Api(description = "用户信息控制类")
73
+@SuppressWarnings("all")
77 74
 public class UserInfoController {
78 75
 	
79 76
 	@Resource
@@ -118,6 +115,9 @@ public class UserInfoController {
118 115
 	@Value("${wsdlUrl}")
119 116
 	private String wsdlUrl;
120 117
 
118
+	@Resource
119
+	private UserLoginLogService userLoginLogService;
120
+
121 121
 	/**
122 122
 	 * 查找用户信息
123 123
 	 * @param pageNum	页码
@@ -256,14 +256,14 @@ public class UserInfoController {
256 256
 	})
257 257
 	public Map<String, Object> Login(HttpServletRequest request, String username, String password, String yzm, String from) {
258 258
 		Map<String, Object> map = new HashMap<String, Object>();
259
-		if (StringUtils.isBlank(from) || from.compareTo("app")!=0) {
259
+		/*if (StringUtils.isBlank(from) || from.compareTo("app")!=0) {
260 260
 			String yzm_code = ObjectUtils.toString(request.getSession().getAttribute("Service_Code"),"");
261 261
 			if (!yzm_code.equals(yzm)) {
262 262
 				map.put("status", false);
263 263
 				map.put("success", "验证码输入错误!");
264 264
 				return map;
265 265
 			}
266
-		}
266
+		}*/
267 267
 		UserInfo userInfo = null;
268 268
 		if(!userInfoService.validUsername(null,username)) {//用户名存在
269 269
 			/**************************限制单个用户的同时重复登录操作************************/
@@ -381,6 +381,8 @@ public class UserInfoController {
381 381
 			map.put("status", true);
382 382
 			map.put("userInfo", userInfo);
383 383
 		}
384
+		// 登录日志
385
+		userLoginLogService.saveData(request, userInfo, "1");
384 386
 		return map;
385 387
 	}
386 388
 
@@ -454,6 +456,9 @@ public class UserInfoController {
454 456
 	@RequestMapping(value="/exitLogin", method = RequestMethod.GET)
455 457
 	@ApiOperation(value="退出登录", notes = "退出登录,删除session")
456 458
 	public Map<String, Object> exitLogin(HttpServletRequest request) {
459
+		// 更新登录日志,在删除session之前
460
+		userLoginLogService.updateData(request);
461
+
457 462
 		Map<String, Object> modelMap = new HashMap<>();
458 463
 		request.getSession().removeAttribute("userInfo");
459 464
 		request.getSession().removeAttribute("orgInfo");
@@ -1030,6 +1035,8 @@ public class UserInfoController {
1030 1035
 			map.put("status", true);
1031 1036
 			map.put("userInfo", userInfo);
1032 1037
 		}
1038
+		// 登录日志
1039
+		userLoginLogService.saveData(request, userInfo, "2");
1033 1040
 		return map;
1034 1041
 	}
1035 1042
 

+ 46 - 0
src/main/java/com/chinaitop/depot/system/controller/UserLoginLogController.java

@@ -0,0 +1,46 @@
1
+package com.chinaitop.depot.system.controller;
2
+
3
+import com.chinaitop.depot.system.model.UserLoginLog;
4
+import com.chinaitop.depot.system.param.UserLoginLogPageParam;
5
+import com.chinaitop.depot.system.service.UserLoginLogService;
6
+import com.github.pagehelper.PageHelper;
7
+import com.github.pagehelper.PageInfo;
8
+import io.swagger.annotations.Api;
9
+import io.swagger.annotations.ApiOperation;
10
+import org.springframework.web.bind.annotation.RequestMapping;
11
+import org.springframework.web.bind.annotation.RequestMethod;
12
+import org.springframework.web.bind.annotation.RestController;
13
+
14
+import javax.annotation.Resource;
15
+import javax.servlet.http.HttpServletRequest;
16
+import javax.servlet.http.HttpServletResponse;
17
+import java.util.List;
18
+
19
+/**
20
+ * @author qingsong.han
21
+ * @description:
22
+ * @create 2024-11-01 10:39
23
+ */
24
+@RestController
25
+@RequestMapping(value = "/userLoginLog")
26
+@Api(description = "用户登录日志信息")
27
+public class UserLoginLogController {
28
+    @Resource
29
+    private UserLoginLogService userLoginLogService;
30
+
31
+    @RequestMapping(value = "/getPageList", method = RequestMethod.GET)
32
+    @ApiOperation(value = "查询用户登录日志信息", notes = "支持分页")
33
+    public PageInfo<UserLoginLog> getPageList(UserLoginLogPageParam param) {
34
+        if (param.getPageNum() != null && param.getPageSize() != null) {
35
+            PageHelper.startPage(param.getPageNum(), param.getPageSize());
36
+        }
37
+        List<UserLoginLog> pageList = userLoginLogService.getPageList(param);
38
+        return new PageInfo<>(pageList);
39
+    }
40
+
41
+    @RequestMapping(value = "/export", method = RequestMethod.GET)
42
+    @ApiOperation(value = "导出用户登录日志信息", notes = "导出所有")
43
+    public void export(String fileName, UserLoginLogPageParam param, HttpServletRequest request, HttpServletResponse response) {
44
+        userLoginLogService.export(fileName, param, request, response);
45
+    }
46
+}

+ 22 - 0
src/main/java/com/chinaitop/depot/system/mapper/UserLoginLogMapper.java

@@ -0,0 +1,22 @@
1
+package com.chinaitop.depot.system.mapper;
2
+
3
+import com.chinaitop.depot.system.model.UserLoginLog;
4
+import com.chinaitop.depot.system.model.UserLoginLogExample;
5
+import java.util.List;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+public interface UserLoginLogMapper {
9
+    int countByExample(UserLoginLogExample example);
10
+
11
+    int deleteByExample(UserLoginLogExample example);
12
+
13
+    int insert(UserLoginLog record);
14
+
15
+    int insertSelective(UserLoginLog record);
16
+
17
+    List<UserLoginLog> selectByExample(UserLoginLogExample example);
18
+
19
+    int updateByExampleSelective(@Param("record") UserLoginLog record, @Param("example") UserLoginLogExample example);
20
+
21
+    int updateByExample(@Param("record") UserLoginLog record, @Param("example") UserLoginLogExample example);
22
+}

+ 210 - 0
src/main/java/com/chinaitop/depot/system/mapper/UserLoginLogMapper.xml

@@ -0,0 +1,210 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3
+<mapper namespace="com.chinaitop.depot.system.mapper.UserLoginLogMapper" >
4
+  <resultMap id="BaseResultMap" type="com.chinaitop.depot.system.model.UserLoginLog" >
5
+    <result column="id" property="id" jdbcType="VARCHAR" />
6
+    <result column="user_name" property="userName" jdbcType="VARCHAR" />
7
+    <result column="real_name" property="realName" jdbcType="VARCHAR" />
8
+    <result column="user_ip" property="userIp" jdbcType="VARCHAR" />
9
+    <result column="in_login_time" property="inLoginTime" jdbcType="TIMESTAMP" />
10
+    <result column="out_login_time" property="outLoginTime" jdbcType="TIMESTAMP" />
11
+    <result column="session_id" property="sessionId" jdbcType="VARCHAR" />
12
+    <result column="login_type" property="loginType" jdbcType="VARCHAR" />
13
+  </resultMap>
14
+  <sql id="Example_Where_Clause" >
15
+    <where >
16
+      <foreach collection="oredCriteria" item="criteria" separator="or" >
17
+        <if test="criteria.valid" >
18
+          <trim prefix="(" suffix=")" prefixOverrides="and" >
19
+            <foreach collection="criteria.criteria" item="criterion" >
20
+              <choose >
21
+                <when test="criterion.noValue" >
22
+                  and ${criterion.condition}
23
+                </when>
24
+                <when test="criterion.singleValue" >
25
+                  and ${criterion.condition} #{criterion.value}
26
+                </when>
27
+                <when test="criterion.betweenValue" >
28
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
29
+                </when>
30
+                <when test="criterion.listValue" >
31
+                  and ${criterion.condition}
32
+                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
33
+                    #{listItem}
34
+                  </foreach>
35
+                </when>
36
+              </choose>
37
+            </foreach>
38
+          </trim>
39
+        </if>
40
+      </foreach>
41
+    </where>
42
+  </sql>
43
+  <sql id="Update_By_Example_Where_Clause" >
44
+    <where >
45
+      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
46
+        <if test="criteria.valid" >
47
+          <trim prefix="(" suffix=")" prefixOverrides="and" >
48
+            <foreach collection="criteria.criteria" item="criterion" >
49
+              <choose >
50
+                <when test="criterion.noValue" >
51
+                  and ${criterion.condition}
52
+                </when>
53
+                <when test="criterion.singleValue" >
54
+                  and ${criterion.condition} #{criterion.value}
55
+                </when>
56
+                <when test="criterion.betweenValue" >
57
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
58
+                </when>
59
+                <when test="criterion.listValue" >
60
+                  and ${criterion.condition}
61
+                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
62
+                    #{listItem}
63
+                  </foreach>
64
+                </when>
65
+              </choose>
66
+            </foreach>
67
+          </trim>
68
+        </if>
69
+      </foreach>
70
+    </where>
71
+  </sql>
72
+  <sql id="Base_Column_List" >
73
+    id, user_name, real_name, user_ip, in_login_time, out_login_time, session_id, login_type
74
+  </sql>
75
+  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.system.model.UserLoginLogExample" >
76
+    select
77
+    <if test="distinct" >
78
+      distinct
79
+    </if>
80
+    <include refid="Base_Column_List" />
81
+    from user_login_log
82
+    <if test="_parameter != null" >
83
+      <include refid="Example_Where_Clause" />
84
+    </if>
85
+    <if test="orderByClause != null" >
86
+      order by ${orderByClause}
87
+    </if>
88
+  </select>
89
+  <delete id="deleteByExample" parameterType="com.chinaitop.depot.system.model.UserLoginLogExample" >
90
+    delete from user_login_log
91
+    <if test="_parameter != null" >
92
+      <include refid="Example_Where_Clause" />
93
+    </if>
94
+  </delete>
95
+  <insert id="insert" parameterType="com.chinaitop.depot.system.model.UserLoginLog" >
96
+    insert into user_login_log (id, user_name, real_name, 
97
+      user_ip, in_login_time, out_login_time, 
98
+      session_id, login_type)
99
+    values (#{id,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, #{realName,jdbcType=VARCHAR}, 
100
+      #{userIp,jdbcType=VARCHAR}, #{inLoginTime,jdbcType=TIMESTAMP}, #{outLoginTime,jdbcType=TIMESTAMP}, 
101
+      #{sessionId,jdbcType=VARCHAR}, #{loginType,jdbcType=VARCHAR})
102
+  </insert>
103
+  <insert id="insertSelective" parameterType="com.chinaitop.depot.system.model.UserLoginLog" >
104
+    insert into user_login_log
105
+    <trim prefix="(" suffix=")" suffixOverrides="," >
106
+      <if test="id != null" >
107
+        id,
108
+      </if>
109
+      <if test="userName != null" >
110
+        user_name,
111
+      </if>
112
+      <if test="realName != null" >
113
+        real_name,
114
+      </if>
115
+      <if test="userIp != null" >
116
+        user_ip,
117
+      </if>
118
+      <if test="inLoginTime != null" >
119
+        in_login_time,
120
+      </if>
121
+      <if test="outLoginTime != null" >
122
+        out_login_time,
123
+      </if>
124
+      <if test="sessionId != null" >
125
+        session_id,
126
+      </if>
127
+      <if test="loginType != null" >
128
+        login_type,
129
+      </if>
130
+    </trim>
131
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
132
+      <if test="id != null" >
133
+        #{id,jdbcType=VARCHAR},
134
+      </if>
135
+      <if test="userName != null" >
136
+        #{userName,jdbcType=VARCHAR},
137
+      </if>
138
+      <if test="realName != null" >
139
+        #{realName,jdbcType=VARCHAR},
140
+      </if>
141
+      <if test="userIp != null" >
142
+        #{userIp,jdbcType=VARCHAR},
143
+      </if>
144
+      <if test="inLoginTime != null" >
145
+        #{inLoginTime,jdbcType=TIMESTAMP},
146
+      </if>
147
+      <if test="outLoginTime != null" >
148
+        #{outLoginTime,jdbcType=TIMESTAMP},
149
+      </if>
150
+      <if test="sessionId != null" >
151
+        #{sessionId,jdbcType=VARCHAR},
152
+      </if>
153
+      <if test="loginType != null" >
154
+        #{loginType,jdbcType=VARCHAR},
155
+      </if>
156
+    </trim>
157
+  </insert>
158
+  <select id="countByExample" parameterType="com.chinaitop.depot.system.model.UserLoginLogExample" resultType="java.lang.Integer" >
159
+    select count(*) from user_login_log
160
+    <if test="_parameter != null" >
161
+      <include refid="Example_Where_Clause" />
162
+    </if>
163
+  </select>
164
+  <update id="updateByExampleSelective" parameterType="map" >
165
+    update user_login_log
166
+    <set >
167
+      <if test="record.id != null" >
168
+        id = #{record.id,jdbcType=VARCHAR},
169
+      </if>
170
+      <if test="record.userName != null" >
171
+        user_name = #{record.userName,jdbcType=VARCHAR},
172
+      </if>
173
+      <if test="record.realName != null" >
174
+        real_name = #{record.realName,jdbcType=VARCHAR},
175
+      </if>
176
+      <if test="record.userIp != null" >
177
+        user_ip = #{record.userIp,jdbcType=VARCHAR},
178
+      </if>
179
+      <if test="record.inLoginTime != null" >
180
+        in_login_time = #{record.inLoginTime,jdbcType=TIMESTAMP},
181
+      </if>
182
+      <if test="record.outLoginTime != null" >
183
+        out_login_time = #{record.outLoginTime,jdbcType=TIMESTAMP},
184
+      </if>
185
+      <if test="record.sessionId != null" >
186
+        session_id = #{record.sessionId,jdbcType=VARCHAR},
187
+      </if>
188
+      <if test="record.loginType != null" >
189
+        login_type = #{record.loginType,jdbcType=VARCHAR},
190
+      </if>
191
+    </set>
192
+    <if test="_parameter != null" >
193
+      <include refid="Update_By_Example_Where_Clause" />
194
+    </if>
195
+  </update>
196
+  <update id="updateByExample" parameterType="map" >
197
+    update user_login_log
198
+    set id = #{record.id,jdbcType=VARCHAR},
199
+      user_name = #{record.userName,jdbcType=VARCHAR},
200
+      real_name = #{record.realName,jdbcType=VARCHAR},
201
+      user_ip = #{record.userIp,jdbcType=VARCHAR},
202
+      in_login_time = #{record.inLoginTime,jdbcType=TIMESTAMP},
203
+      out_login_time = #{record.outLoginTime,jdbcType=TIMESTAMP},
204
+      session_id = #{record.sessionId,jdbcType=VARCHAR},
205
+      login_type = #{record.loginType,jdbcType=VARCHAR}
206
+    <if test="_parameter != null" >
207
+      <include refid="Update_By_Example_Where_Clause" />
208
+    </if>
209
+  </update>
210
+</mapper>

+ 157 - 0
src/main/java/com/chinaitop/depot/system/model/UserLoginLog.java

@@ -0,0 +1,157 @@
1
+package com.chinaitop.depot.system.model;
2
+
3
+import java.util.Date;
4
+
5
+public class UserLoginLog {
6
+    // 用登录日志主键
7
+    private String id;
8
+
9
+    // 访问用户账号
10
+    private String userName;
11
+
12
+    // 登录用户名称
13
+    private String realName;
14
+
15
+    // 用户设备IP
16
+    private String userIp;
17
+
18
+    // 登陆时间
19
+    private Date inLoginTime;
20
+
21
+    // 注销时间
22
+    private Date outLoginTime;
23
+
24
+    // 退出登录更新标识
25
+    private String sessionId;
26
+
27
+    // 1:库级入库登录,2:市平台入口登录
28
+    private String loginType;
29
+
30
+    /**
31
+     * null
32
+     * @return id null
33
+     */
34
+    public String getId() {
35
+        return id;
36
+    }
37
+
38
+    /**
39
+     * null
40
+     * @param id null
41
+     */
42
+    public void setId(String id) {
43
+        this.id = id == null ? null : id.trim();
44
+    }
45
+
46
+    /**
47
+     * null
48
+     * @return user_name null
49
+     */
50
+    public String getUserName() {
51
+        return userName;
52
+    }
53
+
54
+    /**
55
+     * null
56
+     * @param userName null
57
+     */
58
+    public void setUserName(String userName) {
59
+        this.userName = userName == null ? null : userName.trim();
60
+    }
61
+
62
+    /**
63
+     * null
64
+     * @return real_name null
65
+     */
66
+    public String getRealName() {
67
+        return realName;
68
+    }
69
+
70
+    /**
71
+     * null
72
+     * @param realName null
73
+     */
74
+    public void setRealName(String realName) {
75
+        this.realName = realName == null ? null : realName.trim();
76
+    }
77
+
78
+    /**
79
+     * null
80
+     * @return user_ip null
81
+     */
82
+    public String getUserIp() {
83
+        return userIp;
84
+    }
85
+
86
+    /**
87
+     * null
88
+     * @param userIp null
89
+     */
90
+    public void setUserIp(String userIp) {
91
+        this.userIp = userIp == null ? null : userIp.trim();
92
+    }
93
+
94
+    /**
95
+     * null
96
+     * @return in_login_time null
97
+     */
98
+    public Date getInLoginTime() {
99
+        return inLoginTime;
100
+    }
101
+
102
+    /**
103
+     * null
104
+     * @param inLoginTime null
105
+     */
106
+    public void setInLoginTime(Date inLoginTime) {
107
+        this.inLoginTime = inLoginTime;
108
+    }
109
+
110
+    /**
111
+     * null
112
+     * @return out_login_time null
113
+     */
114
+    public Date getOutLoginTime() {
115
+        return outLoginTime;
116
+    }
117
+
118
+    /**
119
+     * null
120
+     * @param outLoginTime null
121
+     */
122
+    public void setOutLoginTime(Date outLoginTime) {
123
+        this.outLoginTime = outLoginTime;
124
+    }
125
+
126
+    /**
127
+     * null
128
+     * @return session_id null
129
+     */
130
+    public String getSessionId() {
131
+        return sessionId;
132
+    }
133
+
134
+    /**
135
+     * null
136
+     * @param sessionId null
137
+     */
138
+    public void setSessionId(String sessionId) {
139
+        this.sessionId = sessionId == null ? null : sessionId.trim();
140
+    }
141
+
142
+    /**
143
+     * null
144
+     * @return login_type null
145
+     */
146
+    public String getLoginType() {
147
+        return loginType;
148
+    }
149
+
150
+    /**
151
+     * null
152
+     * @param loginType null
153
+     */
154
+    public void setLoginType(String loginType) {
155
+        this.loginType = loginType == null ? null : loginType.trim();
156
+    }
157
+}

+ 759 - 0
src/main/java/com/chinaitop/depot/system/model/UserLoginLogExample.java

@@ -0,0 +1,759 @@
1
+package com.chinaitop.depot.system.model;
2
+
3
+import java.util.ArrayList;
4
+import java.util.Date;
5
+import java.util.List;
6
+
7
+public class UserLoginLogExample {
8
+    /**
9
+     * user_login_log
10
+     */
11
+    protected String orderByClause;
12
+
13
+    /**
14
+     * user_login_log
15
+     */
16
+    protected boolean distinct;
17
+
18
+    /**
19
+     * user_login_log
20
+     */
21
+    protected List<Criteria> oredCriteria;
22
+
23
+    public UserLoginLogExample() {
24
+        oredCriteria = new ArrayList<Criteria>();
25
+    }
26
+
27
+    public void setOrderByClause(String orderByClause) {
28
+        this.orderByClause = orderByClause;
29
+    }
30
+
31
+    public String getOrderByClause() {
32
+        return orderByClause;
33
+    }
34
+
35
+    public void setDistinct(boolean distinct) {
36
+        this.distinct = distinct;
37
+    }
38
+
39
+    public boolean isDistinct() {
40
+        return distinct;
41
+    }
42
+
43
+    public List<Criteria> getOredCriteria() {
44
+        return oredCriteria;
45
+    }
46
+
47
+    public void or(Criteria criteria) {
48
+        oredCriteria.add(criteria);
49
+    }
50
+
51
+    public Criteria or() {
52
+        Criteria criteria = createCriteriaInternal();
53
+        oredCriteria.add(criteria);
54
+        return criteria;
55
+    }
56
+
57
+    public Criteria createCriteria() {
58
+        Criteria criteria = createCriteriaInternal();
59
+        if (oredCriteria.size() == 0) {
60
+            oredCriteria.add(criteria);
61
+        }
62
+        return criteria;
63
+    }
64
+
65
+    protected Criteria createCriteriaInternal() {
66
+        Criteria criteria = new Criteria();
67
+        return criteria;
68
+    }
69
+
70
+    public void clear() {
71
+        oredCriteria.clear();
72
+        orderByClause = null;
73
+        distinct = false;
74
+    }
75
+
76
+    /**
77
+     * user_login_log 2024-10-31
78
+     */
79
+    protected abstract static class GeneratedCriteria {
80
+        protected List<Criterion> criteria;
81
+
82
+        protected GeneratedCriteria() {
83
+            super();
84
+            criteria = new ArrayList<Criterion>();
85
+        }
86
+
87
+        public boolean isValid() {
88
+            return criteria.size() > 0;
89
+        }
90
+
91
+        public List<Criterion> getAllCriteria() {
92
+            return criteria;
93
+        }
94
+
95
+        public List<Criterion> getCriteria() {
96
+            return criteria;
97
+        }
98
+
99
+        protected void addCriterion(String condition) {
100
+            if (condition == null) {
101
+                throw new RuntimeException("Value for condition cannot be null");
102
+            }
103
+            criteria.add(new Criterion(condition));
104
+        }
105
+
106
+        protected void addCriterion(String condition, Object value, String property) {
107
+            if (value == null) {
108
+                throw new RuntimeException("Value for " + property + " cannot be null");
109
+            }
110
+            criteria.add(new Criterion(condition, value));
111
+        }
112
+
113
+        protected void addCriterion(String condition, Object value1, Object value2, String property) {
114
+            if (value1 == null || value2 == null) {
115
+                throw new RuntimeException("Between values for " + property + " cannot be null");
116
+            }
117
+            criteria.add(new Criterion(condition, value1, value2));
118
+        }
119
+
120
+        public Criteria andIdIsNull() {
121
+            addCriterion("id is null");
122
+            return (Criteria) this;
123
+        }
124
+
125
+        public Criteria andIdIsNotNull() {
126
+            addCriterion("id is not null");
127
+            return (Criteria) this;
128
+        }
129
+
130
+        public Criteria andIdEqualTo(String value) {
131
+            addCriterion("id =", value, "id");
132
+            return (Criteria) this;
133
+        }
134
+
135
+        public Criteria andIdNotEqualTo(String value) {
136
+            addCriterion("id <>", value, "id");
137
+            return (Criteria) this;
138
+        }
139
+
140
+        public Criteria andIdGreaterThan(String value) {
141
+            addCriterion("id >", value, "id");
142
+            return (Criteria) this;
143
+        }
144
+
145
+        public Criteria andIdGreaterThanOrEqualTo(String value) {
146
+            addCriterion("id >=", value, "id");
147
+            return (Criteria) this;
148
+        }
149
+
150
+        public Criteria andIdLessThan(String value) {
151
+            addCriterion("id <", value, "id");
152
+            return (Criteria) this;
153
+        }
154
+
155
+        public Criteria andIdLessThanOrEqualTo(String value) {
156
+            addCriterion("id <=", value, "id");
157
+            return (Criteria) this;
158
+        }
159
+
160
+        public Criteria andIdLike(String value) {
161
+            addCriterion("id like", value, "id");
162
+            return (Criteria) this;
163
+        }
164
+
165
+        public Criteria andIdNotLike(String value) {
166
+            addCriterion("id not like", value, "id");
167
+            return (Criteria) this;
168
+        }
169
+
170
+        public Criteria andIdIn(List<String> values) {
171
+            addCriterion("id in", values, "id");
172
+            return (Criteria) this;
173
+        }
174
+
175
+        public Criteria andIdNotIn(List<String> values) {
176
+            addCriterion("id not in", values, "id");
177
+            return (Criteria) this;
178
+        }
179
+
180
+        public Criteria andIdBetween(String value1, String value2) {
181
+            addCriterion("id between", value1, value2, "id");
182
+            return (Criteria) this;
183
+        }
184
+
185
+        public Criteria andIdNotBetween(String value1, String value2) {
186
+            addCriterion("id not between", value1, value2, "id");
187
+            return (Criteria) this;
188
+        }
189
+
190
+        public Criteria andUserNameIsNull() {
191
+            addCriterion("user_name is null");
192
+            return (Criteria) this;
193
+        }
194
+
195
+        public Criteria andUserNameIsNotNull() {
196
+            addCriterion("user_name is not null");
197
+            return (Criteria) this;
198
+        }
199
+
200
+        public Criteria andUserNameEqualTo(String value) {
201
+            addCriterion("user_name =", value, "userName");
202
+            return (Criteria) this;
203
+        }
204
+
205
+        public Criteria andUserNameNotEqualTo(String value) {
206
+            addCriterion("user_name <>", value, "userName");
207
+            return (Criteria) this;
208
+        }
209
+
210
+        public Criteria andUserNameGreaterThan(String value) {
211
+            addCriterion("user_name >", value, "userName");
212
+            return (Criteria) this;
213
+        }
214
+
215
+        public Criteria andUserNameGreaterThanOrEqualTo(String value) {
216
+            addCriterion("user_name >=", value, "userName");
217
+            return (Criteria) this;
218
+        }
219
+
220
+        public Criteria andUserNameLessThan(String value) {
221
+            addCriterion("user_name <", value, "userName");
222
+            return (Criteria) this;
223
+        }
224
+
225
+        public Criteria andUserNameLessThanOrEqualTo(String value) {
226
+            addCriterion("user_name <=", value, "userName");
227
+            return (Criteria) this;
228
+        }
229
+
230
+        public Criteria andUserNameLike(String value) {
231
+            addCriterion("user_name like", value, "userName");
232
+            return (Criteria) this;
233
+        }
234
+
235
+        public Criteria andUserNameNotLike(String value) {
236
+            addCriterion("user_name not like", value, "userName");
237
+            return (Criteria) this;
238
+        }
239
+
240
+        public Criteria andUserNameIn(List<String> values) {
241
+            addCriterion("user_name in", values, "userName");
242
+            return (Criteria) this;
243
+        }
244
+
245
+        public Criteria andUserNameNotIn(List<String> values) {
246
+            addCriterion("user_name not in", values, "userName");
247
+            return (Criteria) this;
248
+        }
249
+
250
+        public Criteria andUserNameBetween(String value1, String value2) {
251
+            addCriterion("user_name between", value1, value2, "userName");
252
+            return (Criteria) this;
253
+        }
254
+
255
+        public Criteria andUserNameNotBetween(String value1, String value2) {
256
+            addCriterion("user_name not between", value1, value2, "userName");
257
+            return (Criteria) this;
258
+        }
259
+
260
+        public Criteria andRealNameIsNull() {
261
+            addCriterion("real_name is null");
262
+            return (Criteria) this;
263
+        }
264
+
265
+        public Criteria andRealNameIsNotNull() {
266
+            addCriterion("real_name is not null");
267
+            return (Criteria) this;
268
+        }
269
+
270
+        public Criteria andRealNameEqualTo(String value) {
271
+            addCriterion("real_name =", value, "realName");
272
+            return (Criteria) this;
273
+        }
274
+
275
+        public Criteria andRealNameNotEqualTo(String value) {
276
+            addCriterion("real_name <>", value, "realName");
277
+            return (Criteria) this;
278
+        }
279
+
280
+        public Criteria andRealNameGreaterThan(String value) {
281
+            addCriterion("real_name >", value, "realName");
282
+            return (Criteria) this;
283
+        }
284
+
285
+        public Criteria andRealNameGreaterThanOrEqualTo(String value) {
286
+            addCriterion("real_name >=", value, "realName");
287
+            return (Criteria) this;
288
+        }
289
+
290
+        public Criteria andRealNameLessThan(String value) {
291
+            addCriterion("real_name <", value, "realName");
292
+            return (Criteria) this;
293
+        }
294
+
295
+        public Criteria andRealNameLessThanOrEqualTo(String value) {
296
+            addCriterion("real_name <=", value, "realName");
297
+            return (Criteria) this;
298
+        }
299
+
300
+        public Criteria andRealNameLike(String value) {
301
+            addCriterion("real_name like", value, "realName");
302
+            return (Criteria) this;
303
+        }
304
+
305
+        public Criteria andRealNameNotLike(String value) {
306
+            addCriterion("real_name not like", value, "realName");
307
+            return (Criteria) this;
308
+        }
309
+
310
+        public Criteria andRealNameIn(List<String> values) {
311
+            addCriterion("real_name in", values, "realName");
312
+            return (Criteria) this;
313
+        }
314
+
315
+        public Criteria andRealNameNotIn(List<String> values) {
316
+            addCriterion("real_name not in", values, "realName");
317
+            return (Criteria) this;
318
+        }
319
+
320
+        public Criteria andRealNameBetween(String value1, String value2) {
321
+            addCriterion("real_name between", value1, value2, "realName");
322
+            return (Criteria) this;
323
+        }
324
+
325
+        public Criteria andRealNameNotBetween(String value1, String value2) {
326
+            addCriterion("real_name not between", value1, value2, "realName");
327
+            return (Criteria) this;
328
+        }
329
+
330
+        public Criteria andUserIpIsNull() {
331
+            addCriterion("user_ip is null");
332
+            return (Criteria) this;
333
+        }
334
+
335
+        public Criteria andUserIpIsNotNull() {
336
+            addCriterion("user_ip is not null");
337
+            return (Criteria) this;
338
+        }
339
+
340
+        public Criteria andUserIpEqualTo(String value) {
341
+            addCriterion("user_ip =", value, "userIp");
342
+            return (Criteria) this;
343
+        }
344
+
345
+        public Criteria andUserIpNotEqualTo(String value) {
346
+            addCriterion("user_ip <>", value, "userIp");
347
+            return (Criteria) this;
348
+        }
349
+
350
+        public Criteria andUserIpGreaterThan(String value) {
351
+            addCriterion("user_ip >", value, "userIp");
352
+            return (Criteria) this;
353
+        }
354
+
355
+        public Criteria andUserIpGreaterThanOrEqualTo(String value) {
356
+            addCriterion("user_ip >=", value, "userIp");
357
+            return (Criteria) this;
358
+        }
359
+
360
+        public Criteria andUserIpLessThan(String value) {
361
+            addCriterion("user_ip <", value, "userIp");
362
+            return (Criteria) this;
363
+        }
364
+
365
+        public Criteria andUserIpLessThanOrEqualTo(String value) {
366
+            addCriterion("user_ip <=", value, "userIp");
367
+            return (Criteria) this;
368
+        }
369
+
370
+        public Criteria andUserIpLike(String value) {
371
+            addCriterion("user_ip like", value, "userIp");
372
+            return (Criteria) this;
373
+        }
374
+
375
+        public Criteria andUserIpNotLike(String value) {
376
+            addCriterion("user_ip not like", value, "userIp");
377
+            return (Criteria) this;
378
+        }
379
+
380
+        public Criteria andUserIpIn(List<String> values) {
381
+            addCriterion("user_ip in", values, "userIp");
382
+            return (Criteria) this;
383
+        }
384
+
385
+        public Criteria andUserIpNotIn(List<String> values) {
386
+            addCriterion("user_ip not in", values, "userIp");
387
+            return (Criteria) this;
388
+        }
389
+
390
+        public Criteria andUserIpBetween(String value1, String value2) {
391
+            addCriterion("user_ip between", value1, value2, "userIp");
392
+            return (Criteria) this;
393
+        }
394
+
395
+        public Criteria andUserIpNotBetween(String value1, String value2) {
396
+            addCriterion("user_ip not between", value1, value2, "userIp");
397
+            return (Criteria) this;
398
+        }
399
+
400
+        public Criteria andInLoginTimeIsNull() {
401
+            addCriterion("in_login_time is null");
402
+            return (Criteria) this;
403
+        }
404
+
405
+        public Criteria andInLoginTimeIsNotNull() {
406
+            addCriterion("in_login_time is not null");
407
+            return (Criteria) this;
408
+        }
409
+
410
+        public Criteria andInLoginTimeEqualTo(Date value) {
411
+            addCriterion("in_login_time =", value, "inLoginTime");
412
+            return (Criteria) this;
413
+        }
414
+
415
+        public Criteria andInLoginTimeNotEqualTo(Date value) {
416
+            addCriterion("in_login_time <>", value, "inLoginTime");
417
+            return (Criteria) this;
418
+        }
419
+
420
+        public Criteria andInLoginTimeGreaterThan(Date value) {
421
+            addCriterion("in_login_time >", value, "inLoginTime");
422
+            return (Criteria) this;
423
+        }
424
+
425
+        public Criteria andInLoginTimeGreaterThanOrEqualTo(Date value) {
426
+            addCriterion("in_login_time >=", value, "inLoginTime");
427
+            return (Criteria) this;
428
+        }
429
+
430
+        public Criteria andInLoginTimeLessThan(Date value) {
431
+            addCriterion("in_login_time <", value, "inLoginTime");
432
+            return (Criteria) this;
433
+        }
434
+
435
+        public Criteria andInLoginTimeLessThanOrEqualTo(Date value) {
436
+            addCriterion("in_login_time <=", value, "inLoginTime");
437
+            return (Criteria) this;
438
+        }
439
+
440
+        public Criteria andInLoginTimeIn(List<Date> values) {
441
+            addCriterion("in_login_time in", values, "inLoginTime");
442
+            return (Criteria) this;
443
+        }
444
+
445
+        public Criteria andInLoginTimeNotIn(List<Date> values) {
446
+            addCriterion("in_login_time not in", values, "inLoginTime");
447
+            return (Criteria) this;
448
+        }
449
+
450
+        public Criteria andInLoginTimeBetween(Date value1, Date value2) {
451
+            addCriterion("in_login_time between", value1, value2, "inLoginTime");
452
+            return (Criteria) this;
453
+        }
454
+
455
+        public Criteria andInLoginTimeNotBetween(Date value1, Date value2) {
456
+            addCriterion("in_login_time not between", value1, value2, "inLoginTime");
457
+            return (Criteria) this;
458
+        }
459
+
460
+        public Criteria andOutLoginTimeIsNull() {
461
+            addCriterion("out_login_time is null");
462
+            return (Criteria) this;
463
+        }
464
+
465
+        public Criteria andOutLoginTimeIsNotNull() {
466
+            addCriterion("out_login_time is not null");
467
+            return (Criteria) this;
468
+        }
469
+
470
+        public Criteria andOutLoginTimeEqualTo(Date value) {
471
+            addCriterion("out_login_time =", value, "outLoginTime");
472
+            return (Criteria) this;
473
+        }
474
+
475
+        public Criteria andOutLoginTimeNotEqualTo(Date value) {
476
+            addCriterion("out_login_time <>", value, "outLoginTime");
477
+            return (Criteria) this;
478
+        }
479
+
480
+        public Criteria andOutLoginTimeGreaterThan(Date value) {
481
+            addCriterion("out_login_time >", value, "outLoginTime");
482
+            return (Criteria) this;
483
+        }
484
+
485
+        public Criteria andOutLoginTimeGreaterThanOrEqualTo(Date value) {
486
+            addCriterion("out_login_time >=", value, "outLoginTime");
487
+            return (Criteria) this;
488
+        }
489
+
490
+        public Criteria andOutLoginTimeLessThan(Date value) {
491
+            addCriterion("out_login_time <", value, "outLoginTime");
492
+            return (Criteria) this;
493
+        }
494
+
495
+        public Criteria andOutLoginTimeLessThanOrEqualTo(Date value) {
496
+            addCriterion("out_login_time <=", value, "outLoginTime");
497
+            return (Criteria) this;
498
+        }
499
+
500
+        public Criteria andOutLoginTimeIn(List<Date> values) {
501
+            addCriterion("out_login_time in", values, "outLoginTime");
502
+            return (Criteria) this;
503
+        }
504
+
505
+        public Criteria andOutLoginTimeNotIn(List<Date> values) {
506
+            addCriterion("out_login_time not in", values, "outLoginTime");
507
+            return (Criteria) this;
508
+        }
509
+
510
+        public Criteria andOutLoginTimeBetween(Date value1, Date value2) {
511
+            addCriterion("out_login_time between", value1, value2, "outLoginTime");
512
+            return (Criteria) this;
513
+        }
514
+
515
+        public Criteria andOutLoginTimeNotBetween(Date value1, Date value2) {
516
+            addCriterion("out_login_time not between", value1, value2, "outLoginTime");
517
+            return (Criteria) this;
518
+        }
519
+
520
+        public Criteria andSessionIdIsNull() {
521
+            addCriterion("session_id is null");
522
+            return (Criteria) this;
523
+        }
524
+
525
+        public Criteria andSessionIdIsNotNull() {
526
+            addCriterion("session_id is not null");
527
+            return (Criteria) this;
528
+        }
529
+
530
+        public Criteria andSessionIdEqualTo(String value) {
531
+            addCriterion("session_id =", value, "sessionId");
532
+            return (Criteria) this;
533
+        }
534
+
535
+        public Criteria andSessionIdNotEqualTo(String value) {
536
+            addCriterion("session_id <>", value, "sessionId");
537
+            return (Criteria) this;
538
+        }
539
+
540
+        public Criteria andSessionIdGreaterThan(String value) {
541
+            addCriterion("session_id >", value, "sessionId");
542
+            return (Criteria) this;
543
+        }
544
+
545
+        public Criteria andSessionIdGreaterThanOrEqualTo(String value) {
546
+            addCriterion("session_id >=", value, "sessionId");
547
+            return (Criteria) this;
548
+        }
549
+
550
+        public Criteria andSessionIdLessThan(String value) {
551
+            addCriterion("session_id <", value, "sessionId");
552
+            return (Criteria) this;
553
+        }
554
+
555
+        public Criteria andSessionIdLessThanOrEqualTo(String value) {
556
+            addCriterion("session_id <=", value, "sessionId");
557
+            return (Criteria) this;
558
+        }
559
+
560
+        public Criteria andSessionIdLike(String value) {
561
+            addCriterion("session_id like", value, "sessionId");
562
+            return (Criteria) this;
563
+        }
564
+
565
+        public Criteria andSessionIdNotLike(String value) {
566
+            addCriterion("session_id not like", value, "sessionId");
567
+            return (Criteria) this;
568
+        }
569
+
570
+        public Criteria andSessionIdIn(List<String> values) {
571
+            addCriterion("session_id in", values, "sessionId");
572
+            return (Criteria) this;
573
+        }
574
+
575
+        public Criteria andSessionIdNotIn(List<String> values) {
576
+            addCriterion("session_id not in", values, "sessionId");
577
+            return (Criteria) this;
578
+        }
579
+
580
+        public Criteria andSessionIdBetween(String value1, String value2) {
581
+            addCriterion("session_id between", value1, value2, "sessionId");
582
+            return (Criteria) this;
583
+        }
584
+
585
+        public Criteria andSessionIdNotBetween(String value1, String value2) {
586
+            addCriterion("session_id not between", value1, value2, "sessionId");
587
+            return (Criteria) this;
588
+        }
589
+
590
+        public Criteria andLoginTypeIsNull() {
591
+            addCriterion("login_type is null");
592
+            return (Criteria) this;
593
+        }
594
+
595
+        public Criteria andLoginTypeIsNotNull() {
596
+            addCriterion("login_type is not null");
597
+            return (Criteria) this;
598
+        }
599
+
600
+        public Criteria andLoginTypeEqualTo(String value) {
601
+            addCriterion("login_type =", value, "loginType");
602
+            return (Criteria) this;
603
+        }
604
+
605
+        public Criteria andLoginTypeNotEqualTo(String value) {
606
+            addCriterion("login_type <>", value, "loginType");
607
+            return (Criteria) this;
608
+        }
609
+
610
+        public Criteria andLoginTypeGreaterThan(String value) {
611
+            addCriterion("login_type >", value, "loginType");
612
+            return (Criteria) this;
613
+        }
614
+
615
+        public Criteria andLoginTypeGreaterThanOrEqualTo(String value) {
616
+            addCriterion("login_type >=", value, "loginType");
617
+            return (Criteria) this;
618
+        }
619
+
620
+        public Criteria andLoginTypeLessThan(String value) {
621
+            addCriterion("login_type <", value, "loginType");
622
+            return (Criteria) this;
623
+        }
624
+
625
+        public Criteria andLoginTypeLessThanOrEqualTo(String value) {
626
+            addCriterion("login_type <=", value, "loginType");
627
+            return (Criteria) this;
628
+        }
629
+
630
+        public Criteria andLoginTypeLike(String value) {
631
+            addCriterion("login_type like", value, "loginType");
632
+            return (Criteria) this;
633
+        }
634
+
635
+        public Criteria andLoginTypeNotLike(String value) {
636
+            addCriterion("login_type not like", value, "loginType");
637
+            return (Criteria) this;
638
+        }
639
+
640
+        public Criteria andLoginTypeIn(List<String> values) {
641
+            addCriterion("login_type in", values, "loginType");
642
+            return (Criteria) this;
643
+        }
644
+
645
+        public Criteria andLoginTypeNotIn(List<String> values) {
646
+            addCriterion("login_type not in", values, "loginType");
647
+            return (Criteria) this;
648
+        }
649
+
650
+        public Criteria andLoginTypeBetween(String value1, String value2) {
651
+            addCriterion("login_type between", value1, value2, "loginType");
652
+            return (Criteria) this;
653
+        }
654
+
655
+        public Criteria andLoginTypeNotBetween(String value1, String value2) {
656
+            addCriterion("login_type not between", value1, value2, "loginType");
657
+            return (Criteria) this;
658
+        }
659
+    }
660
+
661
+    /**
662
+     * user_login_log
663
+     */
664
+    public static class Criteria extends GeneratedCriteria {
665
+
666
+        protected Criteria() {
667
+            super();
668
+        }
669
+    }
670
+
671
+    /**
672
+     * user_login_log 2024-10-31
673
+     */
674
+    public static class Criterion {
675
+        private String condition;
676
+
677
+        private Object value;
678
+
679
+        private Object secondValue;
680
+
681
+        private boolean noValue;
682
+
683
+        private boolean singleValue;
684
+
685
+        private boolean betweenValue;
686
+
687
+        private boolean listValue;
688
+
689
+        private String typeHandler;
690
+
691
+        public String getCondition() {
692
+            return condition;
693
+        }
694
+
695
+        public Object getValue() {
696
+            return value;
697
+        }
698
+
699
+        public Object getSecondValue() {
700
+            return secondValue;
701
+        }
702
+
703
+        public boolean isNoValue() {
704
+            return noValue;
705
+        }
706
+
707
+        public boolean isSingleValue() {
708
+            return singleValue;
709
+        }
710
+
711
+        public boolean isBetweenValue() {
712
+            return betweenValue;
713
+        }
714
+
715
+        public boolean isListValue() {
716
+            return listValue;
717
+        }
718
+
719
+        public String getTypeHandler() {
720
+            return typeHandler;
721
+        }
722
+
723
+        protected Criterion(String condition) {
724
+            super();
725
+            this.condition = condition;
726
+            this.typeHandler = null;
727
+            this.noValue = true;
728
+        }
729
+
730
+        protected Criterion(String condition, Object value, String typeHandler) {
731
+            super();
732
+            this.condition = condition;
733
+            this.value = value;
734
+            this.typeHandler = typeHandler;
735
+            if (value instanceof List<?>) {
736
+                this.listValue = true;
737
+            } else {
738
+                this.singleValue = true;
739
+            }
740
+        }
741
+
742
+        protected Criterion(String condition, Object value) {
743
+            this(condition, value, null);
744
+        }
745
+
746
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
747
+            super();
748
+            this.condition = condition;
749
+            this.value = value;
750
+            this.secondValue = secondValue;
751
+            this.typeHandler = typeHandler;
752
+            this.betweenValue = true;
753
+        }
754
+
755
+        protected Criterion(String condition, Object value, Object secondValue) {
756
+            this(condition, value, secondValue, null);
757
+        }
758
+    }
759
+}

+ 36 - 0
src/main/java/com/chinaitop/depot/system/model/UserLoginLogVO.java

@@ -0,0 +1,36 @@
1
+package com.chinaitop.depot.system.model;
2
+
3
+import com.alibaba.excel.annotation.ExcelProperty;
4
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
5
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
6
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
7
+import lombok.Data;
8
+
9
+import java.util.Date;
10
+
11
+@Data
12
+@ContentRowHeight(20) // 文本行高度
13
+@HeadRowHeight(20) // 标题高度
14
+@ColumnWidth(20) // 默认列宽度
15
+public class UserLoginLogVO {
16
+
17
+    // 访问用户账号
18
+    @ExcelProperty(value = "访问用户账号")
19
+    private String userName;
20
+
21
+    // 登录用户名称
22
+    @ExcelProperty(value = "登录用户名称")
23
+    private String realName;
24
+
25
+    // 用户设备IP
26
+    @ExcelProperty(value = "用户设备IP")
27
+    private String userIp;
28
+
29
+    // 登陆时间
30
+    @ExcelProperty(value = "登陆时间")
31
+    private Date inLoginTime;
32
+
33
+    // 注销时间
34
+    @ExcelProperty(value = "注销时间")
35
+    private Date outLoginTime;
36
+}

+ 28 - 0
src/main/java/com/chinaitop/depot/system/param/UserLoginLogPageParam.java

@@ -0,0 +1,28 @@
1
+package com.chinaitop.depot.system.param;
2
+
3
+import com.chinaitop.depot.common.PageParam;
4
+import com.fasterxml.jackson.annotation.JsonFormat;
5
+import lombok.Getter;
6
+import lombok.Setter;
7
+import org.springframework.format.annotation.DateTimeFormat;
8
+
9
+import java.io.Serializable;
10
+import java.util.Date;
11
+
12
+/**
13
+ * @author qingsong.han
14
+ * @description:
15
+ * @create 2024-11-01 10:43
16
+ */
17
+@Getter
18
+@Setter
19
+public class UserLoginLogPageParam extends PageParam implements Serializable {
20
+    // 登陆时间
21
+    private String inLoginTime;
22
+
23
+    // 注销时间
24
+    private String outLoginTime;
25
+
26
+    // 登录用户名称
27
+    private String realName;
28
+}

+ 31 - 0
src/main/java/com/chinaitop/depot/system/service/UserLoginLogService.java

@@ -0,0 +1,31 @@
1
+package com.chinaitop.depot.system.service;
2
+
3
+import com.chinaitop.depot.system.model.UserInfo;
4
+import com.chinaitop.depot.system.model.UserLoginLog;
5
+import com.chinaitop.depot.system.param.UserLoginLogPageParam;
6
+
7
+import javax.servlet.http.HttpServletRequest;
8
+import javax.servlet.http.HttpServletResponse;
9
+import java.util.List;
10
+
11
+/**
12
+ * @author qingsong.han
13
+ * @description:
14
+ * @create 2024-10-31 15:37
15
+ */
16
+public interface UserLoginLogService {
17
+
18
+    // 保存登录日志
19
+    void saveData(HttpServletRequest request, UserInfo userInfo, String loginType);
20
+
21
+    // 更新登录日志
22
+    void updateData(HttpServletRequest request);
23
+
24
+    // 查询过期登录人信息并更新退出时间
25
+    void selectOutLoginIsNull();
26
+
27
+    // 查询列表
28
+    List<UserLoginLog> getPageList(UserLoginLogPageParam param);
29
+
30
+    void export(String fileName, UserLoginLogPageParam param, HttpServletRequest request, HttpServletResponse response);
31
+}

+ 185 - 0
src/main/java/com/chinaitop/depot/system/service/impl/UserLoginLogServiceImpl.java

@@ -0,0 +1,185 @@
1
+package com.chinaitop.depot.system.service.impl;
2
+
3
+import com.alibaba.excel.EasyExcel;
4
+import com.alibaba.excel.support.ExcelTypeEnum;
5
+import com.chinaitop.depot.common.CommonObject;
6
+import com.chinaitop.depot.system.model.UserInfo;
7
+import com.chinaitop.depot.system.mapper.UserLoginLogMapper;
8
+import com.chinaitop.depot.system.model.UserLoginLog;
9
+import com.chinaitop.depot.system.model.UserLoginLogExample;
10
+import com.chinaitop.depot.system.model.UserLoginLogVO;
11
+import com.chinaitop.depot.system.param.UserLoginLogPageParam;
12
+import com.chinaitop.depot.system.service.UserLoginLogService;
13
+import com.chinaitop.depot.utils.DateUtils;
14
+import com.chinaitop.depot.utils.IPUtil;
15
+import com.chinaitop.depot.utils.RedisUtil;
16
+import lombok.extern.slf4j.Slf4j;
17
+import org.springframework.beans.BeanUtils;
18
+import org.springframework.stereotype.Service;
19
+import org.springframework.transaction.annotation.Transactional;
20
+import org.springframework.util.ObjectUtils;
21
+import org.springframework.util.StringUtils;
22
+
23
+import javax.annotation.Resource;
24
+import javax.servlet.http.HttpServletRequest;
25
+import javax.servlet.http.HttpServletResponse;
26
+import java.io.IOException;
27
+import java.net.URLEncoder;
28
+import java.time.LocalDateTime;
29
+import java.util.ArrayList;
30
+import java.util.Date;
31
+import java.util.List;
32
+import java.util.UUID;
33
+
34
+/**
35
+ * @author qingsong.han
36
+ * @description:
37
+ * @create 2024-10-31 15:38
38
+ */
39
+@Slf4j
40
+@Service
41
+public class UserLoginLogServiceImpl implements UserLoginLogService {
42
+    @Resource
43
+    private RedisUtil redisUtil;
44
+    @Resource
45
+    private IPUtil ipUtil;
46
+    @Resource
47
+    private UserLoginLogMapper userLoginLogMapper;
48
+
49
+    @Override
50
+    @Transactional(rollbackFor = Exception.class)
51
+    public void saveData(HttpServletRequest request, UserInfo userInfo, String loginType) {
52
+        // 查询是否登录成功
53
+        if (!ObjectUtils.isEmpty(redisUtil.get(userInfo.getUsername() + CommonObject.sessionId))) {
54
+            UserLoginLog log = new UserLoginLog();
55
+            log.setId(UUID.randomUUID().toString());
56
+            log.setUserName(userInfo.getUsername());
57
+            log.setRealName(userInfo.getRealName());
58
+            log.setUserIp(ipUtil.getIpAddr(request));
59
+            log.setInLoginTime(new Date());
60
+            log.setSessionId(request.getSession().getId());
61
+            log.setLoginType(loginType);
62
+            userLoginLogMapper.insertSelective(log);
63
+        }
64
+    }
65
+
66
+    @Override
67
+    @Transactional(rollbackFor = Exception.class)
68
+    public void updateData(HttpServletRequest request) {
69
+        String sessionId = request.getSession().getId();
70
+        if (StringUtils.hasText(sessionId)) { // 不为空
71
+            // 更新
72
+            this.updateDataTime(sessionId);
73
+        }
74
+    }
75
+
76
+    private void updateDataTime(String sessionId) {
77
+        // 更新
78
+        UserLoginLogExample example = new UserLoginLogExample();
79
+        UserLoginLogExample.Criteria criteria = example.createCriteria();
80
+        criteria.andSessionIdEqualTo(sessionId);
81
+        // 更新退出登录时间
82
+        UserLoginLog loginLog = new UserLoginLog();
83
+        loginLog.setOutLoginTime(new Date());
84
+        userLoginLogMapper.updateByExampleSelective(loginLog, example);
85
+    }
86
+
87
+    @Override
88
+    public void selectOutLoginIsNull() {
89
+        // 查询未正常操作退出登录的(例如:直接关闭浏览器登录超时...)
90
+        UserLoginLogExample example = new UserLoginLogExample();
91
+        UserLoginLogExample.Criteria criteria = example.createCriteria();
92
+        criteria.andOutLoginTimeIsNull();
93
+        List<UserLoginLog> userLoginLogs = userLoginLogMapper.selectByExample(example);
94
+        userLoginLogs.forEach(loginLog -> {
95
+            // key不存在,已退出登录或已过期
96
+            if (!redisUtil.hasKey(loginLog.getUserName() + CommonObject.sessionId)) {
97
+                // 更新
98
+                this.updateDataTime(loginLog.getSessionId());
99
+            } else {
100
+                // 获取session id
101
+                String redisSessionId = redisUtil.get(loginLog.getUserName() + CommonObject.sessionId).toString();
102
+                // 未更新session id
103
+                String sessionId = loginLog.getSessionId();
104
+                // 非正常退出后再次登录session id 不同,更新上次退出登录时间
105
+                if (!sessionId.equals(redisSessionId)) {
106
+                    this.updateDataTime(sessionId);
107
+                }
108
+            }
109
+        });
110
+    }
111
+
112
+    @Override
113
+    public List<UserLoginLog> getPageList(UserLoginLogPageParam param) {
114
+        UserLoginLogExample example = new UserLoginLogExample();
115
+        UserLoginLogExample.Criteria criteria = example.createCriteria();
116
+        // 登录时间
117
+        Date inLoginTimeStart = null;
118
+        Date inLoginTimeEnd = null;
119
+        if (StringUtils.hasText(param.getInLoginTime())) {
120
+            inLoginTimeStart = DateUtils.stringToData(String.format("%s%s", param.getInLoginTime(), DateUtils.startTime));
121
+            inLoginTimeEnd = DateUtils.stringToData(String.format("%s%s", param.getInLoginTime(), DateUtils.endTime));
122
+        }
123
+        // 注销时间
124
+        Date outLoginTimeStart = null;
125
+        Date outLoginTimeEnd = null;
126
+        if (StringUtils.hasText(param.getOutLoginTime())) {
127
+            outLoginTimeStart = DateUtils.stringToData(String.format("%s%s", param.getOutLoginTime(), DateUtils.startTime));
128
+            outLoginTimeEnd = DateUtils.stringToData(String.format("%s%s", param.getOutLoginTime(), DateUtils.endTime));
129
+        }
130
+        if (StringUtils.hasText(param.getInLoginTime()) && StringUtils.hasText(param.getOutLoginTime())) {
131
+            criteria.andInLoginTimeBetween(inLoginTimeStart, inLoginTimeEnd);
132
+            criteria.andOutLoginTimeBetween(outLoginTimeStart, outLoginTimeEnd);
133
+        } else {
134
+            if (StringUtils.hasText(param.getInLoginTime())) {
135
+                criteria.andInLoginTimeBetween(inLoginTimeStart, inLoginTimeEnd);
136
+            }
137
+            if (StringUtils.hasText(param.getOutLoginTime())) {
138
+                criteria.andOutLoginTimeBetween(outLoginTimeStart, outLoginTimeEnd);
139
+            }
140
+        }
141
+        if (StringUtils.hasText(param.getRealName())) {
142
+            criteria.andRealNameLike(param.getRealName());
143
+        }
144
+
145
+        return userLoginLogMapper.selectByExample(example);
146
+    }
147
+
148
+    @Override
149
+    public void export(String fileName, UserLoginLogPageParam param, HttpServletRequest request, HttpServletResponse response) {
150
+        try {
151
+            if (!StringUtils.hasText(fileName)) {
152
+                fileName = LocalDateTime.now().toString();
153
+            }
154
+
155
+            // 设置响应信息,让浏览器下载文件
156
+            fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
157
+            response.setContentType("application/vnd.ms-excel");
158
+            response.setCharacterEncoding("utf-8");
159
+
160
+            response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
161
+
162
+            EasyExcel.write(response.getOutputStream()) // 或, GrainTempExcel.class
163
+                    .head(UserLoginLogVO.class) // write 中, GrainTempExcel.class 二选一
164
+                    .excelType(ExcelTypeEnum.XLSX)
165
+                    .sheet("用户登录日志")
166
+                    .doWrite(this.getData(param));
167
+
168
+        } catch (IOException e) {
169
+            log.error("摄像头管理导出异常:{}", e);
170
+            throw new RuntimeException(e);
171
+        }
172
+    }
173
+
174
+    private List<UserLoginLogVO> getData(UserLoginLogPageParam param) {
175
+        List<UserLoginLog> pageList = this.getPageList(param);
176
+        List<UserLoginLogVO> list = new ArrayList<>();
177
+        pageList.forEach(userLoginLog -> {
178
+            UserLoginLogVO logVO = new UserLoginLogVO();
179
+            BeanUtils.copyProperties(userLoginLog, logVO);
180
+            list.add(logVO);
181
+        });
182
+        return list;
183
+    }
184
+
185
+}

+ 27 - 0
src/main/java/com/chinaitop/depot/tasks/TaskRunning.java

@@ -0,0 +1,27 @@
1
+package com.chinaitop.depot.tasks;
2
+
3
+import com.chinaitop.depot.system.service.UserLoginLogService;
4
+import org.springframework.scheduling.annotation.Scheduled;
5
+import org.springframework.stereotype.Component;
6
+
7
+import javax.annotation.Resource;
8
+
9
+/**
10
+ * @author qingsong.han
11
+ * @description: 静态定时任务
12
+ * @create 2024-11-01 9:42
13
+ */
14
+@Component
15
+public class TaskRunning {
16
+    @Resource
17
+    private UserLoginLogService userLoginLogService;
18
+
19
+    /**
20
+     * 登录过期时间更新定时任务
21
+     */
22
+    @Scheduled(cron = "0 */1 * * * ?") //  每天10分钟执行
23
+    public void outLoginLogRun() {
24
+        userLoginLogService.selectOutLoginIsNull();
25
+    }
26
+
27
+}

+ 71 - 0
src/main/java/com/chinaitop/depot/utils/DateUtils.java

@@ -0,0 +1,71 @@
1
+package com.chinaitop.depot.utils;
2
+
3
+import java.text.SimpleDateFormat;
4
+import java.util.Date;
5
+
6
+public class DateUtils {
7
+
8
+    public static String startTime = " 00:00:00";
9
+    public static String endTime = " 23:59:59";
10
+    //字符串转date
11
+    public static Date stringToData(String str) {
12
+        try {
13
+            return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(str);
14
+        } catch (Exception e) {
15
+            e.printStackTrace();
16
+        }
17
+        return null;
18
+    }
19
+
20
+    //获取时间
21
+    public static Date getDate() {
22
+        return new Date();
23
+    }
24
+
25
+    //date转string
26
+    public static String dateToString(Date time) {
27
+        String dateString = null;
28
+        try {
29
+            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
30
+            dateString = formatter.format(time);
31
+            return dateString;
32
+        } catch (Exception e) {
33
+            e.printStackTrace();
34
+        }
35
+        return null;
36
+    }
37
+
38
+    // 获取日期格式化
39
+    public static String formatDate(Date date) {
40
+        SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd");
41
+        return dateTime.format(date);
42
+    }
43
+
44
+    // 获取日期格式化
45
+    public static String getCurrentDate() {
46
+        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
47
+        return df.format(new Date());
48
+    }
49
+
50
+    // 获取日期格式化
51
+    public static String getNYR() {
52
+        SimpleDateFormat dateTime = new SimpleDateFormat("yyyyMMdd");
53
+        return dateTime.format(new Date());
54
+    }
55
+
56
+    // 获取日期格式化
57
+    public static String getYMD(Date param) {
58
+        SimpleDateFormat dateTime = new SimpleDateFormat("yyyyMMdd");
59
+        return dateTime.format(param);
60
+    }
61
+
62
+    //字符串转date
63
+    public static Date stringToData(String str,String format) {
64
+        try {
65
+            return new SimpleDateFormat(format).parse(str);
66
+        } catch (Exception e) {
67
+            e.printStackTrace();
68
+        }
69
+        return null;
70
+    }
71
+}

+ 37 - 0
src/main/java/com/chinaitop/depot/utils/IPUtil.java

@@ -0,0 +1,37 @@
1
+package com.chinaitop.depot.utils;
2
+
3
+import org.springframework.stereotype.Component;
4
+
5
+import javax.servlet.http.HttpServletRequest;
6
+
7
+/**
8
+ * @author qingsong.han
9
+ * @description:
10
+ * @create 2024-10-31 16:31
11
+ */
12
+@Component
13
+@SuppressWarnings("all")
14
+public class IPUtil {
15
+
16
+    /**
17
+     * 获取IP地址
18
+     *
19
+     * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
20
+     * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
21
+     */
22
+    public String getIpAddr(HttpServletRequest request) {
23
+
24
+        String ip = request.getHeader("x-forwarded-for");
25
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
26
+            ip = request.getHeader("Proxy-Client-IP");
27
+        }
28
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
29
+            ip = request.getHeader("WL-Proxy-Client-IP");
30
+        }
31
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
32
+            ip = request.getRemoteAddr();
33
+        }
34
+        return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip;
35
+    }
36
+
37
+}