feat: 操作日志

This commit is contained in:
dap
2024-09-26 08:40:16 +08:00
parent 066a1a0f97
commit dcb6300ec7
9 changed files with 401 additions and 65 deletions

View File

@@ -0,0 +1,40 @@
import type { OnlineUser } from './model';
import type { PageQuery } from '#/api/common';
import { requestClient } from '#/api/request';
enum Api {
onlineList = '/monitor/online/list',
root = '/monitor/online',
}
/**
* 当前账号的在线设备 个人中心使用
* @returns OnlineUser[]
*/
export function onlineDeviceList() {
return requestClient.get<OnlineUser[]>(Api.root);
}
export function onlineList(params?: PageQuery) {
return requestClient.get<OnlineUser[]>(Api.onlineList, { params });
}
/**
* 强制下线
* @param tokenId 用户token
* @returns void
*/
export function forceLogout(tokenId: string) {
return requestClient.delete<void>(`${Api.root}/${tokenId}`);
}
/**
* 个人中心用的 跟上面的不同是用的Post
* @param tokenId 用户token
* @returns void
*/
export function forceLogout2(tokenId: string) {
return requestClient.post<void>(`${Api.root}/${tokenId}`);
}

View File

@@ -0,0 +1,10 @@
export interface OnlineUser {
tokenId: string;
deptName: string;
userName: string;
ipaddr: string;
loginLocation: string;
browser: string;
os: string;
loginTime: number;
}

View File

@@ -0,0 +1,31 @@
import type { OperationLog } from './model';
import type { IDS, PageQuery, PageResult } from '#/api/common';
import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';
enum Api {
operLogClean = '/monitor/operlog/clean',
operLogExport = '/monitor/operlog/export',
operLogList = '/monitor/operlog/list',
root = '/monitor/operlog',
}
export function operLogList(params?: PageQuery) {
return requestClient.get<PageResult<OperationLog>>(Api.operLogList, {
params,
});
}
export function operLogDelete(operIds: IDS) {
return requestClient.deleteWithMsg<void>(`${Api.root}/${operIds}`);
}
export function operLogClean() {
return requestClient.deleteWithMsg<void>(Api.operLogClean);
}
export function operLogExport(data: any) {
return commonExport(Api.operLogExport, data);
}

View File

@@ -0,0 +1,21 @@
export interface OperationLog {
operId: string;
tenantId: string;
title: string;
businessType: number;
businessTypes?: any;
method: string;
requestMethod: string;
operatorType: number;
operName: string;
deptName: string;
operUrl: string;
operIp: string;
operLocation: string;
operParam: string;
jsonResult: string;
status: number;
errorMsg: string;
operTime: string;
costTime: number;
}