wangzhibo
7 天以前 665ba0f9ae078c2859209451a163d10515171d11
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
42
43
44
45
46
47
48
49
50
51
52
53
import { Inject } from "@midwayjs/core";
import { CoolController, BaseController } from "@cool-midway/core";
import { RecycleAppointmentEntity } from "../../entity/recycleappointment";
import { RecycleAppointmentService } from "../../service/recycleappointment";
import { BaseSysDepartmentEntity } from "../../../base/entity/sys/department";
import { BasicdataSorterEntity } from "../../../basicdata/entity/sorter";
import { WithDeptFilterWhere } from '../../../base/middleware/with-dept-filter-where'
 
 
/**
 * 预约管理
 */
@CoolController({
    api: ["add", "delete", "update", "info", "list", "page"],
    entity: RecycleAppointmentEntity,
    service: RecycleAppointmentService,
    pageQueryOp: {
        keyWordLikeFields: ["a.appointmentNo", "a.contactName", "a.contactPhone"],
        fieldEq: ["a.status", "a.departmentId", "a.sorterId"],
        select: [
            "a.*",
            "b.name AS departmentName",
            "c.businessName AS sorterName"
        ],
        join: [
            {
                entity: BaseSysDepartmentEntity,
                alias: "b",
                condition: "a.departmentId = b.id",
                type: "leftJoin"
            },
            {
                entity: BasicdataSorterEntity,
                alias: "c",
                condition: "a.sorterId = c.businessId",
                type: "leftJoin"
            }
        ],
        where: async (ctx) => {
            const { startDate, endDate } = ctx.request.body;
            const conditions: any[][] = [];
            if (startDate && endDate) {
                conditions.push(["a.appointmentDate BETWEEN :startDate AND :endDate", { startDate, endDate }]);
            }
            conditions.push(...(await WithDeptFilterWhere(ctx, { alias: 'a', field: 'departmentId' })));
            return conditions;
        }
    }
})
export class AdminRecycleAppointmentController extends BaseController {
    @Inject()
    recycleAppointmentService: RecycleAppointmentService;
}