wangzhibo
6 天以前 3f249e399659dcd09d3fe58071b146e50e45c17f
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
import { CoolController, BaseController } from '@cool-midway/core';
import { Inject } from '@midwayjs/core';
import { RecycleItemEntity } from '../../entity/recycleitem';
import { RecycleItemService } from '../../service/recycleitem';
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: RecycleItemEntity,
  service: RecycleItemService,
  pageQueryOp: {
    keyWordLikeFields: ['a.name'],
    fieldEq: ['a.itemId', 'a.category', 'a.status'],
    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' })));
      return conditions;
    }
  },
})
export class RecycleItemController extends BaseController {
  @Inject()
  recycleItemService: RecycleItemService;
}