migrate add column isDeleted + API ลบข้อมูลฝึกอบรม/ดูงาน + การพัฒนารายบุคคล idp + รักษาการ Task #2276, #2279, #2278
All checks were successful
Build & Deploy on Dev / build (push) Successful in 50s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 50s
This commit is contained in:
parent
bb18fed9ae
commit
30bf5ad9e3
12 changed files with 317 additions and 9 deletions
|
|
@ -392,6 +392,7 @@ export class CommandController extends Controller {
|
|||
if (!commandType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||
}
|
||||
const now = new Date();
|
||||
command.detailHeader = commandType.detailHeader;
|
||||
command.detailBody = commandType.detailBody;
|
||||
command.detailFooter = commandType.detailFooter;
|
||||
|
|
@ -401,11 +402,85 @@ export class CommandController extends Controller {
|
|||
command.issue = commandType.name;
|
||||
command.createdUserId = request.user.sub;
|
||||
command.createdFullName = request.user.name;
|
||||
command.createdAt = new Date();
|
||||
command.createdAt = now;
|
||||
command.lastUpdateUserId = request.user.sub;
|
||||
command.lastUpdateFullName = request.user.name;
|
||||
command.lastUpdatedAt = new Date();
|
||||
command.lastUpdatedAt = now;
|
||||
await this.commandRepository.save(command);
|
||||
// insert commandOperator
|
||||
if (request.user.sub) {
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: { keycloak: request.user.sub },
|
||||
relations: {
|
||||
posLevel: true,
|
||||
posType: true,
|
||||
current_holders: {
|
||||
orgRevision: true,
|
||||
orgRoot: true,
|
||||
orgChild1: true,
|
||||
orgChild2: true,
|
||||
orgChild3: true,
|
||||
orgChild4: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
if (profile) {
|
||||
const currentHolder = profile!.current_holders?.find(
|
||||
x =>
|
||||
x.orgRevision?.orgRevisionIsDraft === false &&
|
||||
x.orgRevision?.orgRevisionIsCurrent === true,
|
||||
);
|
||||
|
||||
const posNo =
|
||||
currentHolder != null && currentHolder.orgChild4 != null
|
||||
? `${currentHolder.orgChild4.orgChild4ShortName} ${currentHolder.posMasterNo}`
|
||||
: currentHolder != null && currentHolder.orgChild3 != null
|
||||
? `${currentHolder.orgChild3.orgChild3ShortName} ${currentHolder.posMasterNo}`
|
||||
: currentHolder != null && currentHolder.orgChild2 != null
|
||||
? `${currentHolder.orgChild2.orgChild2ShortName} ${currentHolder.posMasterNo}`
|
||||
: currentHolder != null && currentHolder.orgChild1 != null
|
||||
? `${currentHolder.orgChild1.orgChild1ShortName} ${currentHolder.posMasterNo}`
|
||||
: currentHolder != null && currentHolder?.orgRoot != null
|
||||
? `${currentHolder.orgRoot.orgRootShortName} ${currentHolder.posMasterNo}`
|
||||
: null;
|
||||
|
||||
const position = await this.positionRepository.findOne({
|
||||
where: {
|
||||
positionIsSelected: true,
|
||||
posMaster: {
|
||||
orgRevisionId: currentHolder?.orgRevisionId,
|
||||
current_holderId: profile!.id,
|
||||
},
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
relations: { posExecutive: true },
|
||||
});
|
||||
const operator = Object.assign(
|
||||
new CommandOperator(),
|
||||
{
|
||||
profileId: profile?.id,
|
||||
prefix: profile?.prefix,
|
||||
firstName: profile?.firstName,
|
||||
lastName: profile?.lastName,
|
||||
posNo: posNo,
|
||||
posType: profile?.posType?.posTypeName ?? null,
|
||||
posLevel: profile?.posLevel?.posLevelName ?? null,
|
||||
position: position?.positionName ?? null,
|
||||
positionExecutive: position?.posExecutive?.posExecutiveName ?? null,
|
||||
roleName: "เจ้าหน้าที่ดำเนินการ",
|
||||
orderNo: 1,
|
||||
commandId: command.id,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
createdAt: now,
|
||||
lastUpdateUserId: request.user.sub,
|
||||
lastUpdateFullName: request.user.name,
|
||||
lastUpdatedAt: now,
|
||||
}
|
||||
);
|
||||
await this.commandOperatorRepository.save(operator);
|
||||
}
|
||||
}
|
||||
return new HttpSuccess(command.id);
|
||||
}
|
||||
|
||||
|
|
@ -2538,7 +2613,7 @@ export class CommandController extends Controller {
|
|||
roleName: "เจ้าหน้าที่ดำเนินการ",
|
||||
orderNo: 1,
|
||||
commandId: command.id,
|
||||
createUserId: request.user.sub,
|
||||
createdUserId: request.user.sub,
|
||||
createdFullName: request.user.name,
|
||||
createdAt: now,
|
||||
lastUpdateUserId: request.user.sub,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue