Task #2208 กรณีขอแก้ไขข้อมูลทะเบียนประวัติ และ IDP และคนขออยู่ในสำนักปลัดกรุงเทพมหานคร
All checks were successful
Build & Deploy on Dev / build (push) Successful in 59s

This commit is contained in:
harid 2026-01-21 13:53:29 +07:00
parent 757da877f6
commit ae3a634595
3 changed files with 66 additions and 11 deletions

View file

@ -27,6 +27,7 @@ import { ProfileDevelopmentHistory } from "../entities/ProfileDevelopmentHistory
import { setLogDataDiff } from "../interfaces/utils";
import CallAPI from "../interfaces/call-api";
import { OrgRevision } from "../entities/OrgRevision";
import { OrgRoot } from "../entities/OrgRoot";
@Route("api/v1/org/profile/development-request")
@Tags("DevelopmentRequest")
@Security("bearerAuth")
@ -37,6 +38,7 @@ export class DevelopmentRequestController extends Controller {
private developmentProjectRepository = AppDataSource.getRepository(DevelopmentProject);
private developmentHistoryRepository = AppDataSource.getRepository(ProfileDevelopmentHistory);
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
private orgRootRepo = AppDataSource.getRepository(OrgRoot);
@Get("user")
public async getDevelopmentRequestUser(
@ -298,12 +300,32 @@ export class DevelopmentRequestController extends Controller {
@Body() body: CreateDevelopmentRequest,
) {
const profile = await this.profileRepository.findOne({
where: { keycloak: req.user.sub },
relations: ["posLevel", "posType"],
relations: {
posLevel: true,
posType: true,
current_holders: true
},
where: {
keycloak: req.user.sub,
current_holders: {
orgRevision: {
orgRevisionIsCurrent: true,
orgRevisionIsDraft: false
}
}
}
});
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const orgRoot = await this.orgRootRepo.findOne({
select: {
isDeputy: true
},
where: {
id: profile.current_holders.find(x => x.orgRootId)!.orgRootId ?? ""
}
})
const before = null;
const data = new DevelopmentRequest();
@ -346,6 +368,7 @@ export class DevelopmentRequestController extends Controller {
posLevelName: profile.posLevel.posLevelName,
posTypeName: profile.posType.posTypeName,
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
isDeputy: orgRoot?.isDeputy ?? false
})
.catch((error) => {
console.error("Error calling API:", error);