修改api.js

This commit is contained in:
2025-10-31 18:25:29 +08:00
parent e704249d75
commit 22f633e20b
9 changed files with 279 additions and 114 deletions

View File

@@ -48,7 +48,7 @@ import http from '../utils/http';
/**
* @typedef {object} PaginationDTO
* @property {number} page
* @property {number} pageSize
* @property {number} page_size
* @property {number} total
*/
@@ -64,7 +64,7 @@ import http from '../utils/http';
* @property {string} [end_time]
* @property {string} [order_by]
* @property {number} [page]
* @property {number} [pageSize]
* @property {number} [page_size]
* @property {string} [start_time]
* @property {string} [status]
* @property {number} [user_id]
@@ -80,6 +80,13 @@ import http from '../utils/http';
* @property {NotifierType} type - Type 指定要测试的通知渠道
*/
/**
* @typedef {object} Response
* @property {number} code - 业务状态码
* @property {object} [data] - 业务数据
* @property {string} [message] - 提示信息
*/
/**
* 创建一个新用户
* @param {CreateUserRequest} userData - 用户信息
@@ -99,20 +106,30 @@ const login = (credentials) => {
};
/**
* 获取指定用户操作历史
* @param {number} id - 用户ID
* 获取用户操作日志列表
* @param {UserHistoryParams} params - 查询参数
* @returns {Promise<ListUserActionLogResponse>}
*/
const getUserHistory = (id, params) => {
return http.get(`/api/v1/users/${id}/history`, { params });
const getUserActionLogs = (params) => {
const newParams = {
action_type: params.action_type,
end_time: params.end_time,
order_by: params.order_by,
page: params.page,
page_size: params.page_size,
start_time: params.start_time,
status: params.status,
user_id: params.user_id,
username: params.username,
};
return http.get('/api/v1/monitor/user-action-logs', { params: newParams });
};
/**
* 发送测试通知
* @param {number} id - 用户ID
* @param {SendTestNotificationRequest} data - 请求体
* @returns {Promise<string>}
* @returns {Promise<Response>}
*/
const sendTestNotification = (id, data) => {
return http.post(`/api/v1/users/${id}/notifications/test`, data);
@@ -121,6 +138,6 @@ const sendTestNotification = (id, data) => {
export const UserApi = {
createUser,
login,
getUserHistory,
getUserActionLogs,
sendTestNotification,
};