wangzhibo
2026-07-18 708f980f0f351bfe47d7936151bf52ed4d4a7bc4
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
38
39
40
41
42
43
44
45
46
47
48
49
50
import { CoolController, BaseController } from '@cool-midway/core';
import { BasicdataSorterEntity } from '../../entity/sorter';
import { BasicdataSorterService } from '../../service/sorter';
import { BaseSysDepartmentEntity } from '../../../base/entity/sys/department';
import { BasicdataSiteEntity } from '../../entity/site';
import { WithDeptFilterWhere } from '../../../base/middleware/with-dept-filter-where'
 
/**
 * 分拣人员后台管理
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: BasicdataSorterEntity,
  service: BasicdataSorterService,
  pageQueryOp: {
    keyWordLikeFields: ['a.businessName', 'a.businessId', 'a.phone'],
    fieldEq: ['a.status', 'a.departmentId', 'a.siteId'],
 
    select: [
      'a.*',
      'b.name AS departmentName',
      'c.businessName AS workSiteName',   // ✅ 站点名称
    ],
 
    join: [
      {
        entity: BaseSysDepartmentEntity,
        alias: 'b',
        condition: 'a.departmentId = b.id',
        type: 'leftJoin',
      },
      {
        entity: BasicdataSiteEntity,
        alias: 'c',
        condition: 'a.workSiteId = c.businessId',
        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 AdminBasicdataSorterController extends BaseController { }