import { CoolController, BaseController } from '@cool-midway/core';
import { PushWeightEntity } from '../../entity/weight';
import { PushWeightService } from '../../service/weight';

/**
 * 原始称重数据管理
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: PushWeightEntity,
  service: PushWeightService,
  pageQueryOp: {
    select: ['a.*'],
    fieldEq: ['a.deviceNo', 'a.garbageType'],
    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 {}
