⚡ 登录历史参数化.
This commit is contained in:
13
README.md
13
README.md
@@ -51,12 +51,13 @@
|
|||||||
|
|
||||||
## 演示环境
|
## 演示环境
|
||||||
|
|
||||||
演示地址: http://101.43.254.243:1081/
|
* 🔗 演示地址: http://101.43.254.243:1081/
|
||||||
演示账号: admin/admin
|
* 🔏 演示账号: admin/admin
|
||||||
|
* ⭐ 体验后可以点一下 `star` 这对我很重要! [github](https://github.com/lijiahangmax/orion-visor) [gitee](https://gitee.com/lijiahangmax/orion-visor)
|
||||||
⭐ 体验后可以点一下 `star` 这对我很重要!
|
* 🌈 如果本项目对你有帮助请帮忙推广一下 让更多的人知道此项目!
|
||||||
🌈 如果本项目对你有帮助请帮忙推广一下 让更多的人知道此项目!
|
* 🎭 演示环境部分功能不可用, 完整功能请本地部署!
|
||||||
[github](https://github.com/lijiahangmax/orion-visor) [gitee](https://gitee.com/lijiahangmax/orion-visor)
|
* 📛 演示环境请不要随便删除数据!
|
||||||
|
* 📧 如果演示环境不可用请联系我!
|
||||||
|
|
||||||
## 快速开始
|
## 快速开始
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ public interface Const extends com.orion.lang.constant.Const, FieldConst, CnCons
|
|||||||
|
|
||||||
Integer DEFAULT_SORT = 10;
|
Integer DEFAULT_SORT = 10;
|
||||||
|
|
||||||
int LOGIN_HISTORY_COUNT = 30;
|
|
||||||
|
|
||||||
Long NONE_ID = -1L;
|
Long NONE_ID = -1L;
|
||||||
|
|
||||||
Integer DEFAULT_VERSION = 1;
|
Integer DEFAULT_VERSION = 1;
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ public class MineController {
|
|||||||
@IgnoreLog(IgnoreLogMode.RET)
|
@IgnoreLog(IgnoreLogMode.RET)
|
||||||
@GetMapping("/login-history")
|
@GetMapping("/login-history")
|
||||||
@Operation(summary = "查询当前用户登录日志")
|
@Operation(summary = "查询当前用户登录日志")
|
||||||
public List<LoginHistoryVO> getCurrentLoginHistory() {
|
public List<LoginHistoryVO> getCurrentLoginHistory(@RequestParam("count") Integer count) {
|
||||||
return mineService.getCurrentLoginHistory();
|
return mineService.getCurrentLoginHistory(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@IgnoreLog(IgnoreLogMode.RET)
|
@IgnoreLog(IgnoreLogMode.RET)
|
||||||
|
|||||||
@@ -182,8 +182,9 @@ public class SystemUserController {
|
|||||||
@GetMapping("/login-history")
|
@GetMapping("/login-history")
|
||||||
@Operation(summary = "查询用户登录日志")
|
@Operation(summary = "查询用户登录日志")
|
||||||
@PreAuthorize("@ss.hasPermission('infra:system-user:login-history')")
|
@PreAuthorize("@ss.hasPermission('infra:system-user:login-history')")
|
||||||
public List<LoginHistoryVO> getLoginHistory(@RequestParam("username") String username) {
|
public List<LoginHistoryVO> getLoginHistory(@RequestParam("username") String username,
|
||||||
return operatorLogService.getLoginHistory(username);
|
@RequestParam("count") Integer count) {
|
||||||
|
return operatorLogService.getLoginHistory(username, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,9 +46,10 @@ public interface MineService {
|
|||||||
/**
|
/**
|
||||||
* 获取当前用户登录日志
|
* 获取当前用户登录日志
|
||||||
*
|
*
|
||||||
|
* @param count count
|
||||||
* @return 登录日志
|
* @return 登录日志
|
||||||
*/
|
*/
|
||||||
List<LoginHistoryVO> getCurrentLoginHistory();
|
List<LoginHistoryVO> getCurrentLoginHistory(Integer count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前用户会话列表
|
* 获取当前用户会话列表
|
||||||
|
|||||||
@@ -60,8 +60,9 @@ public interface OperatorLogService {
|
|||||||
* 查询用户登录日志
|
* 查询用户登录日志
|
||||||
*
|
*
|
||||||
* @param username username
|
* @param username username
|
||||||
|
* @param count count
|
||||||
* @return rows
|
* @return rows
|
||||||
*/
|
*/
|
||||||
List<LoginHistoryVO> getLoginHistory(String username);
|
List<LoginHistoryVO> getLoginHistory(String username, Integer count);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ public class MineServiceImpl implements MineService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LoginHistoryVO> getCurrentLoginHistory() {
|
public List<LoginHistoryVO> getCurrentLoginHistory(Integer count) {
|
||||||
String username = SecurityUtils.getLoginUsername();
|
String username = SecurityUtils.getLoginUsername();
|
||||||
return operatorLogService.getLoginHistory(username);
|
return operatorLogService.getLoginHistory(username, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.orion.lang.define.wrapper.DataGrid;
|
import com.orion.lang.define.wrapper.DataGrid;
|
||||||
import com.orion.lang.utils.Arrays1;
|
import com.orion.lang.utils.Arrays1;
|
||||||
|
import com.orion.lang.utils.Valid;
|
||||||
import com.orion.visor.framework.biz.operator.log.core.model.OperatorLogModel;
|
import com.orion.visor.framework.biz.operator.log.core.model.OperatorLogModel;
|
||||||
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
import com.orion.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||||
import com.orion.visor.framework.common.constant.Const;
|
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||||
import com.orion.visor.module.infra.convert.OperatorLogConvert;
|
import com.orion.visor.module.infra.convert.OperatorLogConvert;
|
||||||
import com.orion.visor.module.infra.dao.OperatorLogDAO;
|
import com.orion.visor.module.infra.dao.OperatorLogDAO;
|
||||||
import com.orion.visor.module.infra.define.operator.AuthenticationOperatorType;
|
import com.orion.visor.module.infra.define.operator.AuthenticationOperatorType;
|
||||||
@@ -81,7 +82,8 @@ public class OperatorLogServiceImpl implements OperatorLogService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LoginHistoryVO> getLoginHistory(String username) {
|
public List<LoginHistoryVO> getLoginHistory(String username, Integer count) {
|
||||||
|
Valid.gt(count, 0, ErrorMessage.PARAM_ERROR);
|
||||||
// 条件
|
// 条件
|
||||||
OperatorLogQueryRequest request = new OperatorLogQueryRequest();
|
OperatorLogQueryRequest request = new OperatorLogQueryRequest();
|
||||||
request.setUsername(username);
|
request.setUsername(username);
|
||||||
@@ -89,7 +91,7 @@ public class OperatorLogServiceImpl implements OperatorLogService {
|
|||||||
LambdaQueryWrapper<OperatorLogDO> wrapper = this.buildQueryWrapper(request);
|
LambdaQueryWrapper<OperatorLogDO> wrapper = this.buildQueryWrapper(request);
|
||||||
// 查询
|
// 查询
|
||||||
return operatorLogDAO.of(wrapper)
|
return operatorLogDAO.of(wrapper)
|
||||||
.limit(Const.LOGIN_HISTORY_COUNT)
|
.limit(count)
|
||||||
.list(OperatorLogConvert.MAPPER::toLoginHistory);
|
.list(OperatorLogConvert.MAPPER::toLoginHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ export function updateCurrentUser(request: UserUpdateRequest) {
|
|||||||
/**
|
/**
|
||||||
* 查询当前用户登录日志
|
* 查询当前用户登录日志
|
||||||
*/
|
*/
|
||||||
export function getCurrentLoginHistory() {
|
export function getCurrentLoginHistory(count: number) {
|
||||||
return axios.get<LoginHistoryQueryResponse[]>('/infra/mine/login-history');
|
return axios.get<LoginHistoryQueryResponse[]>('/infra/mine/login-history', { params: { count } });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -192,6 +192,6 @@ export function offlineUserSession(request: UserSessionOfflineRequest) {
|
|||||||
/**
|
/**
|
||||||
* 查询登录日志
|
* 查询登录日志
|
||||||
*/
|
*/
|
||||||
export function getLoginHistory(username: string) {
|
export function getLoginHistory(username: string, count: number) {
|
||||||
return axios.get<LoginHistoryQueryResponse[]>('/infra/system-user/login-history', { params: { username } });
|
return axios.get<LoginHistoryQueryResponse[]>('/infra/system-user/login-history', { params: { username, count } });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
<div class="main-container">
|
<div class="main-container">
|
||||||
<span class="extra-message">
|
<span class="extra-message">
|
||||||
<template v-if="user">
|
<template v-if="user">
|
||||||
只展示用户 <span class="user-info">{{ user.nickname }}({{ user.username }})</span> 最近登录的 30 条历史记录
|
只展示用户 <span class="user-info">{{ user.nickname }}({{ user.username }})</span> 最近登录的 {{ historyCount }} 条历史记录
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
只展示最近登录的 30 条历史记录
|
只展示最近登录的 {{ historyCount }} 条历史记录
|
||||||
</template>
|
</template>
|
||||||
</span>
|
</span>
|
||||||
<!-- 加载中 -->
|
<!-- 加载中 -->
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
import type { UserQueryResponse, LoginHistoryQueryResponse } from '@/api/user/user';
|
import type { UserQueryResponse, LoginHistoryQueryResponse } from '@/api/user/user';
|
||||||
import { ref, onBeforeMount } from 'vue';
|
import { ref, onBeforeMount } from 'vue';
|
||||||
import useLoading from '@/hooks/loading';
|
import useLoading from '@/hooks/loading';
|
||||||
import { ResultStatus } from '../types/const';
|
import { historyCount, ResultStatus } from '../types/const';
|
||||||
import { getCurrentLoginHistory } from '@/api/user/mine';
|
import { getCurrentLoginHistory } from '@/api/user/mine';
|
||||||
import { getLoginHistory } from '@/api/user/user';
|
import { getLoginHistory } from '@/api/user/user';
|
||||||
import { dateFormat } from '@/utils';
|
import { dateFormat } from '@/utils';
|
||||||
@@ -82,11 +82,11 @@
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
if (props.user) {
|
if (props.user) {
|
||||||
// 查询其他用户
|
// 查询其他用户
|
||||||
const { data } = await getLoginHistory(props.user.username);
|
const { data } = await getLoginHistory(props.user.username, historyCount);
|
||||||
list.value = data;
|
list.value = data;
|
||||||
} else {
|
} else {
|
||||||
// 查询当前用户
|
// 查询当前用户
|
||||||
const { data } = await getCurrentLoginHistory();
|
const { data } = await getCurrentLoginHistory(historyCount);
|
||||||
list.value = data;
|
list.value = data;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -5,3 +5,6 @@ export const ResultStatus = {
|
|||||||
// 成功
|
// 成功
|
||||||
SUCCESS: 1,
|
SUCCESS: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 历史数量
|
||||||
|
export const historyCount = 30;
|
||||||
|
|||||||
Reference in New Issue
Block a user