wangrong
8 天以前 cd35d65daa2fb81ebb04823f045e6baf68eaddde
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 { PushWeightEntity } from '../../entity/weight';
import { PushWeightService } from '../../service/weight';
import { BasicdataWastetypeEntity } from '../../../basicdata/entity/wastetype';
 
/**
 * 原始称重数据管理
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: PushWeightEntity,
  service: PushWeightService,
  pageQueryOp: {
    select: ['a.*', 'b.name AS garbageName'],
    fieldEq: ['a.deviceNo', 'a.garbageType'],
    join: [
      {
        entity: BasicdataWastetypeEntity,
        alias: 'b',
        condition: 'a.garbageType = b.code',
        type: 'leftJoin',
      },
    ],
    where: async ctx => {
      const { startTime, endTime } = ctx.request.body;
      const conditions = [];
      if (startTime && endTime) {
        conditions.push([
          'a.uploadTime BETWEEN :startTime AND :endTime',
          { startTime, endTime },
        ]);
      }
      return conditions;
    },
  },
})
export class AdminPushWeightController extends BaseController {}