Commit 8e7141a733d9ebbfa12289dce6791b63faa9ec5d
1 parent
48a6f577
登录日志记录展示优化
Signed-off-by: TanYibin <5491541@qq.com>
Showing
10 changed files
with
33 additions
and
34 deletions
huaheng-wms-core/src/main/java/org/jeecg/config/init/CodeGenerateDbConfig.java
... | ... | @@ -12,7 +12,7 @@ import org.springframework.context.annotation.Configuration; |
12 | 12 | * @Description: 代码生成器,自定义DB配置 |
13 | 13 | * 【加了此类,则online模式DB连接,使用平台的配置,jeecg_database.properties配置无效; |
14 | 14 | * 但是使用GUI模式代码生成,还是走jeecg_database.properties配置】 |
15 | - * 提醒: 达梦数据库需要修改下面的参数${spring.datasource.dynamic.datasource.master.url:}配置 | |
15 | + * 提醒:达梦数据库需要修改下面的参数 ${spring.datasource.dynamic.datasource.master.url} 配置 | |
16 | 16 | * @author: scott |
17 | 17 | * @date: 2021年02月18日 16:30 |
18 | 18 | */ |
... | ... | @@ -38,11 +38,11 @@ public class CodeGenerateDbConfig { |
38 | 38 | password = ConfigTools.decrypt(publicKey, password); |
39 | 39 | } catch (Exception e) { |
40 | 40 | e.printStackTrace(); |
41 | - log.error(" 代码生成器数据库连接,数据库密码解密失败!"); | |
41 | + log.error("代码生成器数据库连接,数据库密码解密失败!"); | |
42 | 42 | } |
43 | 43 | } |
44 | 44 | CodegenDatasourceConfig.initDbConfig(driverClassName, url, username, password); |
45 | - log.info(" 代码生成器数据库连接,使用application.yml的DB配置 ###################"); | |
45 | + log.info("###代码生成器数据库连接,使用application.yml的DB配置 ###"); | |
46 | 46 | } |
47 | 47 | return null; |
48 | 48 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/system/controller/LoginController.java
... | ... | @@ -125,7 +125,7 @@ public class LoginController { |
125 | 125 | LoginUser loginUser = new LoginUser(); |
126 | 126 | BeanUtils.copyProperties(sysUser, loginUser); |
127 | 127 | loginUser.setId(sysUser.getId() + ""); |
128 | - baseCommonService.addLog("用户名: " + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null, loginUser); | |
128 | + baseCommonService.addLog("用户名:" + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null, loginUser); | |
129 | 129 | // update-end--Author:wangshuai Date:20200714 for:登录日志没有记录人员 |
130 | 130 | return result; |
131 | 131 | } |
... | ... | @@ -172,9 +172,9 @@ public class LoginController { |
172 | 172 | LoginUser sysUser = sysBaseAPI.getUserByName(username); |
173 | 173 | if (sysUser != null) { |
174 | 174 | // update-begin--Author:wangshuai Date:20200714 for:登出日志没有记录人员 |
175 | - baseCommonService.addLog("用户名: " + sysUser.getRealname() + ",退出成功!", CommonConstant.LOG_TYPE_1, null, sysUser); | |
175 | + baseCommonService.addLog("用户名:" + sysUser.getRealname() + ",退出成功!", CommonConstant.LOG_TYPE_1, null, sysUser); | |
176 | 176 | // update-end--Author:wangshuai Date:20200714 for:登出日志没有记录人员 |
177 | - log.info(" 用户名: " + sysUser.getRealname() + ",退出成功! "); | |
177 | + log.info("用户名:" + sysUser.getRealname() + ",退出成功!"); | |
178 | 178 | // 清空用户登录Token缓存 |
179 | 179 | redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token); |
180 | 180 | // 清空用户登录Shiro权限缓存 |
... | ... | @@ -378,7 +378,7 @@ public class LoginController { |
378 | 378 | // 用户信息 |
379 | 379 | userInfo(sysUser, result, warehouseCode); |
380 | 380 | // 添加日志 |
381 | - baseCommonService.addLog("用户名: " + sysUser.getUsername() + ",登录成功!", CommonConstant.LOG_TYPE_1, null); | |
381 | + baseCommonService.addLog("用户名:" + sysUser.getUsername() + ",登录成功!", CommonConstant.LOG_TYPE_1, null); | |
382 | 382 | |
383 | 383 | return result; |
384 | 384 | } |
... | ... | @@ -436,9 +436,10 @@ public class LoginController { |
436 | 436 | LoginUser loginUser = sysBaseAPI.getUserByName(JwtUtil.getUsername(token)); |
437 | 437 | if (loginUser != null) { |
438 | 438 | if (oConvertUtils.isNotEmpty(username) && loginUser.getUsername().contains(username)) { |
439 | - log.info(" 强制 " + sysUser.getRealname() + "退出成功! "); | |
439 | + log.info("强制 " + sysUser.getRealname() + " 退出成功! "); | |
440 | 440 | // 清空用户登录Token缓存 |
441 | 441 | redisUtil.del(token); |
442 | + // 清空用户登录Token缓存 | |
442 | 443 | redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token); |
443 | 444 | // 清空用户登录Shiro权限缓存 |
444 | 445 | redisUtil.del(CommonConstant.PREFIX_USER_SHIRO_CACHE + sysUser.getId()); |
... | ... | @@ -569,7 +570,7 @@ public class LoginController { |
569 | 570 | result.setResult(obj); |
570 | 571 | result.setSuccess(true); |
571 | 572 | result.setCode(200); |
572 | - baseCommonService.addLog("用户名: " + username + ",登录成功[移动端]!", CommonConstant.LOG_TYPE_1, null); | |
573 | + baseCommonService.addLog("用户名:" + username + ",登录成功[移动端]!", CommonConstant.LOG_TYPE_1, null); | |
573 | 574 | return result; |
574 | 575 | } |
575 | 576 | |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/system/controller/SysUserController.java
... | ... | @@ -217,7 +217,7 @@ public class SysUserController { |
217 | 217 | Result<SysUser> result = new Result<SysUser>(); |
218 | 218 | try { |
219 | 219 | SysUser sysUser = sysUserService.getById(jsonObject.getString("id")); |
220 | - baseCommonService.addLog("编辑用户,id: " + jsonObject.getString("id"), CommonConstant.LOG_TYPE_2, 2); | |
220 | + baseCommonService.addLog("编辑用户,id:" + jsonObject.getString("id"), CommonConstant.LOG_TYPE_2, 2); | |
221 | 221 | if (sysUser == null) { |
222 | 222 | result.error500("未找到对应实体"); |
223 | 223 | } else { |
... | ... | @@ -249,7 +249,7 @@ public class SysUserController { |
249 | 249 | // @RequiresRoles({"admin"}) |
250 | 250 | @RequestMapping(value = "/delete", method = RequestMethod.DELETE) |
251 | 251 | public Result<?> delete(@RequestParam(name = "id", required = true) String id) { |
252 | - baseCommonService.addLog("删除用户,id: " + id, CommonConstant.LOG_TYPE_2, 3); | |
252 | + baseCommonService.addLog("删除用户,id:" + id, CommonConstant.LOG_TYPE_2, 3); | |
253 | 253 | this.sysUserService.deleteUser(id); |
254 | 254 | return Result.ok("删除用户成功"); |
255 | 255 | } |
... | ... | @@ -260,7 +260,7 @@ public class SysUserController { |
260 | 260 | // @RequiresRoles({"admin"}) |
261 | 261 | @RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE) |
262 | 262 | public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
263 | - baseCommonService.addLog("批量删除用户, ids: " + ids, CommonConstant.LOG_TYPE_2, 3); | |
263 | + baseCommonService.addLog("批量删除用户,ids:" + ids, CommonConstant.LOG_TYPE_2, 3); | |
264 | 264 | this.sysUserService.deleteBatchUsers(ids); |
265 | 265 | return Result.ok("批量删除用户成功"); |
266 | 266 | } |
... | ... | @@ -1228,7 +1228,7 @@ public class SysUserController { |
1228 | 1228 | try { |
1229 | 1229 | String username = JwtUtil.getUserNameByToken(request); |
1230 | 1230 | SysUser sysUser = sysUserService.getUserByName(username); |
1231 | - baseCommonService.addLog("移动端编辑用户,id: " + jsonObject.getString("id"), CommonConstant.LOG_TYPE_2, 2); | |
1231 | + baseCommonService.addLog("移动端编辑用户,id:" + jsonObject.getString("id"), CommonConstant.LOG_TYPE_2, 2); | |
1232 | 1232 | String realname = jsonObject.getString("realname"); |
1233 | 1233 | String avatar = jsonObject.getString("avatar"); |
1234 | 1234 | String sex = jsonObject.getString("sex"); |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/system/controller/SysUserOnlineController.java
... | ... | @@ -120,7 +120,6 @@ public class SysUserOnlineController { |
120 | 120 | return Result.error("退出登录失败!"); |
121 | 121 | } |
122 | 122 | Collection<String> keys = redisTemplate.keys(CommonConstant.PREFIX_USER_TOKEN + "*"); |
123 | - List<SysUserOnlineVO> onlineList = new ArrayList<SysUserOnlineVO>(); | |
124 | 123 | for (String key : keys) { |
125 | 124 | if (key.equals(online.getToken())) { |
126 | 125 | String tokenValue = (String)redisUtil.get(online.getToken()); |
... | ... | @@ -128,20 +127,17 @@ public class SysUserOnlineController { |
128 | 127 | LoginUser sysUser = sysBaseAPI.getUserByName(username); |
129 | 128 | if (sysUser != null) { |
130 | 129 | // update-begin--Author:wangshuai Date:20200714 for:登出日志没有记录人员 |
131 | - baseCommonService.addLog("用户名: " + sysUser.getRealname() + ",退出成功!", CommonConstant.LOG_TYPE_1, null, sysUser); | |
130 | + baseCommonService.addLog("用户名:" + sysUser.getRealname() + ",退出成功!", CommonConstant.LOG_TYPE_1, null, sysUser); | |
132 | 131 | // update-end--Author:wangshuai Date:20200714 for:登出日志没有记录人员 |
133 | - log.info(" 用户名: " + sysUser.getRealname() + ",退出成功! "); | |
134 | - | |
135 | - // 以下两个清空测试无效 保留在这吧 | |
136 | - // 清空用户登录Token缓存/用户登录Shiro权限缓存 | |
132 | + log.info("用户 " + sysUser.getRealname() + ",退出成功!"); | |
133 | + // 清空用户登录Token缓存 | |
137 | 134 | redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + tokenValue); |
135 | + // 用户登录Shiro权限缓存 | |
138 | 136 | redisUtil.del(CommonConstant.PREFIX_USER_SHIRO_CACHE + sysUser.getId()); |
139 | - | |
140 | - // 真*清空Token | |
141 | - redisUtil.del(key); | |
142 | - | |
143 | 137 | // 清空用户的缓存信息 |
144 | 138 | redisUtil.del(String.format("%s::%s", CacheConstant.SYS_USERS_CACHE, sysUser.getUsername())); |
139 | + // 真*清空Token | |
140 | + redisUtil.del(key); | |
145 | 141 | // 调用shiro的logout |
146 | 142 | SecurityUtils.getSubject().logout(); |
147 | 143 | return Result.ok("退出登录成功!"); |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/system/controller/ThirdLoginController.java
... | ... | @@ -202,7 +202,6 @@ public class ThirdLoginController { |
202 | 202 | return token; |
203 | 203 | } |
204 | 204 | |
205 | - @SuppressWarnings("unchecked") | |
206 | 205 | @RequestMapping(value = "/getLoginUser/{token}/{thirdType}", method = RequestMethod.GET) |
207 | 206 | @ResponseBody |
208 | 207 | public Result<JSONObject> getThirdLoginUser(@PathVariable("token") String token, @PathVariable("thirdType") String thirdType) throws Exception { |
... | ... | @@ -235,7 +234,7 @@ public class ThirdLoginController { |
235 | 234 | result.setResult(obj); |
236 | 235 | result.setSuccess(true); |
237 | 236 | result.setCode(200); |
238 | - baseCommonService.addLog("用户名: " + username + ",登录成功[第三方用户]!", CommonConstant.LOG_TYPE_1, null); | |
237 | + baseCommonService.addLog("用户名:" + username + ",登录成功[第三方用户]!", CommonConstant.LOG_TYPE_1, null); | |
239 | 238 | return result; |
240 | 239 | } |
241 | 240 | |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
... | ... | @@ -392,13 +392,13 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl |
392 | 392 | // update-begin---author:王帅 Date:20200601 for:if条件永远为falsebug------------ |
393 | 393 | if (CommonConstant.DEL_FLAG_1.equals(sysUser.getDelFlag())) { |
394 | 394 | // update-end---author:王帅 Date:20200601 for:if条件永远为falsebug------------ |
395 | - baseCommonService.addLog("用户登录失败,用户名:" + sysUser.getUsername() + "已注销!", CommonConstant.LOG_TYPE_1, null); | |
395 | + baseCommonService.addLog("用户登录失败,用户名:" + sysUser.getUsername() + "已注销!", CommonConstant.LOG_TYPE_1, null); | |
396 | 396 | result.error500("该用户已注销"); |
397 | 397 | return result; |
398 | 398 | } |
399 | 399 | // 情况3:根据用户信息查询,该用户已冻结 |
400 | 400 | if (CommonConstant.USER_FREEZE.equals(sysUser.getStatus())) { |
401 | - baseCommonService.addLog("用户登录失败,用户名:" + sysUser.getUsername() + "已冻结!", CommonConstant.LOG_TYPE_1, null); | |
401 | + baseCommonService.addLog("用户登录失败,用户名:" + sysUser.getUsername() + "已冻结!", CommonConstant.LOG_TYPE_1, null); | |
402 | 402 | result.error500("该用户已冻结"); |
403 | 403 | return result; |
404 | 404 | } |
... | ... |
huaheng-wms-core/src/main/resources/application-dev.yml
... | ... | @@ -273,8 +273,9 @@ cas: |
273 | 273 | #Mybatis输出sql日志 |
274 | 274 | logging: |
275 | 275 | level: |
276 | - org.jeecg.modules.wms: debug | |
277 | - org.springframework: info | |
276 | + org.jeecg.common: WARN | |
277 | + org.jeecg.modules: WARN | |
278 | + org.jeecg.modules.wms: DEBUG | |
278 | 279 | #swagger |
279 | 280 | knife4j: |
280 | 281 | #开启增强配置 |
... | ... |
huaheng-wms-core/src/main/resources/application-prod.yml
... | ... | @@ -262,8 +262,9 @@ cas: |
262 | 262 | #Mybatis输出sql日志 |
263 | 263 | logging: |
264 | 264 | level: |
265 | - org.jeecg.modules.wms: info | |
266 | - org.springframework: info | |
265 | + org.jeecg.common: WARN | |
266 | + org.jeecg.modules: WARN | |
267 | + org.jeecg.modules.wms: DEBUG | |
267 | 268 | #swagger |
268 | 269 | knife4j: |
269 | 270 | #开启增强配置 |
... | ... |
huaheng-wms-core/src/main/resources/application-test.yml
... | ... | @@ -274,8 +274,9 @@ cas: |
274 | 274 | #Mybatis输出sql日志 |
275 | 275 | logging: |
276 | 276 | level: |
277 | - org.jeecg.modules.wms: debug | |
278 | - org.springframework: info | |
277 | + org.jeecg.common: WARN | |
278 | + org.jeecg.modules: WARN | |
279 | + org.jeecg.modules.wms: DEBUG | |
279 | 280 | #swagger |
280 | 281 | knife4j: |
281 | 282 | #开启增强配置 |
... | ... |
huaheng-wms-core/src/main/resources/banner.txt
... | ... | @@ -9,4 +9,4 @@ |
9 | 9 | 888 888 "Y88888P" d88P 888 888 888 8888888888 888 Y888 "Y8888P88 888P Y888 888 888 "Y8888P" 888 |
10 | 10 | |
11 | 11 | Jeecg Boot Version: 3.1.0 |
12 | -Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version} | |
13 | 12 | \ No newline at end of file |
13 | +Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version} | |
... | ... |