feat: CRUD leave
This commit is contained in:
parent
2b24e43522
commit
c13ca10a3e
1 changed files with 105 additions and 7 deletions
|
|
@ -13,11 +13,16 @@ import {
|
||||||
Tags,
|
Tags,
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { CreateProfileLeave, ProfileLeave, UpdateProfileLeave } from "../entities/ProfileLeave";
|
import {
|
||||||
|
ProfileLeaveHistory,
|
||||||
|
CreateProfileLeave,
|
||||||
|
ProfileLeave,
|
||||||
|
UpdateProfileLeave,
|
||||||
|
} from "../entities/ProfileLeave";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { ProfileLeaveHistory } from "../entities/ProfileLeaveHistory";
|
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { Profile } from "../entities/Profile";
|
import { Profile } from "../entities/Profile";
|
||||||
|
|
||||||
|
|
@ -33,10 +38,41 @@ export class ProfileLeaveController extends Controller {
|
||||||
@Example({
|
@Example({
|
||||||
status: 200,
|
status: 200,
|
||||||
message: "สำเร็จ",
|
message: "สำเร็จ",
|
||||||
result: [],
|
result: {
|
||||||
|
id: "adbb08a6-d2f4-41b0-a9c1-49e883ca96bc",
|
||||||
|
createdAt: "2024-03-20T23:35:45.230Z",
|
||||||
|
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||||
|
lastUpdatedAt: "2024-03-20T23:40:06.000Z",
|
||||||
|
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||||
|
createdFullName: "สาวิตรี ศรีสมัย",
|
||||||
|
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||||
|
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
||||||
|
leaveTypeId: "8dc5e672-b416-4323-b086-06dde8c4353c",
|
||||||
|
dateLeave: "2024-03-21T06:39:46.000Z",
|
||||||
|
leaveDays: 0,
|
||||||
|
leaveCount: null,
|
||||||
|
totalLeave: 0,
|
||||||
|
status: "string",
|
||||||
|
reason: "string",
|
||||||
|
leaveType: {
|
||||||
|
id: "8dc5e672-b416-4323-b086-06dde8c4353c",
|
||||||
|
createdAt: "2024-02-04T21:28:40.536Z",
|
||||||
|
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||||
|
lastUpdatedAt: "2024-02-04T21:28:40.536Z",
|
||||||
|
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||||
|
createdFullName: "สาวิตรี ศรีสมัย",
|
||||||
|
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||||
|
name: "ลาป่วย",
|
||||||
|
code: "CM-002",
|
||||||
|
limit: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
public async getLeave(@Path() profileId: string) {
|
public async getLeave(@Path() profileId: string) {
|
||||||
const record = await this.leaveRepo.findBy({ profileId });
|
const record = await this.leaveRepo.findOne({
|
||||||
|
relations: { leaveType: true },
|
||||||
|
where: { profileId },
|
||||||
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,11 +80,73 @@ export class ProfileLeaveController extends Controller {
|
||||||
@Example({
|
@Example({
|
||||||
status: 200,
|
status: 200,
|
||||||
message: "สำเร็จ",
|
message: "สำเร็จ",
|
||||||
result: [],
|
result: [
|
||||||
|
{
|
||||||
|
id: "7eed2e72-d71c-4b3b-a90b-e1b7abdaa838",
|
||||||
|
createdAt: "2024-03-20T23:35:45.230Z",
|
||||||
|
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||||
|
lastUpdatedAt: "2024-03-20T23:40:06.000Z",
|
||||||
|
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||||
|
createdFullName: "สาวิตรี ศรีสมัย",
|
||||||
|
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||||
|
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
||||||
|
leaveTypeId: "8dc5e672-b416-4323-b086-06dde8c4353c",
|
||||||
|
dateLeave: "2024-03-21T06:39:46.000Z",
|
||||||
|
leaveDays: 0,
|
||||||
|
leaveCount: null,
|
||||||
|
totalLeave: 0,
|
||||||
|
status: "string",
|
||||||
|
reason: "string",
|
||||||
|
leaveType: {
|
||||||
|
id: "8dc5e672-b416-4323-b086-06dde8c4353c",
|
||||||
|
createdAt: "2024-02-04T21:28:40.536Z",
|
||||||
|
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||||
|
lastUpdatedAt: "2024-02-04T21:28:40.536Z",
|
||||||
|
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||||
|
createdFullName: "สาวิตรี ศรีสมัย",
|
||||||
|
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||||
|
name: "ลาป่วย",
|
||||||
|
code: "CM-002",
|
||||||
|
limit: 1,
|
||||||
|
},
|
||||||
|
profileLeaveId: "adbb08a6-d2f4-41b0-a9c1-49e883ca96bc",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "b1b9c291-9c96-4cbb-9309-6ff5a2a6e0e8",
|
||||||
|
createdAt: "2024-03-20T23:35:45.230Z",
|
||||||
|
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||||
|
lastUpdatedAt: "2024-03-20T23:35:45.230Z",
|
||||||
|
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||||
|
createdFullName: "สาวิตรี ศรีสมัย",
|
||||||
|
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||||
|
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
||||||
|
leaveTypeId: "7dc4e314-b456-4323-b086-06dde8c4353c",
|
||||||
|
dateLeave: "2024-03-21T06:34:49.000Z",
|
||||||
|
leaveDays: 2,
|
||||||
|
leaveCount: null,
|
||||||
|
totalLeave: 200,
|
||||||
|
status: "ไม่ผ่าน",
|
||||||
|
reason: "ติดงานสำคัญ",
|
||||||
|
leaveType: {
|
||||||
|
id: "7dc4e314-b456-4323-b086-06dde8c4353c",
|
||||||
|
createdAt: "2024-02-04T21:28:40.536Z",
|
||||||
|
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||||
|
lastUpdatedAt: "2024-02-04T21:28:40.536Z",
|
||||||
|
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||||
|
createdFullName: "สาวิตรี ศรีสมัย",
|
||||||
|
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||||
|
name: "ลาพักร้อน",
|
||||||
|
code: "CM-001",
|
||||||
|
limit: 356,
|
||||||
|
},
|
||||||
|
profileLeaveId: "adbb08a6-d2f4-41b0-a9c1-49e883ca96bc",
|
||||||
|
},
|
||||||
|
],
|
||||||
})
|
})
|
||||||
public async leaveHistory(@Path() leaveId: string) {
|
public async leaveHistory(@Path() leaveId: string) {
|
||||||
const record = await this.leaveHistoryRepo.findBy({
|
const record = await this.leaveHistoryRepo.find({
|
||||||
profileLeaveId: leaveId,
|
relations: { leaveType: true },
|
||||||
|
where: { profileLeaveId: leaveId },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue