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}`)
|
||||
}
|
||||
}
|
||||
72
src/api/modules/article.ts
Normal file
72
src/api/modules/article.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* 文章相关类型定义
|
||||
*/
|
||||
|
||||
// 文章类型 (新命名规范)
|
||||
export interface Article {
|
||||
id?: number
|
||||
blogClass: string
|
||||
title: string
|
||||
count?: number
|
||||
htmlContent: string
|
||||
createTime: string
|
||||
homeImg: string
|
||||
brief: string
|
||||
typeName?: string
|
||||
status?: number
|
||||
author?: string
|
||||
tags?: string[]
|
||||
}
|
||||
|
||||
// 兼容原有的文章类型命名
|
||||
export interface ArticleType {
|
||||
id?: number
|
||||
blog_class: string
|
||||
title: string
|
||||
count?: number
|
||||
html_content: string
|
||||
create_time: string
|
||||
home_img: string
|
||||
brief: string
|
||||
type_name?: string
|
||||
}
|
||||
|
||||
// 文章分类类型 (新命名规范)
|
||||
export interface ArticleCategory {
|
||||
id: number
|
||||
name: string
|
||||
icon: string
|
||||
count: number
|
||||
description?: string
|
||||
sortOrder?: number
|
||||
}
|
||||
|
||||
// 兼容原有的文章分类类型命名
|
||||
export interface ArticleCategoryType {
|
||||
id: number
|
||||
name: string
|
||||
icon: string
|
||||
count: number
|
||||
}
|
||||
|
||||
// 文章查询参数
|
||||
export interface ArticleQueryParams {
|
||||
page?: number
|
||||
size?: number
|
||||
searchVal?: string
|
||||
year?: string
|
||||
categoryId?: number
|
||||
status?: number
|
||||
}
|
||||
|
||||
// 文章创建/更新参数
|
||||
export interface ArticleFormData {
|
||||
blogClass: string
|
||||
title: string
|
||||
htmlContent: string
|
||||
homeImg: string
|
||||
brief: string
|
||||
author?: string
|
||||
tags?: string[]
|
||||
status?: number
|
||||
}
|
||||
63
src/api/modules/auth.ts
Normal file
63
src/api/modules/auth.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* 认证相关 API
|
||||
*/
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import type {
|
||||
LoginParams,
|
||||
LoginData,
|
||||
UserInfo,
|
||||
UserInfoResponse,
|
||||
RefreshTokenParams,
|
||||
RefreshTokenData,
|
||||
ChangePasswordParams,
|
||||
BaseResponse
|
||||
} from '@/types/api'
|
||||
|
||||
export class AuthService extends BaseService {
|
||||
/**
|
||||
* 用户登录
|
||||
* @param params 登录参数
|
||||
*/
|
||||
static login(params: LoginParams): Promise<BaseResponse<LoginData>> {
|
||||
return this.post<BaseResponse<LoginData>>('/api/admin/login', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
static logout(): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>('/api/admin/logout')
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户信息
|
||||
* GET /api/admin/me
|
||||
*/
|
||||
static getUserInfo(): Promise<BaseResponse<UserInfoResponse>> {
|
||||
return this.get<BaseResponse<UserInfoResponse>>('/api/admin/me')
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新 Token
|
||||
* @param params 刷新参数
|
||||
*/
|
||||
static refreshToken(params: RefreshTokenParams): Promise<BaseResponse<RefreshTokenData>> {
|
||||
return this.post<BaseResponse<RefreshTokenData>>('/api/auth/refresh', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* @param params 修改密码参数
|
||||
*/
|
||||
static changePassword(params: ChangePasswordParams): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>('/api/auth/change-password', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证码(如果需要)
|
||||
*/
|
||||
static getCaptcha(): Promise<BaseResponse<{ captchaId: string; captchaImage: string }>> {
|
||||
return this.get<BaseResponse<{ captchaId: string; captchaImage: string }>>('/api/auth/captcha')
|
||||
}
|
||||
}
|
||||
274
src/api/modules/card.ts
Normal file
274
src/api/modules/card.ts
Normal file
@@ -0,0 +1,274 @@
|
||||
/**
|
||||
* 网卡相关 API
|
||||
*/
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import type {
|
||||
Card,
|
||||
SimCardProduct,
|
||||
CardQueryParams,
|
||||
CardImportBatch,
|
||||
CardOperationParams,
|
||||
CardAssignParams,
|
||||
BatchRechargeRecord,
|
||||
CardChangeApplication,
|
||||
ProcessCardChangeParams,
|
||||
FlowDetail,
|
||||
SuspendResumeRecord,
|
||||
CardOrder,
|
||||
BaseResponse,
|
||||
PaginationResponse,
|
||||
ListResponse
|
||||
} from '@/types/api'
|
||||
|
||||
export class CardService extends BaseService {
|
||||
// ========== 号卡商品管理 ==========
|
||||
|
||||
/**
|
||||
* 获取号卡商品列表
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getSimCardProducts(params?: any): Promise<PaginationResponse<SimCardProduct>> {
|
||||
return this.getPage<SimCardProduct>('/api/simcard-products', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建号卡商品
|
||||
* @param data 商品数据
|
||||
*/
|
||||
static createSimCardProduct(data: Partial<SimCardProduct>): Promise<BaseResponse> {
|
||||
return this.create('/api/simcard-products', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新号卡商品
|
||||
* @param id 商品ID
|
||||
* @param data 商品数据
|
||||
*/
|
||||
static updateSimCardProduct(
|
||||
id: string | number,
|
||||
data: Partial<SimCardProduct>
|
||||
): Promise<BaseResponse> {
|
||||
return this.update(`/api/simcard-products/${id}`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除号卡商品
|
||||
* @param id 商品ID
|
||||
*/
|
||||
static deleteSimCardProduct(id: string | number): Promise<BaseResponse> {
|
||||
return this.remove(`/api/simcard-products/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 号卡分配
|
||||
* @param params 分配参数
|
||||
*/
|
||||
static assignCard(params: CardAssignParams): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>('/api/simcard-products/assign', params)
|
||||
}
|
||||
|
||||
// ========== 网卡管理 ==========
|
||||
|
||||
/**
|
||||
* 获取网卡列表
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getCards(params?: CardQueryParams): Promise<PaginationResponse<Card>> {
|
||||
return this.getPage<Card>('/api/cards', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ICCID获取单卡信息
|
||||
* @param iccid ICCID
|
||||
*/
|
||||
static getCardByIccid(iccid: string): Promise<BaseResponse<Card>> {
|
||||
return this.getOne<Card>(`/api/cards/iccid/${iccid}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 网卡操作(充值、停复机、增减流量等)
|
||||
* @param params 操作参数
|
||||
*/
|
||||
static cardOperation(params: CardOperationParams): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>('/api/cards/operation', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 套餐充值
|
||||
* @param iccid ICCID
|
||||
* @param packageId 套餐ID
|
||||
*/
|
||||
static rechargePackage(iccid: string, packageId: string | number): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>(`/api/cards/${iccid}/recharge`, { packageId })
|
||||
}
|
||||
|
||||
/**
|
||||
* 停机
|
||||
* @param iccid ICCID
|
||||
* @param remark 备注
|
||||
*/
|
||||
static suspend(iccid: string, remark?: string): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>(`/api/cards/${iccid}/suspend`, { remark })
|
||||
}
|
||||
|
||||
/**
|
||||
* 复机
|
||||
* @param iccid ICCID
|
||||
* @param remark 备注
|
||||
*/
|
||||
static resume(iccid: string, remark?: string): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>(`/api/cards/${iccid}/resume`, { remark })
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流量详情
|
||||
* @param iccid ICCID
|
||||
* @param startDate 开始日期
|
||||
* @param endDate 结束日期
|
||||
*/
|
||||
static getFlowDetails(
|
||||
iccid: string,
|
||||
startDate?: string,
|
||||
endDate?: string
|
||||
): Promise<ListResponse<FlowDetail>> {
|
||||
return this.getList<FlowDetail>(`/api/cards/${iccid}/flow-details`, {
|
||||
startDate,
|
||||
endDate
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取停复机记录
|
||||
* @param iccid ICCID
|
||||
*/
|
||||
static getSuspendResumeRecords(iccid: string): Promise<ListResponse<SuspendResumeRecord>> {
|
||||
return this.getList<SuspendResumeRecord>(`/api/cards/${iccid}/suspend-resume-records`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取往期订单
|
||||
* @param iccid ICCID
|
||||
*/
|
||||
static getCardOrders(iccid: string): Promise<ListResponse<CardOrder>> {
|
||||
return this.getList<CardOrder>(`/api/cards/${iccid}/orders`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改过期时间
|
||||
* @param iccid ICCID
|
||||
* @param expireTime 过期时间
|
||||
*/
|
||||
static changeExpireTime(iccid: string, expireTime: string): Promise<BaseResponse> {
|
||||
return this.put<BaseResponse>(`/api/cards/${iccid}/expire-time`, { expireTime })
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加流量
|
||||
* @param iccid ICCID
|
||||
* @param flow 流量(MB)
|
||||
*/
|
||||
static addFlow(iccid: string, flow: number): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>(`/api/cards/${iccid}/add-flow`, { flow })
|
||||
}
|
||||
|
||||
/**
|
||||
* 减少流量
|
||||
* @param iccid ICCID
|
||||
* @param flow 流量(MB)
|
||||
*/
|
||||
static reduceFlow(iccid: string, flow: number): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>(`/api/cards/${iccid}/reduce-flow`, { flow })
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更钱包余额
|
||||
* @param iccid ICCID
|
||||
* @param amount 金额
|
||||
*/
|
||||
static changeWalletBalance(iccid: string, amount: number): Promise<BaseResponse> {
|
||||
return this.put<BaseResponse>(`/api/cards/${iccid}/wallet`, { amount })
|
||||
}
|
||||
|
||||
// ========== 批量操作 ==========
|
||||
|
||||
/**
|
||||
* 获取导入批次列表
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getImportBatches(params?: any): Promise<PaginationResponse<CardImportBatch>> {
|
||||
return this.getPage<CardImportBatch>('/api/cards/import-batches', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导入网卡
|
||||
* @param file Excel文件
|
||||
* @param params 额外参数
|
||||
*/
|
||||
static importCards(file: File, params?: Record<string, any>): Promise<BaseResponse> {
|
||||
return this.upload('/api/cards/import', file, params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入失败记录
|
||||
* @param batchId 批次ID
|
||||
*/
|
||||
static getImportFailures(batchId: string | number): Promise<ListResponse<any>> {
|
||||
return this.getList(`/api/cards/import-batches/${batchId}/failures`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量充值记录列表
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getBatchRechargeRecords(
|
||||
params?: any
|
||||
): Promise<PaginationResponse<BatchRechargeRecord>> {
|
||||
return this.getPage<BatchRechargeRecord>('/api/cards/batch-recharge-records', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量充值导入
|
||||
* @param file Excel文件
|
||||
*/
|
||||
static batchRecharge(file: File): Promise<BaseResponse> {
|
||||
return this.upload('/api/cards/batch-recharge', file)
|
||||
}
|
||||
|
||||
// ========== 换卡管理 ==========
|
||||
|
||||
/**
|
||||
* 获取换卡申请列表
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getCardChangeApplications(
|
||||
params?: any
|
||||
): Promise<PaginationResponse<CardChangeApplication>> {
|
||||
return this.getPage<CardChangeApplication>('/api/card-change-applications', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理换卡申请
|
||||
* @param params 处理参数
|
||||
*/
|
||||
static processCardChange(params: ProcessCardChangeParams): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>('/api/card-change-applications/process', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建换卡通知
|
||||
* @param iccids ICCID列表
|
||||
* @param reason 换卡原因
|
||||
*/
|
||||
static createCardChangeNotice(iccids: string[], reason: string): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>('/api/card-change-notices', { iccids, reason })
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取换卡通知记录
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getCardChangeNotices(params?: any): Promise<PaginationResponse<any>> {
|
||||
return this.getPage('/api/card-change-notices', params)
|
||||
}
|
||||
}
|
||||
22
src/api/modules/index.ts
Normal file
22
src/api/modules/index.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* API 服务模块统一导出
|
||||
*/
|
||||
|
||||
// 旧模块(待重构)
|
||||
export * from './article'
|
||||
|
||||
// 新模块
|
||||
export { AuthService } from './auth'
|
||||
export { RoleService } from './role'
|
||||
export { PermissionService } from './permission'
|
||||
export { AccountService } from './account'
|
||||
export { PlatformAccountService } from './platformAccount'
|
||||
export { ShopAccountService } from './shopAccount'
|
||||
export { ShopService } from './shop'
|
||||
export { CardService } from './card'
|
||||
|
||||
// TODO: 按需添加其他业务模块
|
||||
// export { PackageService } from './package'
|
||||
// export { DeviceService } from './device'
|
||||
// export { CommissionService } from './commission'
|
||||
// export { SettingService } from './setting'
|
||||
76
src/api/modules/permission.ts
Normal file
76
src/api/modules/permission.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* 权限相关 API - 匹配后端实际接口
|
||||
*/
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import type {
|
||||
Permission,
|
||||
PermissionTreeNode,
|
||||
PermissionQueryParams,
|
||||
CreatePermissionParams,
|
||||
UpdatePermissionParams,
|
||||
BaseResponse,
|
||||
PaginationResponse
|
||||
} from '@/types/api'
|
||||
|
||||
export class PermissionService extends BaseService {
|
||||
/**
|
||||
* 获取权限列表(分页)
|
||||
* GET /api/admin/permissions
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getPermissions(
|
||||
params?: PermissionQueryParams
|
||||
): Promise<PaginationResponse<Permission>> {
|
||||
return this.getPage<Permission>('/api/admin/permissions', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限树
|
||||
* GET /api/admin/permissions/tree
|
||||
* 用于角色分配权限时的树形选择
|
||||
*/
|
||||
static getPermissionTree(): Promise<BaseResponse<PermissionTreeNode[]>> {
|
||||
return this.get<BaseResponse<PermissionTreeNode[]>>('/api/admin/permissions/tree')
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限详情
|
||||
* GET /api/admin/permissions/{id}
|
||||
* @param id 权限ID
|
||||
*/
|
||||
static getPermission(id: number): Promise<BaseResponse<Permission>> {
|
||||
return this.getOne<Permission>(`/api/admin/permissions/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建权限
|
||||
* POST /api/admin/permissions
|
||||
* @param data 权限数据
|
||||
*/
|
||||
static createPermission(data: CreatePermissionParams): Promise<BaseResponse> {
|
||||
return this.create('/api/admin/permissions', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新权限
|
||||
* PUT /api/admin/permissions/{id}
|
||||
* @param id 权限ID
|
||||
* @param data 权限数据
|
||||
*/
|
||||
static updatePermission(
|
||||
id: number,
|
||||
data: UpdatePermissionParams
|
||||
): Promise<BaseResponse> {
|
||||
return this.update(`/api/admin/permissions/${id}`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除权限
|
||||
* DELETE /api/admin/permissions/{id}
|
||||
* @param id 权限ID
|
||||
*/
|
||||
static deletePermission(id: number): Promise<BaseResponse> {
|
||||
return this.remove(`/api/admin/permissions/${id}`)
|
||||
}
|
||||
}
|
||||
147
src/api/modules/platformAccount.ts
Normal file
147
src/api/modules/platformAccount.ts
Normal file
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* 平台账号相关 API - 匹配后端实际接口
|
||||
*/
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import type {
|
||||
PlatformAccountResponse,
|
||||
PlatformAccountQueryParams,
|
||||
CreatePlatformAccountParams,
|
||||
UpdatePlatformAccountParams,
|
||||
ChangePlatformAccountPasswordParams,
|
||||
AssignRolesParams,
|
||||
UpdateAccountStatusParams,
|
||||
PlatformAccountRoleResponse,
|
||||
BaseResponse,
|
||||
PaginationResponse
|
||||
} from '@/types/api'
|
||||
|
||||
export class PlatformAccountService extends BaseService {
|
||||
/**
|
||||
* 1. 获取平台账号列表
|
||||
* GET /api/admin/platform-accounts
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getPlatformAccounts(
|
||||
params?: PlatformAccountQueryParams
|
||||
): Promise<PaginationResponse<PlatformAccountResponse>> {
|
||||
return this.getPage<PlatformAccountResponse>('/api/admin/platform-accounts', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 2. 新增平台账号
|
||||
* POST /api/admin/platform-accounts
|
||||
* @param data 账号数据
|
||||
*/
|
||||
static createPlatformAccount(
|
||||
data: CreatePlatformAccountParams
|
||||
): Promise<BaseResponse<PlatformAccountResponse>> {
|
||||
return this.post<BaseResponse<PlatformAccountResponse>>(
|
||||
'/api/admin/platform-accounts',
|
||||
data
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 3. 移除角色
|
||||
* DELETE /api/admin/platform-accounts/{account_id}/roles/{role_id}
|
||||
* @param accountId 账号ID
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
static removeRoleFromPlatformAccount(
|
||||
accountId: number,
|
||||
roleId: number
|
||||
): Promise<BaseResponse> {
|
||||
return this.delete<BaseResponse>(
|
||||
`/api/admin/platform-accounts/${accountId}/roles/${roleId}`
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 4. 删除平台账号
|
||||
* DELETE /api/admin/platform-accounts/{id}
|
||||
* @param id 账号ID
|
||||
*/
|
||||
static deletePlatformAccount(id: number): Promise<BaseResponse> {
|
||||
return this.remove(`/api/admin/platform-accounts/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 5. 获取平台账号详情
|
||||
* GET /api/admin/platform-accounts/{id}
|
||||
* @param id 账号ID
|
||||
*/
|
||||
static getPlatformAccountDetail(
|
||||
id: number
|
||||
): Promise<BaseResponse<PlatformAccountResponse>> {
|
||||
return this.getOne<PlatformAccountResponse>(`/api/admin/platform-accounts/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 6. 编辑平台账号
|
||||
* PUT /api/admin/platform-accounts/{id}
|
||||
* @param id 账号ID
|
||||
* @param data 更新数据
|
||||
*/
|
||||
static updatePlatformAccount(
|
||||
id: number,
|
||||
data: UpdatePlatformAccountParams
|
||||
): Promise<BaseResponse<PlatformAccountResponse>> {
|
||||
return this.put<BaseResponse<PlatformAccountResponse>>(
|
||||
`/api/admin/platform-accounts/${id}`,
|
||||
data
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 7. 修改密码
|
||||
* PUT /api/admin/platform-accounts/{id}/password
|
||||
* @param id 账号ID
|
||||
* @param data 新密码
|
||||
*/
|
||||
static changePlatformAccountPassword(
|
||||
id: number,
|
||||
data: ChangePlatformAccountPasswordParams
|
||||
): Promise<BaseResponse> {
|
||||
return this.put<BaseResponse>(`/api/admin/platform-accounts/${id}/password`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 8. 获取账号角色
|
||||
* GET /api/admin/platform-accounts/{id}/roles
|
||||
* @param id 账号ID
|
||||
*/
|
||||
static getPlatformAccountRoles(
|
||||
id: number
|
||||
): Promise<BaseResponse<PlatformAccountRoleResponse[]>> {
|
||||
return this.get<BaseResponse<PlatformAccountRoleResponse[]>>(
|
||||
`/api/admin/platform-accounts/${id}/roles`
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 9. 分配角色
|
||||
* POST /api/admin/platform-accounts/{id}/roles
|
||||
* @param id 账号ID
|
||||
* @param data 角色ID列表
|
||||
*/
|
||||
static assignRolesToPlatformAccount(
|
||||
id: number,
|
||||
data: AssignRolesParams
|
||||
): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>(`/api/admin/platform-accounts/${id}/roles`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 10. 启用/禁用账号
|
||||
* PUT /api/admin/platform-accounts/{id}/status
|
||||
* @param id 账号ID
|
||||
* @param data 状态
|
||||
*/
|
||||
static updatePlatformAccountStatus(
|
||||
id: number,
|
||||
data: UpdateAccountStatusParams
|
||||
): Promise<BaseResponse> {
|
||||
return this.put<BaseResponse>(`/api/admin/platform-accounts/${id}/status`, data)
|
||||
}
|
||||
}
|
||||
104
src/api/modules/role.ts
Normal file
104
src/api/modules/role.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* 角色相关 API - 匹配后端实际接口
|
||||
*/
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import type {
|
||||
PlatformRole,
|
||||
RoleQueryParams,
|
||||
PlatformRoleFormData,
|
||||
PermissionTreeNode,
|
||||
BaseResponse,
|
||||
PaginationResponse
|
||||
} from '@/types/api'
|
||||
|
||||
export class RoleService extends BaseService {
|
||||
/**
|
||||
* 获取角色分页列表
|
||||
* GET /api/admin/roles
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getRoles(params?: RoleQueryParams): Promise<PaginationResponse<PlatformRole>> {
|
||||
return this.getPage<PlatformRole>('/api/admin/roles', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色详情
|
||||
* GET /api/admin/roles/{id}
|
||||
* @param id 角色ID
|
||||
*/
|
||||
static getRole(id: number): Promise<BaseResponse<PlatformRole>> {
|
||||
return this.getOne<PlatformRole>(`/api/admin/roles/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建角色
|
||||
* POST /api/admin/roles
|
||||
* @param data 角色数据
|
||||
*/
|
||||
static createRole(data: PlatformRoleFormData): Promise<BaseResponse> {
|
||||
return this.create('/api/admin/roles', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新角色
|
||||
* PUT /api/admin/roles/{id}
|
||||
* @param id 角色ID
|
||||
* @param data 角色数据
|
||||
*/
|
||||
static updateRole(id: number, data: PlatformRoleFormData): Promise<BaseResponse> {
|
||||
return this.update(`/api/admin/roles/${id}`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
* DELETE /api/admin/roles/{id}
|
||||
* @param id 角色ID
|
||||
*/
|
||||
static deleteRole(id: number): Promise<BaseResponse> {
|
||||
return this.remove(`/api/admin/roles/${id}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新角色状态
|
||||
* PUT /api/admin/roles/{id}/status
|
||||
* @param roleId 角色ID
|
||||
* @param status 状态 (0-禁用, 1-启用)
|
||||
*/
|
||||
static updateRoleStatus(roleId: number, status: 0 | 1): Promise<BaseResponse> {
|
||||
return this.put<BaseResponse>(`/api/admin/roles/${roleId}/status`, { status })
|
||||
}
|
||||
|
||||
// ========== 权限相关 ==========
|
||||
|
||||
/**
|
||||
* 获取角色权限
|
||||
* GET /api/admin/roles/{id}/permissions
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
static getRolePermissions(roleId: number): Promise<any> {
|
||||
return this.get<any>(`/api/admin/roles/${roleId}/permissions`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 分配权限给角色
|
||||
* POST /api/admin/roles/{id}/permissions
|
||||
* @param roleId 角色ID
|
||||
* @param permissionIds 权限ID列表
|
||||
*/
|
||||
static assignPermissions(roleId: number, permissionIds: number[]): Promise<BaseResponse> {
|
||||
return this.post<BaseResponse>(`/api/admin/roles/${roleId}/permissions`, {
|
||||
perm_ids: permissionIds
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除角色的单个权限
|
||||
* DELETE /api/admin/roles/{role_id}/permissions/{perm_id}
|
||||
* @param roleId 角色ID
|
||||
* @param permId 权限ID
|
||||
*/
|
||||
static removePermission(roleId: number, permId: number): Promise<BaseResponse> {
|
||||
return this.delete<BaseResponse>(`/api/admin/roles/${roleId}/permissions/${permId}`)
|
||||
}
|
||||
}
|
||||
52
src/api/modules/shop.ts
Normal file
52
src/api/modules/shop.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 店铺相关 API - 匹配后端实际接口
|
||||
*/
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import type {
|
||||
ShopResponse,
|
||||
ShopQueryParams,
|
||||
CreateShopParams,
|
||||
UpdateShopParams,
|
||||
BaseResponse,
|
||||
PaginationResponse
|
||||
} from '@/types/api'
|
||||
|
||||
export class ShopService extends BaseService {
|
||||
/**
|
||||
* 获取店铺列表
|
||||
* GET /api/admin/shops
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getShops(params?: ShopQueryParams): Promise<PaginationResponse<ShopResponse>> {
|
||||
return this.getPage<ShopResponse>('/api/admin/shops', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建店铺
|
||||
* POST /api/admin/shops
|
||||
* @param data 店铺数据
|
||||
*/
|
||||
static createShop(data: CreateShopParams): Promise<BaseResponse<ShopResponse>> {
|
||||
return this.post<BaseResponse<ShopResponse>>('/api/admin/shops', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新店铺
|
||||
* PUT /api/admin/shops/{id}
|
||||
* @param id 店铺ID
|
||||
* @param data 更新数据
|
||||
*/
|
||||
static updateShop(id: number, data: UpdateShopParams): Promise<BaseResponse<ShopResponse>> {
|
||||
return this.put<BaseResponse<ShopResponse>>(`/api/admin/shops/${id}`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除店铺
|
||||
* DELETE /api/admin/shops/{id}
|
||||
* @param id 店铺ID
|
||||
*/
|
||||
static deleteShop(id: number): Promise<BaseResponse> {
|
||||
return this.delete<BaseResponse>(`/api/admin/shops/${id}`)
|
||||
}
|
||||
}
|
||||
76
src/api/modules/shopAccount.ts
Normal file
76
src/api/modules/shopAccount.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* 代理账号相关 API - 匹配后端实际接口
|
||||
*/
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import type {
|
||||
ShopAccountResponse,
|
||||
ShopAccountQueryParams,
|
||||
CreateShopAccountParams,
|
||||
UpdateShopAccountParams,
|
||||
UpdateShopAccountPasswordParams,
|
||||
UpdateShopAccountStatusParams,
|
||||
BaseResponse,
|
||||
PaginationResponse
|
||||
} from '@/types/api'
|
||||
|
||||
export class ShopAccountService extends BaseService {
|
||||
/**
|
||||
* 获取代理账号列表
|
||||
* GET /api/admin/shop-accounts
|
||||
* @param params 查询参数
|
||||
*/
|
||||
static getShopAccounts(
|
||||
params?: ShopAccountQueryParams
|
||||
): Promise<PaginationResponse<ShopAccountResponse>> {
|
||||
return this.getPage<ShopAccountResponse>('/api/admin/shop-accounts', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建代理账号
|
||||
* POST /api/admin/shop-accounts
|
||||
* @param data 代理账号数据
|
||||
*/
|
||||
static createShopAccount(data: CreateShopAccountParams): Promise<BaseResponse<ShopAccountResponse>> {
|
||||
return this.post<BaseResponse<ShopAccountResponse>>('/api/admin/shop-accounts', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新代理账号
|
||||
* PUT /api/admin/shop-accounts/{id}
|
||||
* @param id 账号ID
|
||||
* @param data 更新数据
|
||||
*/
|
||||
static updateShopAccount(
|
||||
id: number,
|
||||
data: UpdateShopAccountParams
|
||||
): Promise<BaseResponse<ShopAccountResponse>> {
|
||||
return this.put<BaseResponse<ShopAccountResponse>>(`/api/admin/shop-accounts/${id}`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置代理账号密码
|
||||
* PUT /api/admin/shop-accounts/{id}/password
|
||||
* @param id 账号ID
|
||||
* @param data 密码数据
|
||||
*/
|
||||
static updateShopAccountPassword(
|
||||
id: number,
|
||||
data: UpdateShopAccountPasswordParams
|
||||
): Promise<BaseResponse> {
|
||||
return this.put<BaseResponse>(`/api/admin/shop-accounts/${id}/password`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用/禁用代理账号
|
||||
* PUT /api/admin/shop-accounts/{id}/status
|
||||
* @param id 账号ID
|
||||
* @param data 状态数据
|
||||
*/
|
||||
static updateShopAccountStatus(
|
||||
id: number,
|
||||
data: UpdateShopAccountStatusParams
|
||||
): Promise<BaseResponse> {
|
||||
return this.put<BaseResponse>(`/api/admin/shop-accounts/${id}/status`, data)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user