演示

BranchService

公司分支 — 创建、列表、更新、默认分支与 Spotlight 搜索。

注入

TSXinject
1import { 2 ContainerRegistryManager, 3 BranchService, 4 Inject, 5 Service, 6} from "@quan-erp/shared-backend-core"; 7 8@Service() 9export class MyPluginService { 10 @Inject(BranchService, ContainerRegistryManager.BUILTIN_PLUGIN) 11 private branchService: BranchService; 12}

查询方法

  • getById(id) — 按 id 取分支
  • get({ skip?, limit?, search? }) — 分页搜索
  • sportlightSearch(dto, user) — Spotlight(拼写与源码一致)
TSXlookup
1import { 2 BranchService, 3 ContainerRegistryManager, 4 Inject, 5 Service, 6} from "@quan-erp/shared-backend-core"; 7 8@Service() 9export class BranchLookupService { 10 @Inject(BranchService, ContainerRegistryManager.BUILTIN_PLUGIN) 11 private branchService: BranchService; 12 13 async list(search?: string) { 14 return this.branchService.get({ skip: 0, limit: 50, search }); 15 } 16}

创建 / 更新 / 默认

  • create(params) — 创建分支
  • update(id, data, updatedByUserId?) — 更新
  • markDefault(id, userId) — 设为系统默认分支
TSXcreate
1import { 2 BranchService, 3 ContainerRegistryManager, 4 Inject, 5 Service, 6} from "@quan-erp/shared-backend-core"; 7 8@Service() 9export class BranchAdminService { 10 @Inject(BranchService, ContainerRegistryManager.BUILTIN_PLUGIN) 11 private branchService: BranchService; 12 13 async openBranch(createdByUserId: number) { 14 return this.branchService.create({ 15 createdByUserId, 16 data: { 17 id: 0, 18 name: "Downtown", 19 city: "Yangon", 20 country: "MM", 21 }, 22 }); 23 } 24 25 async makeDefault(branchId: number, userId: number) { 26 await this.branchService.markDefault(branchId, userId); 27 } 28}