wangzhibo
4 天以前 c19f1f7e21c93d1f13b4f44a8a615f65af577559
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
51
52
53
54
55
56
57
import { CoolController, BaseController } from '@cool-midway/core';
import { PushSiteweightEntity } from '../../entity/siteweight';
import { PushSiteweightService } from '../../service/siteweight';
import { BaseSysDepartmentEntity } from '../../../base/entity/sys/department';
import {BasicdataWastetypeEntity} from '../../../basicdata/entity/wastetype'
import { BasicdataSiteEntity } from '../../../basicdata/entity/site';
import { WithDeptFilterWhere } from '../../../base/middleware/with-dept-filter-where'
 
/**
 * 业务称重数据管理
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: PushSiteweightEntity,
  service: PushSiteweightService,
  pageQueryOp: {
     select: [
      'a.*',
      'b.name AS departmentName',
      'c.name AS garbageName',   // 垃圾名称
      'd.businessName AS businessName', 'd.siteType AS siteType',  // 垃圾名称
      
    ],
    fieldEq: ['a.deviceNo','d.siteType'],
    fieldLike: ['a.deviceNo'],
    join: [
      {
        entity: BaseSysDepartmentEntity,
        alias: 'b',
        condition: 'a.departmentId = b.id',
        type: 'leftJoin',
      },
      {
        entity: BasicdataWastetypeEntity,
        alias: 'c',
        condition: 'a.garbageType = c.code',   
        type: 'leftJoin',
      },
      {
        entity: BasicdataSiteEntity,
        alias: 'd',
        condition: 'a.businessId = d.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 AdminPushSiteweightController extends BaseController {}