From 27f9622b17091d01f171721e20355b79a660491f Mon Sep 17 00:00:00 2001 From: Leo <98382335+gaoziman@users.noreply.github.com> Date: Sat, 27 Sep 2025 17:49:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(API):=20=E6=96=B0=E5=A2=9E=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=94=A8=E6=88=B7=E7=9B=91=E6=8E=A7API=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增在线用户相关类型定义 - 实现分页查询在线用户列表接口 - 实现强制注销用户接口 - 实现获取在线用户统计接口 - 支持按登录名、用户名、IP地址过滤 --- src/service/api/monitor/online/index.ts | 33 +++++++++ src/service/api/monitor/online/types.ts | 97 +++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 src/service/api/monitor/online/index.ts create mode 100644 src/service/api/monitor/online/types.ts diff --git a/src/service/api/monitor/online/index.ts b/src/service/api/monitor/online/index.ts new file mode 100644 index 0000000..5b43ea2 --- /dev/null +++ b/src/service/api/monitor/online/index.ts @@ -0,0 +1,33 @@ +import { request } from '@/service/http' +import type { + OnlineUserCountVo, + OnlineUserSearchForm, + OnlineUserVo, + PageOnlineUserVo, + SysUserOnlineQueryBo, +} from './types' + +// 重新导出类型定义 +export type { OnlineUserCountVo, OnlineUserSearchForm, OnlineUserVo, PageOnlineUserVo, SysUserOnlineQueryBo } + +/** + * 分页查询在线用户列表 + */ +export function getOnlineUserListPage(params: SysUserOnlineQueryBo) { + return request.Get>('/coder/sysUserOnline/listPage', { params }) +} + +/** + * 强制注销 + * @param userId 用户ID + */ +export function logoutUser(userId: string) { + return request.Get>(`/coder/sysUserOnline/logout/${userId}`) +} + +/** + * 获取在线用户统计信息 + */ +export function getOnlineUserCount() { + return request.Get>('/coder/sysUserOnline/count') +} diff --git a/src/service/api/monitor/online/types.ts b/src/service/api/monitor/online/types.ts new file mode 100644 index 0000000..cf6ae08 --- /dev/null +++ b/src/service/api/monitor/online/types.ts @@ -0,0 +1,97 @@ +/** + * 在线用户监控 - 类型定义 + */ + +/** + * 在线用户实体 + */ +export interface OnlineUserVo { + /** 用户ID */ + userId: string + /** 登录名称 */ + loginName: string + /** 用户名 */ + userName: string + /** 用户头像 */ + avatar?: string + /** 性别[1-男 2-女 3-未知] */ + sex?: string + /** 手机号 */ + phone?: string + /** 邮箱 */ + email?: string + /** 用户类型[1-系统用户 2-注册用户 3-微信用户] */ + userType?: string + /** 城市ID[可新增城市表-暂时无用] */ + cityId?: string + /** 登录时间 */ + loginTime?: string + /** 创建时间 */ + createTime?: string + /** 登录IP */ + loginIp?: string + /** 登录地址 */ + loginAddress?: string + /** 浏览器类型 */ + browser?: string + /** 操作系统 */ + os?: string + /** 设备名字 */ + deviceName?: string + /** 是否超级管理员 */ + isCoderAdmin?: boolean +} + +/** + * 在线用户查询参数 + */ +export interface SysUserOnlineQueryBo { + /** 页码 */ + pageNo?: number + /** 页大小 */ + pageSize?: number + /** 登录名称 */ + loginName?: string + /** 用户名字 */ + userName?: string + /** IP地址 */ + loginIp?: string +} + +/** + * 在线用户搜索表单 + */ +export interface OnlineUserSearchForm { + /** 登录名称 */ + loginName?: string + /** 用户名字 */ + userName?: string + /** IP地址 */ + loginIp?: string +} + +/** + * 分页在线用户响应 + */ +export interface PageOnlineUserVo { + /** 总记录数 */ + total: number + /** 当前页 */ + current: number + /** 每页大小 */ + size: number + /** 总页数 */ + pages: number + /** 数据列表 */ + records: OnlineUserVo[] +} + +/** + * 在线用户统计响应 + */ +export interface OnlineUserCountVo { + /** 在线用户总数 */ + onlineCount: number + /** 统计时间戳 */ + timestamp: number +}