import { ApiClientFactory } from '../core/api.client.factory'; import { MaterialItemModel, GroupModel } from '../model/MaterialManage.model'; export class MaterialManageService { constructor(private factory: ApiClientFactory) {} /** * @name 媒资列表 * @param projectId */ async fetchList(projectId: string) { const url = `/api/media/asset/list?projectId=${projectId}`; const result = await this.factory.entity.get(url); return result; } /** * @name 修改/添加 * @param params */ async update(params: MaterialItemModel) { const url = `/api/media/asset`; const result = await this.factory.entity.post(url, params); return result; } /** * @name 删除 * @param projectId */ async delete(projectId: string, ids: string[]) { const url = `/api/media/asset/deleteByIds`; const result = await this.factory.entity.delete(url, { projectId, ids, }); return result; } /** * @name 分组列表 * @param projectId */ async fetchGroupList(projectId: string) { const url = `/api/media/group/list?projectId=${projectId}`; const result = await this.factory.entity.get(url); return result; } /** * @name 分组添加/修改 * @param params */ async updateGroup(params: GroupModel) { const url = `/api/media/group`; const result = await this.factory.entity.post(url, params); return result; } /** * @name 删除分组 * @param id */ async deleteGroup(id: string) { const url = `/api/media/group/${id}`; const result = await this.factory.entity.delete(url); return result; } /** * @name 批量移到分组 * @param id */ async changeGroup(projectId: string, groupId: string, ids: string[]) { const url = `/api/media/asset/changeGroup`; const result = await this.factory.entity.post(url, { projectId, ids, groupId, }); return result; } }