Task #2208 กรณีขอแก้ไขข้อมูลทะเบียนประวัติ และ IDP และคนขออยู่ในสำนักปลัดกรุงเทพมหานคร
All checks were successful
Build & Deploy on Dev / build (push) Successful in 59s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 59s
This commit is contained in:
parent
757da877f6
commit
ae3a634595
3 changed files with 66 additions and 11 deletions
|
|
@ -27,6 +27,7 @@ import { ProfileDevelopmentHistory } from "../entities/ProfileDevelopmentHistory
|
||||||
import { setLogDataDiff } from "../interfaces/utils";
|
import { setLogDataDiff } from "../interfaces/utils";
|
||||||
import CallAPI from "../interfaces/call-api";
|
import CallAPI from "../interfaces/call-api";
|
||||||
import { OrgRevision } from "../entities/OrgRevision";
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
|
import { OrgRoot } from "../entities/OrgRoot";
|
||||||
@Route("api/v1/org/profile/development-request")
|
@Route("api/v1/org/profile/development-request")
|
||||||
@Tags("DevelopmentRequest")
|
@Tags("DevelopmentRequest")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -37,6 +38,7 @@ export class DevelopmentRequestController extends Controller {
|
||||||
private developmentProjectRepository = AppDataSource.getRepository(DevelopmentProject);
|
private developmentProjectRepository = AppDataSource.getRepository(DevelopmentProject);
|
||||||
private developmentHistoryRepository = AppDataSource.getRepository(ProfileDevelopmentHistory);
|
private developmentHistoryRepository = AppDataSource.getRepository(ProfileDevelopmentHistory);
|
||||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||||
|
private orgRootRepo = AppDataSource.getRepository(OrgRoot);
|
||||||
|
|
||||||
@Get("user")
|
@Get("user")
|
||||||
public async getDevelopmentRequestUser(
|
public async getDevelopmentRequestUser(
|
||||||
|
|
@ -298,12 +300,32 @@ export class DevelopmentRequestController extends Controller {
|
||||||
@Body() body: CreateDevelopmentRequest,
|
@Body() body: CreateDevelopmentRequest,
|
||||||
) {
|
) {
|
||||||
const profile = await this.profileRepository.findOne({
|
const profile = await this.profileRepository.findOne({
|
||||||
where: { keycloak: req.user.sub },
|
relations: {
|
||||||
relations: ["posLevel", "posType"],
|
posLevel: true,
|
||||||
|
posType: true,
|
||||||
|
current_holders: true
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
keycloak: req.user.sub,
|
||||||
|
current_holders: {
|
||||||
|
orgRevision: {
|
||||||
|
orgRevisionIsCurrent: true,
|
||||||
|
orgRevisionIsDraft: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ 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 before = null;
|
||||||
const data = new DevelopmentRequest();
|
const data = new DevelopmentRequest();
|
||||||
|
|
||||||
|
|
@ -346,6 +368,7 @@ export class DevelopmentRequestController extends Controller {
|
||||||
posLevelName: profile.posLevel.posLevelName,
|
posLevelName: profile.posLevel.posLevelName,
|
||||||
posTypeName: profile.posType.posTypeName,
|
posTypeName: profile.posType.posTypeName,
|
||||||
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
||||||
|
isDeputy: orgRoot?.isDeputy ?? false
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error);
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import { Brackets } from "typeorm";
|
||||||
import CallAPI from "../interfaces/call-api";
|
import CallAPI from "../interfaces/call-api";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
import { OrgRevision } from "../entities/OrgRevision";
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
|
import { OrgRoot } from "../entities/OrgRoot";
|
||||||
@Route("api/v1/org/profile/edit")
|
@Route("api/v1/org/profile/edit")
|
||||||
@Tags("ProfileEdit")
|
@Tags("ProfileEdit")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -31,6 +31,7 @@ export class ProfileEditController extends Controller {
|
||||||
private profileRepo = AppDataSource.getRepository(Profile);
|
private profileRepo = AppDataSource.getRepository(Profile);
|
||||||
private profileEditRepo = AppDataSource.getRepository(ProfileEdit);
|
private profileEditRepo = AppDataSource.getRepository(ProfileEdit);
|
||||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||||
|
private orgRootRepo = AppDataSource.getRepository(OrgRoot);
|
||||||
|
|
||||||
@Get("user")
|
@Get("user")
|
||||||
public async detailProfileEditUser(
|
public async detailProfileEditUser(
|
||||||
|
|
@ -294,12 +295,32 @@ export class ProfileEditController extends Controller {
|
||||||
@Post()
|
@Post()
|
||||||
public async newProfileEdit(@Request() req: RequestWithUser, @Body() body: CreateProfileEdit) {
|
public async newProfileEdit(@Request() req: RequestWithUser, @Body() body: CreateProfileEdit) {
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { keycloak: req.user.sub },
|
relations: {
|
||||||
relations: ["posLevel", "posType"],
|
posLevel: true,
|
||||||
|
posType: true,
|
||||||
|
current_holders: true
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
keycloak: req.user.sub,
|
||||||
|
current_holders: {
|
||||||
|
orgRevision: {
|
||||||
|
orgRevisionIsCurrent: true,
|
||||||
|
orgRevisionIsDraft: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ 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 data = new ProfileEdit();
|
const data = new ProfileEdit();
|
||||||
const meta = {
|
const meta = {
|
||||||
|
|
@ -322,6 +343,7 @@ export class ProfileEditController extends Controller {
|
||||||
posLevelName: profile.posLevel.posLevelName,
|
posLevelName: profile.posLevel.posLevelName,
|
||||||
posTypeName: profile.posType.posTypeName,
|
posTypeName: profile.posType.posTypeName,
|
||||||
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
||||||
|
isDeputy: orgRoot?.isDeputy ?? false
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error);
|
||||||
|
|
|
||||||
|
|
@ -145,13 +145,23 @@ export class WorkflowController extends Controller {
|
||||||
metaStates.find((metaState) => metaState.id === metaStateOp.metaStateId)?.order ===
|
metaStates.find((metaState) => metaState.id === metaStateOp.metaStateId)?.order ===
|
||||||
state.order,
|
state.order,
|
||||||
);
|
);
|
||||||
|
if (body.isDeputy) {
|
||||||
// Task #2207 กรณีคนขอโอนอยู่ในสำนักปลัดกรุงเทพมหานคร
|
// Task #2207 กรณีคนขอโอนอยู่ในสำนักปลัดกรุงเทพมหานคร
|
||||||
if (body.isDeputy && metaStateOp.operator == "PersonnelOfficer" && correspondingState?.order == 1) {
|
if (body.sysName == "SYS_TRANSFER_REQ") {
|
||||||
|
if (metaStateOp.operator == "PersonnelOfficer" && correspondingState?.order == 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (body.isDeputy && metaStateOp.operator == "Officer" && [1, 2].includes(correspondingState?.order as number)) {
|
else if (metaStateOp.operator == "Officer" && [1, 2].includes(correspondingState?.order as number)) {
|
||||||
metaStateOp.operator = "PersonnelOfficer"
|
metaStateOp.operator = "PersonnelOfficer"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// Task #2208 กรณีขอแก้ไขข้อมูลทะเบียนประวัติ และ IDP และคนขออยู่ในสำนักปลัดกรุงเทพมหานคร
|
||||||
|
if (metaStateOp.operator == "Officer" &&
|
||||||
|
(["REGISTRY_PROFILE", "REGISTRY_PROFILE_EMP", "REGISTRY_IDP"].includes(body.sysName))
|
||||||
|
) {
|
||||||
|
metaStateOp.operator = "PersonnelOfficer"
|
||||||
|
}
|
||||||
|
}
|
||||||
if (correspondingState) {
|
if (correspondingState) {
|
||||||
const stateOperator = new StateOperator();
|
const stateOperator = new StateOperator();
|
||||||
Object.assign(stateOperator, {
|
Object.assign(stateOperator, {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue