Initial commit: One Pipe System
完整的管理系统,包含账户管理、卡片管理、套餐管理、财务管理等功能模块。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
97
src/api/modules/account.ts
Normal file
97
src/api/modules/account.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* 账号相关 API - 匹配后端实际接口
|
||||
*/
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import type {
|
||||
PlatformAccount,
|
||||
AccountQueryParams,
|
||||
CreatePlatformAccountParams,
|
||||
BaseResponse,
|
||||
PaginationResponse
|
||||
} from '@/types/api'
|
||||
|
||||
export class AccountService extends BaseService {
|
||||
// ========== 账号管理 (Account Management) ==========
|
||||
|
||||
/**
|
||||
* 获取账号列表
|
||||
* GET /api/admin/accounts
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getAccounts(
|
||||
params?: AccountQueryParams
|
||||
): Promise<PaginationResponse<PlatformAccount>> {
|
||||
return this.getPage<PlatformAccount>('/api/admin/accounts', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建账号
|
||||
* POST /api/admin/accounts
|
||||
* @param data 账号数据
|
||||
*/
|
||||
static createAccount(data: CreatePlatformAccountParams): Promise<BaseResponse> {
|
||||
return this.create('/api/admin/accounts', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新账号
|
||||
* PUT /api/admin/accounts/{id}
|
||||
* @param id 账号ID
|
||||
* @param data 账号数据
|
||||
*/
|
||||
static updateAccount(
|
||||
id: number,
|
||||
data: Partial<CreatePlatformAccountParams>
|
||||
): Promise<BaseResponse> {
|
||||
return this.update(`/api/admin/accounts/${id}`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除账号
|
||||
* DELETE /api/admin/accounts/{id}
|
||||
* @param id 账号ID
|
||||
*/
|
||||
static deleteAccount(id: number): Promise<BaseResponse> {
|
||||
return this.remove(`/api/admin/accounts/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账号详情
|
||||
* GET /api/admin/accounts/{id}
|
||||
* @param id 账号ID
|
||||
*/
|
||||
static getAccountDetail(id: number): Promise<BaseResponse<PlatformAccount>> {
|
||||
return this.getOne<PlatformAccount>(`/api/admin/accounts/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账号的角色列表
|
||||
* GET /api/admin/accounts/{id}/roles
|
||||
* @param id 账号ID
|
||||
* @returns 返回角色对象数组
|
||||
*/
|
||||
static getAccountRoles(id: number): Promise<BaseResponse<any[]>> {
|
||||
return this.get<BaseResponse<any[]>>(`/api/admin/accounts/${id}/roles`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 为账号分配角色
|
||||
* POST /api/admin/accounts/{id}/roles
|
||||
* @param id 账号ID
|
||||
* @param roleIds 角色ID列表
|
||||
*/
|
||||
static assignRolesToAccount(id: number, roleIds: number[]): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>(`/api/admin/accounts/${id}/roles`, { role_ids: roleIds })
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除账号的单个角色
|
||||
* DELETE /api/admin/accounts/{account_id}/roles/{role_id}
|
||||
* @param accountId 账号ID
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
static removeRoleFromAccount(accountId: number, roleId: number): Promise<BaseResponse> {
|
||||
return this.delete<BaseResponse>(`/api/admin/accounts/${accountId}/roles/${roleId}`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user