add workflow

This commit is contained in:
kittapath 2024-10-30 16:30:04 +07:00
parent 4a933c79cd
commit f3eadd867a

View file

@ -25,6 +25,7 @@ import { DevelopmentProject } from "../entities/DevelopmentProject";
import { ProfileDevelopment } from "../entities/ProfileDevelopment";
import { ProfileDevelopmentHistory } from "../entities/ProfileDevelopmentHistory";
import { setLogDataDiff } from "../interfaces/utils";
import CallAPI from "../interfaces/call-api";
@Route("api/v1/org/profile/development-request")
@Tags("DevelopmentRequest")
@Security("bearerAuth")
@ -207,7 +208,10 @@ export class DevelopmentRequestController extends Controller {
@Request() req: RequestWithUser,
@Body() body: CreateDevelopmentRequest,
) {
const profile = await this.profileRepository.findOneBy({ keycloak: req.user.sub });
const profile = await this.profileRepository.findOne({
where: { keycloak: req.user.sub },
relations: ["posLevel", "posType"],
});
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
@ -246,6 +250,16 @@ export class DevelopmentRequestController extends Controller {
}),
);
}
await new CallAPI()
.PostData(req, "/org/workflow/add-workflow", {
refId: data.id,
sysName: "REGISTRY_IDP",
posLevelName: profile.posLevel.posLevelName,
posTypeName: profile.posType.posTypeName,
})
.catch((error) => {
console.error("Error calling API:", error);
});
return new HttpSuccess(data.id);
}