108 lines
3.3 KiB
TypeScript
108 lines
3.3 KiB
TypeScript
/**
|
||
* 手机号资产关联相关 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}`
|
||
)
|
||
}
|
||
}
|