Files
Snap.Server.Web/src/api/user.ts
2026-02-10 20:20:40 +08:00

69 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import request from '@/utils/request'
/** 用户信息数据结构 */
export interface UserInfo {
CdnExpireAt: string
GachaLogExpireAt: string
IsLicensedDeveloper: boolean
IsMaintainer: boolean
NormalizedUserName: string
UserName: string
}
/** 用户列表中的用户数据结构 */
export interface UserListItem {
CdnExpireAt: string
CreatedAt: string
GachaLogExpireAt: string
IsLicensedDeveloper: boolean
IsMaintainer: boolean
NormalizedUserName: string
UserName: string
_id: string
email: string
}
/** API响应数据结构 */
export interface ApiResponse<T> {
code: number
data: T
message: string
}
/**
* 获取用户信息
* GET /Passport/v2/UserInfo
*/
export function getUserInfoApi(): Promise<UserInfo> {
return request({
url: '/Passport/v2/UserInfo',
method: 'get',
})
}
/**
* 获取用户列表
* GET /web-api/users
* @param params 搜索和筛选参数
* @param params.q 搜索关键词可搜索用户名、邮箱、_id
* @param params.role 按角色筛选maintainer, developer, user
* @param params.email 按邮箱筛选
* @param params.username 按用户名筛选
* @param params.id 按用户ID筛选
* @param params.is 按状态筛选licensed, not-licensed
*/
export function getUserListApi(params?: {
q?: string
role?: string
email?: string
username?: string
id?: string
is?: string
}): Promise<UserListItem[]> {
return request({
url: '/web-api/users',
method: 'get',
params,
})
}