登录历史参数化.

This commit is contained in:
lijiahang
2024-06-11 12:28:24 +08:00
parent 07e8e63ee6
commit 4b060a864a
12 changed files with 35 additions and 28 deletions

View File

@@ -51,12 +51,13 @@
## 演示环境
演示地址: http://101.43.254.243:1081/
演示账号: admin/admin
⭐ 体验后可以点一下 `star` 这对我很重要!
🌈 如果本项目对你有帮助请帮忙推广一下 让更多的人知道此项目!
[github](https://github.com/lijiahangmax/orion-visor) [gitee](https://gitee.com/lijiahangmax/orion-visor)
* 🔗 演示地址: http://101.43.254.243:1081/
* 🔏 演示账号: admin/admin
* ⭐ 体验后可以点一下 `star` 这对我很重要! [github](https://github.com/lijiahangmax/orion-visor) [gitee](https://gitee.com/lijiahangmax/orion-visor)
* 🌈 如果本项目对你有帮助请帮忙推广一下 让更多的人知道此项目!
* 🎭 演示环境部分功能不可用, 完整功能请本地部署!
* 📛 演示环境请不要随便删除数据!
* 📧 如果演示环境不可用请联系我!
## 快速开始

View File

@@ -25,8 +25,6 @@ public interface Const extends com.orion.lang.constant.Const, FieldConst, CnCons
Integer DEFAULT_SORT = 10;
int LOGIN_HISTORY_COUNT = 30;
Long NONE_ID = -1L;
Integer DEFAULT_VERSION = 1;

View File

@@ -70,8 +70,8 @@ public class MineController {
@IgnoreLog(IgnoreLogMode.RET)
@GetMapping("/login-history")
@Operation(summary = "查询当前用户登录日志")
public List<LoginHistoryVO> getCurrentLoginHistory() {
return mineService.getCurrentLoginHistory();
public List<LoginHistoryVO> getCurrentLoginHistory(@RequestParam("count") Integer count) {
return mineService.getCurrentLoginHistory(count);
}
@IgnoreLog(IgnoreLogMode.RET)

View File

@@ -182,8 +182,9 @@ public class SystemUserController {
@GetMapping("/login-history")
@Operation(summary = "查询用户登录日志")
@PreAuthorize("@ss.hasPermission('infra:system-user:login-history')")
public List<LoginHistoryVO> getLoginHistory(@RequestParam("username") String username) {
return operatorLogService.getLoginHistory(username);
public List<LoginHistoryVO> getLoginHistory(@RequestParam("username") String username,
@RequestParam("count") Integer count) {
return operatorLogService.getLoginHistory(username, count);
}
}

View File

@@ -46,9 +46,10 @@ public interface MineService {
/**
* 获取当前用户登录日志
*
* @param count count
* @return 登录日志
*/
List<LoginHistoryVO> getCurrentLoginHistory();
List<LoginHistoryVO> getCurrentLoginHistory(Integer count);
/**
* 获取当前用户会话列表

View File

@@ -60,8 +60,9 @@ public interface OperatorLogService {
* 查询用户登录日志
*
* @param username username
* @param count count
* @return rows
*/
List<LoginHistoryVO> getLoginHistory(String username);
List<LoginHistoryVO> getLoginHistory(String username, Integer count);
}

View File

@@ -77,9 +77,9 @@ public class MineServiceImpl implements MineService {
}
@Override
public List<LoginHistoryVO> getCurrentLoginHistory() {
public List<LoginHistoryVO> getCurrentLoginHistory(Integer count) {
String username = SecurityUtils.getLoginUsername();
return operatorLogService.getLoginHistory(username);
return operatorLogService.getLoginHistory(username, count);
}
@Override

View File

@@ -4,9 +4,10 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.orion.lang.define.wrapper.DataGrid;
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.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.dao.OperatorLogDAO;
import com.orion.visor.module.infra.define.operator.AuthenticationOperatorType;
@@ -81,7 +82,8 @@ public class OperatorLogServiceImpl implements OperatorLogService {
}
@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();
request.setUsername(username);
@@ -89,7 +91,7 @@ public class OperatorLogServiceImpl implements OperatorLogService {
LambdaQueryWrapper<OperatorLogDO> wrapper = this.buildQueryWrapper(request);
// 查询
return operatorLogDAO.of(wrapper)
.limit(Const.LOGIN_HISTORY_COUNT)
.limit(count)
.list(OperatorLogConvert.MAPPER::toLoginHistory);
}

View File

@@ -35,8 +35,8 @@ export function updateCurrentUser(request: UserUpdateRequest) {
/**
* 查询当前用户登录日志
*/
export function getCurrentLoginHistory() {
return axios.get<LoginHistoryQueryResponse[]>('/infra/mine/login-history');
export function getCurrentLoginHistory(count: number) {
return axios.get<LoginHistoryQueryResponse[]>('/infra/mine/login-history', { params: { count } });
}
/**

View File

@@ -192,6 +192,6 @@ export function offlineUserSession(request: UserSessionOfflineRequest) {
/**
* 查询登录日志
*/
export function getLoginHistory(username: string) {
return axios.get<LoginHistoryQueryResponse[]>('/infra/system-user/login-history', { params: { username } });
export function getLoginHistory(username: string, count: number) {
return axios.get<LoginHistoryQueryResponse[]>('/infra/system-user/login-history', { params: { username, count } });
}

View File

@@ -2,10 +2,10 @@
<div class="main-container">
<span class="extra-message">
<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 v-else>
只展示最近登录的 30 条历史记录
只展示最近登录的 {{ historyCount }} 条历史记录
</template>
</span>
<!-- 加载中 -->
@@ -62,7 +62,7 @@
import type { UserQueryResponse, LoginHistoryQueryResponse } from '@/api/user/user';
import { ref, onBeforeMount } from 'vue';
import useLoading from '@/hooks/loading';
import { ResultStatus } from '../types/const';
import { historyCount, ResultStatus } from '../types/const';
import { getCurrentLoginHistory } from '@/api/user/mine';
import { getLoginHistory } from '@/api/user/user';
import { dateFormat } from '@/utils';
@@ -82,11 +82,11 @@
setLoading(true);
if (props.user) {
// 查询其他用户
const { data } = await getLoginHistory(props.user.username);
const { data } = await getLoginHistory(props.user.username, historyCount);
list.value = data;
} else {
// 查询当前用户
const { data } = await getCurrentLoginHistory();
const { data } = await getCurrentLoginHistory(historyCount);
list.value = data;
}
} catch (e) {

View File

@@ -5,3 +5,6 @@ export const ResultStatus = {
// 成功
SUCCESS: 1,
};
// 历史数量
export const historyCount = 30;