/** * 企业客户管理 API */ import { BaseService } from '../BaseService' import type { BaseResponse } from '@/types/api' import type { EnterpriseItem, EnterprisePageResult, EnterpriseQueryParams, CreateEnterpriseParams, UpdateEnterpriseParams, UpdateEnterprisePasswordParams, UpdateEnterpriseStatusParams, CreateEnterpriseResponse } from '@/types/api/enterprise' import type { AllocateCardsRequest, AllocateCardsResponse, AllocateCardsPreviewRequest, AllocateCardsPreviewResponse, EnterpriseCardListParams, EnterpriseCardPageResult, RecallCardsRequest, RecallCardsResponse } from '@/types/api/enterpriseCard' import type { EnterpriseDeviceListParams, EnterpriseDevicePageResult, AllocateDevicesRequest, AllocateDevicesResponse, RecallDevicesRequest, RecallDevicesResponse } from '@/types/api/enterpriseDevice' export class EnterpriseService extends BaseService { /** * 查询企业客户列表 */ static getEnterprises( params?: EnterpriseQueryParams ): Promise> { return this.get>('/api/admin/enterprises', params) } /** * 新增企业客户 */ static createEnterprise( data: CreateEnterpriseParams ): Promise> { return this.post>('/api/admin/enterprises', data) } /** * 编辑企业信息 */ static updateEnterprise( id: number, data: UpdateEnterpriseParams ): Promise> { return this.put>(`/api/admin/enterprises/${id}`, data) } /** * 修改企业账号密码 */ static updateEnterprisePassword( id: number, data: UpdateEnterprisePasswordParams ): Promise { return this.put(`/api/admin/enterprises/${id}/password`, data) } /** * 启用/禁用企业 */ static updateEnterpriseStatus( id: number, data: UpdateEnterpriseStatusParams ): Promise { return this.put(`/api/admin/enterprises/${id}/status`, data) } // ========== 企业卡授权相关 ========== /** * 授权卡给企业 * @param enterpriseId 企业ID * @param data 授权请求数据 */ static allocateCards( enterpriseId: number, data: AllocateCardsRequest ): Promise> { return this.post>( `/api/admin/enterprises/${enterpriseId}/allocate-cards`, data ) } /** * 卡授权预检 * @param enterpriseId 企业ID * @param data 预检请求数据 */ static previewAllocateCards( enterpriseId: number, data: AllocateCardsPreviewRequest ): Promise> { return this.post>( `/api/admin/enterprises/${enterpriseId}/allocate-cards/preview`, data ) } /** * 获取企业卡列表 * @param enterpriseId 企业ID * @param params 查询参数 */ static getEnterpriseCards( enterpriseId: number, params?: EnterpriseCardListParams ): Promise> { return this.get>( `/api/admin/enterprises/${enterpriseId}/cards`, params ) } /** * 复机卡 * @param enterpriseId 企业ID * @param cardId 卡ID */ static resumeCard(enterpriseId: number, cardId: number): Promise { return this.post(`/api/admin/enterprises/${enterpriseId}/cards/${cardId}/resume`) } /** * 停机卡 * @param enterpriseId 企业ID * @param cardId 卡ID */ static suspendCard(enterpriseId: number, cardId: number): Promise { return this.post(`/api/admin/enterprises/${enterpriseId}/cards/${cardId}/suspend`) } /** * 回收卡授权 * @param enterpriseId 企业ID * @param data 回收请求数据 */ static recallCards( enterpriseId: number, data: RecallCardsRequest ): Promise> { return this.post>( `/api/admin/enterprises/${enterpriseId}/recall-cards`, data ) } // ========== 企业设备授权相关 ========== /** * 授权设备给企业 * @param enterpriseId 企业ID * @param data 授权请求数据 */ static allocateDevices( enterpriseId: number, data: AllocateDevicesRequest ): Promise> { return this.post>( `/api/admin/enterprises/${enterpriseId}/allocate-devices`, data ) } /** * 获取企业设备列表 * @param enterpriseId 企业ID * @param params 查询参数 */ static getEnterpriseDevices( enterpriseId: number, params?: EnterpriseDeviceListParams ): Promise> { return this.get>( `/api/admin/enterprises/${enterpriseId}/devices`, params ) } /** * 撤销设备授权 * @param enterpriseId 企业ID * @param data 撤销请求数据 */ static recallDevices( enterpriseId: number, data: RecallDevicesRequest ): Promise> { return this.post>( `/api/admin/enterprises/${enterpriseId}/recall-devices`, data ) } }