check state

This commit is contained in:
kittapath 2024-10-17 12:10:23 +07:00
parent 9370c9e72b
commit 5947b19f9e

View file

@ -265,8 +265,6 @@ export class WorkflowController extends Controller {
});
if (!stateOperatorUser)
throw new HttpError(HttpStatus.NOT_FOUND, "ผู้ใช้งานนี้ไม่มีหน้าที่ในกระบวนการนี้");
console.log(stateOperatorUser.operator);
console.log(stateOperatorUser.workflow.stateId);
const operator = await this.stateOperatorRepo.findOne({
where: {
operator: stateOperatorUser.operator,
@ -274,8 +272,25 @@ export class WorkflowController extends Controller {
},
relations: ["state"],
});
if (!operator)
throw new HttpError(HttpStatus.NOT_FOUND, "ผู้ใช้งานนี้ไม่มีหน้าที่ในขั้นตอนนี้");
if (!operator) {
const state = await this.stateRepo.findOne({
where: {
id: stateOperatorUser.workflow.stateId,
},
});
return new HttpSuccess({
stateId: state?.id || null,
stateNo: state?.order || null,
stateName: state?.name || null,
operator: stateOperatorUser.operator,
can_view: false,
can_update: false,
can_operate: false,
can_change_state: false,
can_delete: false,
can_cancel: false,
});
}
return new HttpSuccess({
stateId: operator.state.id,
stateNo: operator.state.order,