import { CoolController, BaseController } from '@cool-midway/core';
|
import { ReportDailysiteEntity } from '../../entity/dailysite';
|
import { ReportDailysiteService } from '../../service/dailysite';
|
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: ReportDailysiteEntity,
|
service: ReportDailysiteService,
|
pageQueryOp: {
|
keyWordLikeFields: ['a.siteName'],
|
fieldEq: ['a.date', 'a.siteId', 'a.departmentId'],
|
select: ['a.*', 'b.name AS departmentName'],
|
join: [
|
{
|
entity: BaseSysDepartmentEntity,
|
alias: 'b',
|
condition: 'a.departmentId = b.id',
|
type: 'leftJoin',
|
},
|
],
|
|
where: async (ctx) => {
|
const { startTime, endTime } = ctx.request.body;
|
const conditions: any[][] = [];
|
if (startTime && endTime) {
|
conditions.push(['a.date BETWEEN :startTime AND :endTime', { startTime, endTime }]);
|
}
|
conditions.push(...(await WithDeptFilterWhere(ctx, { alias: 'a', field: 'departmentId' })));
|
return conditions;
|
}
|
}
|
})
|
export class AdminReportDailysiteController extends BaseController { }
|