แก้ วันที่ 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

@ -46,7 +46,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
public async getGovHistoryUser(@Request() request: { user: Record<string, any> }) {
const orgRevision = await this.orgRevisionRepository.findOne({
select: ["id"],
where: {
where: {
orgRevisionIsDraft: false,
orgRevisionIsCurrent: true,
},
@ -147,7 +147,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const orgRevision = await this.orgRevisionRepository.findOne({
select: ["id"],
where: {
where: {
orgRevisionIsDraft: false,
orgRevisionIsCurrent: true,
},
@ -238,7 +238,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
public async getGovHistoryAdmin(@Path() profileEmployeeId: string) {
const orgRevision = await this.orgRevisionRepository.findOne({
select: ["id"],
where: {
where: {
orgRevisionIsDraft: false,
orgRevisionIsCurrent: true,
},
@ -343,7 +343,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
@Get("history/{profileEmployeeId}")
@Example({})
public async govHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId)
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const record = await this.govRepo.find({
order: { lastUpdatedAt: "DESC" },
where: { profileEmployeeId: profileEmployeeId },
@ -362,7 +362,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
@Body() body: UpdateProfileGovernment,
@Path() profileEmployeeId: string,
) {
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId)
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const record = await this.profileEmployeeRepo.findOne({
where: { id: profileEmployeeId },
});
@ -371,15 +371,18 @@ export class ProfileGovernmentEmployeeController extends Controller {
const history = new ProfileGovernment();
Object.assign(record, body);
Object.assign(history, body);
Object.assign(history, { ...body, id: undefined });
history.profileEmployeeId = profileEmployeeId;
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.profileEmployeeRepo.save(record), this.govRepo.save(history)]);
return new HttpSuccess();