Merge branch 'develop' into working

This commit is contained in:
Suphonchai Phoonsawat 2024-10-17 11:34:32 +07:00
commit 9370c9e72b
2 changed files with 27 additions and 4 deletions

View file

@ -307,13 +307,25 @@ export class WorkflowController extends Controller {
},
},
order: { order: "ASC", stateUserComments: { order: "ASC" } },
relations: ["stateUserComments"],
relations: ["stateUserComments", "stateUserComments.profile"],
});
const _state = state.map((x) => ({
stateId: x.id,
stateNo: x.order,
stateName: x.name,
stateUserComments: x.stateUserComments,
stateUserComments: x.stateUserComments.map((x) => ({
id: x.id,
prefix: x.profile.prefix,
firstName: x.profile.firstName,
lastName: x.profile.lastName,
profileId: x.profileId,
isAcceptSetting: x.isAcceptSetting,
isApproveSetting: x.isApproveSetting,
isReasonSetting: x.isReasonSetting,
isAccept: x.isAccept,
isApprove: x.isApprove,
reason: x.reason,
})),
}));
return new HttpSuccess(_state);
}
@ -327,6 +339,17 @@ export class WorkflowController extends Controller {
system: string;
},
) {
const stateOperatorUserNow = await this.stateOperatorUserRepo.findOne({
where: {
workflow: {
refId: body.refId,
sysName: body.system,
},
profile: {
keycloak: req.user.sub,
},
},
});
const stateOperatorUser = await this.stateOperatorUserRepo.find({
where: {
workflow: {
@ -336,6 +359,7 @@ export class WorkflowController extends Controller {
profile: {
keycloak: Not(req.user.sub),
},
operator: stateOperatorUserNow?.operator || "",
},
});
await this.stateOperatorUserRepo.remove(stateOperatorUser);

View file

@ -1,6 +1,5 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { StateOperator } from "./StateOperator";
import { Workflow } from "./Workflow";
import { Profile } from "./Profile";