import http from '../utils/http'; /** * @typedef {object} CreateUserRequest * @property {string} username * @property {string} password */ /** * @typedef {object} CreateUserResponse * @property {number} id * @property {string} username */ /** * @typedef {object} LoginRequest * @property {string} identifier - Identifier 可以是用户名、邮箱、手机号、微信号或飞书账号 * @property {string} password */ /** * @typedef {object} LoginResponse * @property {number} id * @property {string} username * @property {string} token */ /** * @typedef {('成功'|'失败')} AuditStatus */ /** * @typedef {object} UserActionLogDTO * @property {number} id * @property {number} user_id * @property {string} username * @property {string} action_type * @property {string} description * @property {string} http_method * @property {string} http_path * @property {string} source_ip * @property {Array} target_resource * @property {AuditStatus} status * @property {string} result_details * @property {string} time */ /** * @typedef {object} PaginationDTO * @property {number} page * @property {number} pageSize * @property {number} total */ /** * @typedef {object} ListUserActionLogResponse * @property {Array} list * @property {PaginationDTO} pagination */ /** * @typedef {object} UserHistoryParams * @property {string} [action_type] * @property {string} [end_time] * @property {string} [order_by] * @property {number} [page] * @property {number} [pageSize] * @property {string} [start_time] * @property {string} [status] * @property {number} [user_id] * @property {string} [username] */ /** * 创建一个新用户 * @param {CreateUserRequest} userData - 用户信息 * @returns {Promise} */ const createUser = (userData) => { return http.post('/api/v1/users', userData); }; /** * 用户登录 * @param {LoginRequest} credentials - 登录凭证 * @returns {Promise} */ const login = (credentials) => { return http.post('/api/v1/users/login', credentials); }; /** * 获取指定用户的操作历史 * @param {number} id - 用户ID * @param {UserHistoryParams} params - 查询参数 * @returns {Promise} */ const getUserHistory = (id, params) => { return http.get(`/api/v1/users/${id}/history`, { params }); }; export const UserApi = { createUser, login, getUserHistory, };