แก้ วันที่ update
This commit is contained in:
parent
6d36c9b05f
commit
218886b3f4
83 changed files with 1671 additions and 3483 deletions
|
|
@ -2,7 +2,6 @@ import {
|
|||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Example,
|
||||
Get,
|
||||
Patch,
|
||||
Path,
|
||||
|
|
@ -41,103 +40,32 @@ export class ProfileTrainingController extends Controller {
|
|||
}
|
||||
const record = await this.trainingRepo.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
result: [
|
||||
{
|
||||
id: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
||||
createdAt: "2024-03-12T02:55:56.915Z",
|
||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
lastUpdatedAt: "2024-03-12T02:55:56.915Z",
|
||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
createdFullName: "สาวิตรี ศรีสมัย",
|
||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
||||
isActive: true,
|
||||
startDate: "2024-03-12T09:55:23.000Z",
|
||||
endDate: "2024-03-12T09:55:23.000Z",
|
||||
numberOrder: "string",
|
||||
topic: "string",
|
||||
place: "string",
|
||||
dateOrder: "2024-03-12T09:55:23.000Z",
|
||||
department: "string",
|
||||
duration: "string",
|
||||
name: "string",
|
||||
yearly: 0,
|
||||
isDate: true,
|
||||
},
|
||||
],
|
||||
})
|
||||
public async getTraining(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const record = await this.trainingRepo.findBy({ profileId });
|
||||
const record = await this.trainingRepo.find({
|
||||
where: { profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Get("history/{trainingId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
result: [
|
||||
{
|
||||
id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d",
|
||||
createdAt: "2024-03-12T02:55:56.971Z",
|
||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
lastUpdatedAt: "2024-03-12T02:55:56.971Z",
|
||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
createdFullName: "สาวิตรี ศรีสมัย",
|
||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||
isActive: true,
|
||||
startDate: "2024-03-12T09:55:23.000Z",
|
||||
endDate: "2024-03-12T09:55:23.000Z",
|
||||
numberOrder: "string",
|
||||
topic: "string",
|
||||
place: "string",
|
||||
dateOrder: "2024-03-12T09:55:23.000Z",
|
||||
department: "string",
|
||||
duration: "string",
|
||||
name: "string",
|
||||
yearly: 0,
|
||||
isDate: true,
|
||||
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
||||
},
|
||||
{
|
||||
id: "a251c176-3dac-4d09-9813-38c8db1127e3",
|
||||
createdAt: "2024-03-12T02:58:17.917Z",
|
||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
||||
lastUpdatedAt: "2024-03-12T02:58:17.917Z",
|
||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
||||
createdFullName: "string",
|
||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||
isActive: true,
|
||||
startDate: "2024-03-12T09:57:44.000Z",
|
||||
endDate: "2024-03-12T09:57:44.000Z",
|
||||
numberOrder: "string",
|
||||
topic: "topic",
|
||||
place: "place",
|
||||
dateOrder: "2024-03-12T09:57:44.000Z",
|
||||
department: "department",
|
||||
duration: "string",
|
||||
name: "name",
|
||||
yearly: 0,
|
||||
isDate: true,
|
||||
profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a",
|
||||
},
|
||||
],
|
||||
})
|
||||
public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const record = await this.trainingHistoryRepo.findBy({
|
||||
profileTrainingId: trainingId,
|
||||
const record = await this.trainingHistoryRepo.find({
|
||||
where: {
|
||||
profileTrainingId: trainingId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -147,7 +75,7 @@ export class ProfileTrainingController extends Controller {
|
|||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -161,6 +89,8 @@ export class ProfileTrainingController extends Controller {
|
|||
createdFullName: req.user.name,
|
||||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
createdAt: new Date(),
|
||||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
|
|
@ -187,15 +117,18 @@ export class ProfileTrainingController extends Controller {
|
|||
const history = new ProfileTrainingHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
|
||||
history.profileTrainingId = trainingId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
history.lastUpdateUserId = req.user.sub;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]);
|
||||
|
||||
|
|
@ -206,7 +139,11 @@ export class ProfileTrainingController extends Controller {
|
|||
public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
await new permission().PermissionOrgUserDelete(
|
||||
req,
|
||||
"SYS_REGISTRY_OFFICER",
|
||||
_record.profileId,
|
||||
);
|
||||
}
|
||||
await this.trainingHistoryRepo.delete({
|
||||
profileTrainingId: trainingId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue