Files
one-pipe-system/src/api/modules/phoneAsset.ts
2026-09-17 12:16:20 +08:00

108 lines
3.3 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.
/**
* 手机号资产关联相关 API
* 契约来源docs/产品迭代8月份/手机号资产关联.md
*/
import { BaseService } from '../BaseService'
import type {
BaseResponse,
PhoneAssetAssociationListResponse,
PhoneAssetAssociationQueryParams,
BatchUnbindPhoneAssetAssociationRequest,
BatchUnbindPhoneAssetAssociationResponse,
CreatePhoneAssetUnbindImportRequest,
PhoneAssetUnbindImportTask,
PhoneAssetUnbindImportTaskDetail,
PhoneAssetUnbindImportTaskListResponse,
PhoneAssetUnbindImportTaskQueryParams,
UnbindPhoneAssetAssociationResponse
} from '@/types/api'
/**
* 手机号资产关联服务
* 仅超级管理员和平台账号可访问,代理/企业/个人由后端 403 兜底。
*/
export class PhoneAssetAssociationService extends BaseService {
/**
* 查询手机号资产关联列表(分页)
* GET /api/admin/phone-asset-associations
*/
static getAssociations(
params?: PhoneAssetAssociationQueryParams
): Promise<BaseResponse<PhoneAssetAssociationListResponse>> {
return this.get<BaseResponse<PhoneAssetAssociationListResponse>>(
'/api/admin/phone-asset-associations',
params
)
}
/**
* 解除单条手机号资产关联
* DELETE /api/admin/phone-asset-associations/{id}
*
* 注意接口文档未定义请求体reason 与 confirmed 当前按查询参数传递;
* 联调时若后端以 JSON body 接收,需调整为请求体方式。
*/
static unbindAssociation(
id: number,
reason: string,
confirmed: boolean
): Promise<BaseResponse<UnbindPhoneAssetAssociationResponse>> {
return this.delete<BaseResponse<UnbindPhoneAssetAssociationResponse>>(
`/api/admin/phone-asset-associations/${id}`,
{ reason, confirmed }
)
}
/**
* 按资产批量解除手机号关联
* POST /api/admin/phone-asset-associations/batch-unbind
*/
static batchUnbind(
data: BatchUnbindPhoneAssetAssociationRequest
): Promise<BaseResponse<BatchUnbindPhoneAssetAssociationResponse>> {
return this.post<BaseResponse<BatchUnbindPhoneAssetAssociationResponse>>(
'/api/admin/phone-asset-associations/batch-unbind',
data
)
}
/**
* 创建 CSV 解绑导入任务
* POST /api/admin/phone-asset-associations/unbind-imports
*/
static createUnbindImport(
data: CreatePhoneAssetUnbindImportRequest
): Promise<BaseResponse<PhoneAssetUnbindImportTask>> {
return this.post<BaseResponse<PhoneAssetUnbindImportTask>>(
'/api/admin/phone-asset-associations/unbind-imports',
data
)
}
/**
* 查询解绑导入任务列表(分页)
* GET /api/admin/phone-asset-associations/unbind-imports
*/
static getUnbindImportTasks(
params?: PhoneAssetUnbindImportTaskQueryParams
): Promise<BaseResponse<PhoneAssetUnbindImportTaskListResponse>> {
return this.get<BaseResponse<PhoneAssetUnbindImportTaskListResponse>>(
'/api/admin/phone-asset-associations/unbind-imports',
params
)
}
/**
* 查询解绑导入任务详情
* GET /api/admin/phone-asset-associations/unbind-imports/{id}
*/
static getUnbindImportTaskDetail(
id: number
): Promise<BaseResponse<PhoneAssetUnbindImportTaskDetail>> {
return this.getOne<PhoneAssetUnbindImportTaskDetail>(
`/api/admin/phone-asset-associations/unbind-imports/${id}`
)
}
}