แก้ วันที่ update

This commit is contained in:
kittapath 2024-08-30 18:02:34 +07:00
parent 6d36c9b05f
commit 218886b3f4
83 changed files with 1671 additions and 3483 deletions

View file

@ -2,7 +2,6 @@ import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
Path,
@ -48,41 +47,12 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
},
},
where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
});
return new HttpSuccess(record);
}
@Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
createdAt: "2024-03-12T03:05:09.393Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:05:09.393Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
year: 0,
no: "string",
volume: "string",
section: "string",
page: "string",
receiveDate: "2024-03-12T10:05:02.000Z",
insigniaId: "string",
insigniaType: "string",
dateAnnounce: "2024-03-12T10:05:02.000Z",
issue: "string",
volumeNo: "string",
refCommandDate: "2024-03-12T10:05:02.000Z",
refCommandNo: "string",
note: "string",
},
],
})
public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.insigniaRepo.find({
@ -92,65 +62,12 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
},
},
where: { profileEmployeeId },
order: { createdAt: "ASC" },
});
return new HttpSuccess(record);
}
@Get("history/{InsigniaId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "c363d13c-88bd-4954-adf5-70d3f5ca9c30",
createdAt: "2024-03-12T03:06:31.062Z",
createdUserId: "00000000-0000-0000-0000-000000000000",
lastUpdatedAt: "2024-03-12T03:06:31.062Z",
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
createdFullName: "string",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
year: 0,
no: "no",
volume: "volume",
section: "section",
page: "page",
receiveDate: "2024-03-12T10:05:44.000Z",
insigniaId: "insigniaId",
insigniaType: "insigniaType",
dateAnnounce: "2024-03-12T10:05:44.000Z",
issue: "string",
volumeNo: "volumeNo",
refCommandDate: "2024-03-12T10:05:44.000Z",
refCommandNo: "refCommandNo",
note: "string",
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
},
{
id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
createdAt: "2024-03-12T03:05:09.393Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-12T03:09:04.905Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
year: 0,
no: "string",
volume: "string",
section: "string",
page: "string",
receiveDate: "2024-03-12T10:05:02.000Z",
insigniaId: "string",
insigniaType: "string",
dateAnnounce: "2024-03-12T10:05:02.000Z",
issue: "string",
volumeNo: "string",
refCommandDate: "2024-03-12T10:05:02.000Z",
refCommandNo: "string",
note: "string",
profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb",
},
],
})
public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.insigniaHistoryRepo.find({
@ -162,6 +79,7 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
where: {
profileInsigniaId: InsigniaId,
},
order: { createdAt: "DESC" },
});
return new HttpSuccess(record);
}
@ -196,6 +114,8 @@ export class ProfileInsigniaEmployeeTempController 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 });
@ -230,15 +150,18 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
const history = new ProfileInsigniaHistory();
Object.assign(record, body);
Object.assign(history, body);
Object.assign(history, { ...body, id: undefined });
history.profileInsigniaId = insigniaId;
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.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]);