แก้ วันที่ 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,36 +40,18 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
}
|
||||
const record = await this.honorRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
result: [
|
||||
{
|
||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
||||
createdAt: "2024-03-12T03:10:05.594Z",
|
||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
lastUpdatedAt: "2024-03-12T03:10:05.594Z",
|
||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
createdFullName: "สาวิตรี ศรีสมัย",
|
||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
||||
detail: "string",
|
||||
issueDate: "2024-03-12T10:09:47.000Z",
|
||||
issuer: "string",
|
||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
||||
refCommandNo: "string",
|
||||
isDate: true,
|
||||
},
|
||||
],
|
||||
})
|
||||
public async getHonor(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const record = await this.honorRepo.findBy({ profileEmployeeId });
|
||||
const record = await this.honorRepo.find({
|
||||
where: { profileEmployeeId: profileEmployeeId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
|
|
@ -91,57 +72,27 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
profileEmployeeId: profile.id,
|
||||
},
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Get("history/{honorId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
result: [
|
||||
{
|
||||
id: "3bedb365-4a41-4df5-8f47-b6e143221d2c",
|
||||
createdAt: "2024-03-12T03:11:01.395Z",
|
||||
createdUserId: "00000000-0000-0000-0000-000000000000",
|
||||
lastUpdatedAt: "2024-03-12T03:11:01.395Z",
|
||||
lastUpdateUserId: "00000000-0000-0000-0000-000000000000",
|
||||
createdFullName: "string",
|
||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||
detail: "detail",
|
||||
issueDate: "2024-03-12T10:10:31.000Z",
|
||||
issuer: "issuer",
|
||||
refCommandDate: "2024-03-12T10:10:31.000Z",
|
||||
refCommandNo: "refCommandNo",
|
||||
isDate: true,
|
||||
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
||||
},
|
||||
{
|
||||
id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f",
|
||||
createdAt: "2024-03-12T03:10:05.657Z",
|
||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
lastUpdatedAt: "2024-03-12T03:10:05.657Z",
|
||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
createdFullName: "สาวิตรี ศรีสมัย",
|
||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||
detail: "string",
|
||||
issueDate: "2024-03-12T10:09:47.000Z",
|
||||
issuer: "string",
|
||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
||||
refCommandNo: "string",
|
||||
isDate: true,
|
||||
profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
||||
},
|
||||
],
|
||||
})
|
||||
public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
||||
await new permission().PermissionOrgUserGet(
|
||||
req,
|
||||
"SYS_REGISTRY_EMP",
|
||||
_record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
|
||||
const record = await this.honorHistoryRepo.findBy({
|
||||
profileHonorId: honorId,
|
||||
const record = await this.honorHistoryRepo.find({
|
||||
where: {
|
||||
profileHonorId: honorId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -165,6 +116,8 @@ export class ProfileHonorEmployeeController 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 });
|
||||
|
|
@ -186,20 +139,27 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
) {
|
||||
const record = await this.honorRepo.findOneBy({ id: honorId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId)
|
||||
|
||||
await new permission().PermissionOrgUserUpdate(
|
||||
req,
|
||||
"SYS_REGISTRY_EMP",
|
||||
record.profileEmployeeId,
|
||||
);
|
||||
|
||||
const history = new ProfileHonorHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
|
||||
history.profileHonorId = honorId;
|
||||
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.honorRepo.save(record), this.honorHistoryRepo.save(history)]);
|
||||
|
||||
|
|
@ -210,7 +170,11 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
public async deleteTraning(@Path() honorId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
||||
await new permission().PermissionOrgUserDelete(
|
||||
req,
|
||||
"SYS_REGISTRY_EMP",
|
||||
_record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
|
||||
await this.honorHistoryRepo.delete({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue