import { Inject } from '@midwayjs/core';
|
import { CoolController, BaseController } from '@cool-midway/core';
|
import { PushVehicleGpsEntity } from '../../entity/vehiclegps';
|
import { PushVehicleGpsService } from '../../service/vehiclegps';
|
import { BaseSysDepartmentEntity } from '../../../base/entity/sys/department'
|
import { WithDeptFilterWhere } from '../../../base/middleware/with-dept-filter-where'
|
|
/**
|
* 车载监控GPS位置数据
|
*/
|
@CoolController({
|
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
|
entity: PushVehicleGpsEntity,
|
service: PushVehicleGpsService,
|
pageQueryOp: {
|
keyWordLikeFields: ['a.sn', 'a.vehicleNo'],
|
fieldEq: ['a.status'],
|
select: ['a.*', 'b.name AS departmentName'],
|
join: [
|
{
|
entity: BaseSysDepartmentEntity,
|
alias: 'b',
|
condition: 'a.departmentId = b.id',
|
type: 'leftJoin',
|
},
|
],
|
where: async (ctx) => {
|
const { createDate, gpsTime } = ctx.request.body;
|
const conditions: any[][] = [];
|
if (createDate && createDate.length === 2) {
|
conditions.push(['a.createDate BETWEEN :createStartDate AND :createEndDate', { createStartDate: createDate[0], createEndDate: createDate[1] }]);
|
}
|
if (gpsTime && gpsTime.length === 2) {
|
conditions.push(['a.gpsTime BETWEEN :gpsStartDate AND :gpsEndDate', { gpsStartDate: gpsTime[0], gpsEndDate: gpsTime[1] }]);
|
}
|
|
conditions.push(...(await WithDeptFilterWhere(ctx, { alias: 'a', field: 'departmentId' })));
|
|
return conditions;
|
}
|
}
|
})
|
export class AdminPushVehicleGpsController extends BaseController {
|
@Inject()
|
pushVehicleGpsService: PushVehicleGpsService;
|
}
|