wangrong
2026-07-25 a97d3b4a19c0fc7586bd02f5b51f609904d5cf15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { CoolController, BaseController } from '@cool-midway/core';
import { BasicdataBuyerEntity } from '../../entity/buyer';
import { BasicdataBuyerService } from '../../service/buyer';
import { BaseSysDepartmentEntity } from '../../../base/entity/sys/department';
import { WithDeptFilterWhere } from '../../../base/middleware/with-dept-filter-where'
 
/**
 * 购买方管理
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: BasicdataBuyerEntity,
  service: BasicdataBuyerService,
  pageQueryOp: {
    fieldEq: ['a.departmentId', 'a.name', 'a.contact'],
    fieldLike: ['a.name', 'a.address'],
    select: ['a.*', 'b.name AS departmentName'],
    join: [
      {
        entity: BaseSysDepartmentEntity,
        alias: 'b',
        condition: 'a.departmentId = b.id',
        type: 'leftJoin',
      },
    ],
    where: async ctx => {
      const conditions: any[][] = [];
      conditions.push(...(await WithDeptFilterWhere(ctx, { alias: 'a', field: 'departmentId' })));
 
      // 其他关联表(举例)
      // conditions.push(...(await deptFilterWhere(ctx, 'd', 'id')));
 
      return conditions;
    },
  },
})
export class AdminOperationBuyerController extends BaseController { }