แก้ วันที่ update
This commit is contained in:
parent
6d36c9b05f
commit
218886b3f4
83 changed files with 1671 additions and 3483 deletions
|
|
@ -37,53 +37,22 @@ export class ProfileOtherController extends Controller {
|
|||
}
|
||||
const lists = await this.otherRepository.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
result: [
|
||||
{
|
||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
||||
isActive: true,
|
||||
date: "2024-03-12T10:09:47.000Z",
|
||||
reference: "string",
|
||||
detail: "string",
|
||||
refCommandNo: "string",
|
||||
refCommandDate: "2024-03-12T10:09:47.000Z",
|
||||
},
|
||||
],
|
||||
})
|
||||
public async getOther(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const lists = await this.otherRepository.find({
|
||||
where: { profileId: profileId },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("history/{otherId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
result: [
|
||||
{
|
||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
||||
isActive: true,
|
||||
date: "2024-03-12T10:09:47.000Z",
|
||||
detail: "string",
|
||||
},
|
||||
{
|
||||
id: "debfa8a7-83fb-4801-a940-8ae74e7638d3",
|
||||
isActive: true,
|
||||
date: "2024-03-12T10:09:47.000Z",
|
||||
detail: "string",
|
||||
},
|
||||
],
|
||||
})
|
||||
public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
if (_record) {
|
||||
|
|
@ -101,7 +70,7 @@ export class ProfileOtherController extends Controller {
|
|||
if (!body.profileId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileRepository.findOneBy({ id: body.profileId });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -115,6 +84,8 @@ export class ProfileOtherController 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 });
|
||||
|
|
@ -141,15 +112,18 @@ export class ProfileOtherController extends Controller {
|
|||
const history = new ProfileOtherHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
|
||||
history.profileOtherId = otherId;
|
||||
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.otherRepository.save(record),
|
||||
|
|
@ -161,10 +135,14 @@ export class ProfileOtherController extends Controller {
|
|||
|
||||
@Delete("{otherId}")
|
||||
public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(
|
||||
req,
|
||||
"SYS_REGISTRY_OFFICER",
|
||||
_record.profileId,
|
||||
);
|
||||
}
|
||||
await this.otherHistoryRepository.delete({
|
||||
profileOtherId: otherId,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue