Implement feature X to enhance user experience and optimize performance #1555
This commit is contained in:
parent
5a4b7c92a3
commit
5b2c968033
1 changed files with 464 additions and 481 deletions
|
|
@ -1,45 +1,44 @@
|
||||||
import {
|
import {
|
||||||
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
|
Get,
|
||||||
|
Path,
|
||||||
Post,
|
Post,
|
||||||
Put,
|
Put,
|
||||||
|
Request,
|
||||||
|
Response,
|
||||||
Route,
|
Route,
|
||||||
Security,
|
Security,
|
||||||
Tags,
|
|
||||||
Body,
|
|
||||||
Path,
|
|
||||||
Request,
|
|
||||||
SuccessResponse,
|
SuccessResponse,
|
||||||
Response,
|
Tags,
|
||||||
Get,
|
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
|
||||||
import HttpStatus from "../interfaces/http-status";
|
|
||||||
import HttpError from "../interfaces/http-error";
|
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
|
||||||
import { Profile } from "../entities/Profile";
|
|
||||||
import { And, Between, Brackets, In, IsNull, LessThanOrEqual, Not } from "typeorm";
|
import { And, Between, Brackets, In, IsNull, LessThanOrEqual, Not } from "typeorm";
|
||||||
import { OrgRevision } from "../entities/OrgRevision";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { OrgRoot } from "../entities/OrgRoot";
|
import { Assign } from "../entities/Assign";
|
||||||
|
import { EmployeePosDict } from "../entities/EmployeePosDict";
|
||||||
|
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||||
import { OrgChild1 } from "../entities/OrgChild1";
|
import { OrgChild1 } from "../entities/OrgChild1";
|
||||||
import { OrgChild2 } from "../entities/OrgChild2";
|
import { OrgChild2 } from "../entities/OrgChild2";
|
||||||
import { OrgChild3 } from "../entities/OrgChild3";
|
import { OrgChild3 } from "../entities/OrgChild3";
|
||||||
import { OrgChild4 } from "../entities/OrgChild4";
|
import { OrgChild4 } from "../entities/OrgChild4";
|
||||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
|
import { OrgRoot } from "../entities/OrgRoot";
|
||||||
import { Position } from "../entities/Position";
|
import { Position } from "../entities/Position";
|
||||||
import { Insignia } from "../entities/Insignia";
|
|
||||||
import { CreateProfileInsignia, ProfileInsignia } from "../entities/ProfileInsignia";
|
|
||||||
import { PosMaster } from "../entities/PosMaster";
|
import { PosMaster } from "../entities/PosMaster";
|
||||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
|
||||||
import { EmployeePosDict } from "../entities/EmployeePosDict";
|
|
||||||
import { calculateRetireLaw } from "../interfaces/utils";
|
|
||||||
import Extension from "../interfaces/extension";
|
|
||||||
import { PosMasterHistory } from "../entities/PosMasterHistory";
|
|
||||||
import { PosMasterEmployeeHistory } from "../entities/PosMasterEmployeeHistory";
|
|
||||||
import { PosMasterAssign } from "../entities/PosMasterAssign";
|
import { PosMasterAssign } from "../entities/PosMasterAssign";
|
||||||
import { Assign } from "../entities/Assign";
|
import { PosMasterEmployeeHistory } from "../entities/PosMasterEmployeeHistory";
|
||||||
import { ProfileSalary } from "../entities/ProfileSalary";
|
import { PosMasterHistory } from "../entities/PosMasterHistory";
|
||||||
|
import { Profile } from "../entities/Profile";
|
||||||
import { ProfileEducation } from "../entities/ProfileEducation";
|
import { ProfileEducation } from "../entities/ProfileEducation";
|
||||||
|
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||||
|
import { CreateProfileInsignia, ProfileInsignia } from "../entities/ProfileInsignia";
|
||||||
|
import { ProfileSalary } from "../entities/ProfileSalary";
|
||||||
|
import Extension from "../interfaces/extension";
|
||||||
|
import HttpError from "../interfaces/http-error";
|
||||||
|
import HttpStatus from "../interfaces/http-status";
|
||||||
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
|
import { calculateRetireLaw } from "../interfaces/utils";
|
||||||
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
@Route("api/v1/org/dotnet")
|
@Route("api/v1/org/dotnet")
|
||||||
@Tags("Dotnet")
|
@Tags("Dotnet")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -60,12 +59,9 @@ export class OrganizationDotnetController extends Controller {
|
||||||
private positionRepository = AppDataSource.getRepository(Position);
|
private positionRepository = AppDataSource.getRepository(Position);
|
||||||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||||
private posMasterHistoryRepository = AppDataSource.getRepository(PosMasterHistory);
|
private posMasterHistoryRepository = AppDataSource.getRepository(PosMasterHistory);
|
||||||
private posMasterEmployeeHistoryRepository =
|
|
||||||
AppDataSource.getRepository(PosMasterEmployeeHistory);
|
|
||||||
private empPosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
private empPosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
||||||
private insigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
private insigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
||||||
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
||||||
private posMasterAssignRepo = AppDataSource.getRepository(PosMasterAssign);
|
|
||||||
private assignRepository = AppDataSource.getRepository(Assign);
|
private assignRepository = AppDataSource.getRepository(Assign);
|
||||||
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
|
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
|
||||||
private educationRepo = AppDataSource.getRepository(ProfileEducation);
|
private educationRepo = AppDataSource.getRepository(ProfileEducation);
|
||||||
|
|
@ -105,10 +101,40 @@ export class OrganizationDotnetController extends Controller {
|
||||||
node?: number | null;
|
node?: number | null;
|
||||||
page: number;
|
page: number;
|
||||||
pageSize: number;
|
pageSize: number;
|
||||||
|
selectedNodeId?: string | null;
|
||||||
|
selectedNode?: number | null;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
let condition = "1=1";
|
let condition = "1=1";
|
||||||
let conditionParams = {};
|
let conditionParams = {};
|
||||||
|
|
||||||
|
let selectedNodeCondition = "1=1";
|
||||||
|
let selectedNodeConditionParams = {};
|
||||||
|
|
||||||
|
if (body.selectedNodeId && body.selectedNode != null) {
|
||||||
|
switch (body.selectedNode) {
|
||||||
|
case 0:
|
||||||
|
selectedNodeCondition = "orgRoot.ancestorDNA = :selectedNodeId";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
selectedNodeCondition = "orgChild1.ancestorDNA = :selectedNodeId";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
selectedNodeCondition = "orgChild2.ancestorDNA = :selectedNodeId";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
selectedNodeCondition = "orgChild3.ancestorDNA = :selectedNodeId";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
selectedNodeCondition = "orgChild4.ancestorDNA = :selectedNodeId";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
selectedNodeCondition = "1=1";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
selectedNodeConditionParams = { selectedNodeId: body.selectedNodeId };
|
||||||
|
}
|
||||||
|
|
||||||
if (body.role === "CHILD") {
|
if (body.role === "CHILD") {
|
||||||
switch (body.node) {
|
switch (body.node) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -214,6 +240,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.andWhere(condition, conditionParams)
|
.andWhere(condition, conditionParams)
|
||||||
|
.andWhere(selectedNodeCondition, selectedNodeConditionParams)
|
||||||
.select([
|
.select([
|
||||||
"profile.id",
|
"profile.id",
|
||||||
"profile.citizenId",
|
"profile.citizenId",
|
||||||
|
|
@ -411,20 +438,18 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("get-profileId")
|
@Get("get-profileId")
|
||||||
async getProfileInbox(
|
async getProfileInbox(@Request() request: { user: Record<string, any> }) {
|
||||||
@Request() request: { user: Record<string, any> },
|
let profile: any;
|
||||||
) {
|
|
||||||
let profile: any
|
|
||||||
//OFF
|
//OFF
|
||||||
profile = await this.profileRepo.findOne({
|
profile = await this.profileRepo.findOne({
|
||||||
where: { keycloak: request.user.sub },
|
where: { keycloak: request.user.sub },
|
||||||
select: { id: true }
|
select: { id: true },
|
||||||
});
|
});
|
||||||
//EMP
|
//EMP
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
profile = await this.profileEmpRepo.findOne({
|
profile = await this.profileEmpRepo.findOne({
|
||||||
where: { keycloak: request.user.sub },
|
where: { keycloak: request.user.sub },
|
||||||
select: { id: true }
|
select: { id: true },
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
if (request.user.role.includes("SUPER_ADMIN")) {
|
if (request.user.role.includes("SUPER_ADMIN")) {
|
||||||
|
|
@ -435,8 +460,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const result = {
|
const result = {
|
||||||
profileId: profile ? profile.id : null
|
profileId: profile ? profile.id : null,
|
||||||
}
|
};
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1048,7 +1073,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
profile.posLevel != null &&
|
profile.posLevel != null &&
|
||||||
(profile.posType.posTypeName == "บริหาร" || profile.posType.posTypeName == "อำนวยการ")
|
(profile.posType.posTypeName == "บริหาร" || profile.posType.posTypeName == "อำนวยการ")
|
||||||
? `${profile.posType?.posTypeName ?? ""}${profile.posLevel?.posLevelName ?? ""}`
|
? `${profile.posType?.posTypeName ?? ""}${profile.posLevel?.posLevelName ?? ""}`
|
||||||
: profile.posLevel?.posLevelName ?? null;
|
: (profile.posLevel?.posLevelName ?? null);
|
||||||
const _profileCurrent = profile?.current_holders?.find(
|
const _profileCurrent = profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true,
|
x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true,
|
||||||
|
|
@ -1236,7 +1261,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
profileInsignia: profile.profileInsignias.length > 0 ? profile.profileInsignias[0] : null,
|
profileInsignia: profile.profileInsignias.length > 0 ? profile.profileInsignias[0] : null,
|
||||||
profileType: "OFFICER",
|
profileType: "OFFICER",
|
||||||
positionLeaveName: positionLeaveName,
|
positionLeaveName: positionLeaveName,
|
||||||
posExecutiveName: position == null || position.posExecutive == null
|
posExecutiveName:
|
||||||
|
position == null || position.posExecutive == null
|
||||||
? null
|
? null
|
||||||
: position.posExecutive.posExecutiveName,
|
: position.posExecutive.posExecutiveName,
|
||||||
oc: oc,
|
oc: oc,
|
||||||
|
|
@ -1297,7 +1323,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
});
|
});
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
const currentHolder = profile.current_holders?.find(
|
const currentHolder = profile.current_holders?.find(
|
||||||
x =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft === false &&
|
x.orgRevision?.orgRevisionIsDraft === false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent === true,
|
x.orgRevision?.orgRevisionIsCurrent === true,
|
||||||
);
|
);
|
||||||
|
|
@ -1346,8 +1372,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
.getOne();
|
.getOne();
|
||||||
|
|
||||||
if (pos?.current_holder) {
|
if (pos?.current_holder) {
|
||||||
commanderFullname =
|
commanderFullname = `${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`;
|
||||||
`${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`;
|
|
||||||
commanderPositionName = pos.current_holder.position;
|
commanderPositionName = pos.current_holder.position;
|
||||||
commanderId = pos.current_holder.id;
|
commanderId = pos.current_holder.id;
|
||||||
commanderKeycloak = pos.current_holder.keycloak;
|
commanderKeycloak = pos.current_holder.keycloak;
|
||||||
|
|
@ -1382,10 +1407,9 @@ export class OrganizationDotnetController extends Controller {
|
||||||
const positionLeaveName =
|
const positionLeaveName =
|
||||||
profile.posType &&
|
profile.posType &&
|
||||||
profile.posLevel &&
|
profile.posLevel &&
|
||||||
(profile.posType.posTypeName === "บริหาร" ||
|
(profile.posType.posTypeName === "บริหาร" || profile.posType.posTypeName === "อำนวยการ")
|
||||||
profile.posType.posTypeName === "อำนวยการ")
|
|
||||||
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
||||||
: profile.posLevel?.posLevelName ?? null;
|
: (profile.posLevel?.posLevelName ?? null);
|
||||||
|
|
||||||
const mapProfile = {
|
const mapProfile = {
|
||||||
id: profile.id,
|
id: profile.id,
|
||||||
|
|
@ -1474,9 +1498,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
* 2. current holder
|
* 2. current holder
|
||||||
* ========================================= */
|
* ========================================= */
|
||||||
const currentHolder = profile.current_holders?.find(
|
const currentHolder = profile.current_holders?.find(
|
||||||
x =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft === false &&
|
x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true,
|
||||||
x.orgRevision?.orgRevisionIsCurrent === true,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const org = {
|
const org = {
|
||||||
|
|
@ -1526,8 +1549,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
.getOne();
|
.getOne();
|
||||||
|
|
||||||
if (pos?.current_holder) {
|
if (pos?.current_holder) {
|
||||||
commanderFullname =
|
commanderFullname = `${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`;
|
||||||
`${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`;
|
|
||||||
commanderPositionName = pos.current_holder.position;
|
commanderPositionName = pos.current_holder.position;
|
||||||
commanderId = pos.current_holder.id;
|
commanderId = pos.current_holder.id;
|
||||||
commanderKeycloak = pos.current_holder.keycloak;
|
commanderKeycloak = pos.current_holder.keycloak;
|
||||||
|
|
@ -1586,10 +1608,9 @@ export class OrganizationDotnetController extends Controller {
|
||||||
const positionLeaveName =
|
const positionLeaveName =
|
||||||
profile.posType &&
|
profile.posType &&
|
||||||
profile.posLevel &&
|
profile.posLevel &&
|
||||||
(profile.posType.posTypeName === "บริหาร" ||
|
(profile.posType.posTypeName === "บริหาร" || profile.posType.posTypeName === "อำนวยการ")
|
||||||
profile.posType.posTypeName === "อำนวยการ")
|
|
||||||
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
||||||
: profile.posLevel?.posLevelName ?? null;
|
: (profile.posLevel?.posLevelName ?? null);
|
||||||
|
|
||||||
/* =========================================
|
/* =========================================
|
||||||
* 8. map response
|
* 8. map response
|
||||||
|
|
@ -1718,7 +1739,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
});
|
});
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
const currentHolder = profile.current_holders?.find(
|
const currentHolder = profile.current_holders?.find(
|
||||||
x =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft === false &&
|
x.orgRevision?.orgRevisionIsDraft === false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent === true,
|
x.orgRevision?.orgRevisionIsCurrent === true,
|
||||||
);
|
);
|
||||||
|
|
@ -1772,7 +1793,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
mouthSalaryAmount: profile.mouthSalaryAmount,
|
mouthSalaryAmount: profile.mouthSalaryAmount,
|
||||||
|
|
||||||
posType: profile.posType?.posTypeName ?? null,
|
posType: profile.posType?.posTypeName ?? null,
|
||||||
posLevel: profile.posType?.posTypeShortName == null && profile.posLevel?.posLevelName == null
|
posLevel:
|
||||||
|
profile.posType?.posTypeShortName == null && profile.posLevel?.posLevelName == null
|
||||||
? null
|
? null
|
||||||
: `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`,
|
: `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`,
|
||||||
oc,
|
oc,
|
||||||
|
|
@ -1801,9 +1823,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
* 2. current holder
|
* 2. current holder
|
||||||
* ========================================= */
|
* ========================================= */
|
||||||
const currentHolder = profile.current_holders?.find(
|
const currentHolder = profile.current_holders?.find(
|
||||||
x =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft === false &&
|
x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true,
|
||||||
x.orgRevision?.orgRevisionIsCurrent === true,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/* =========================================
|
/* =========================================
|
||||||
|
|
@ -1845,10 +1866,9 @@ export class OrganizationDotnetController extends Controller {
|
||||||
const positionLeaveName =
|
const positionLeaveName =
|
||||||
profile.posType &&
|
profile.posType &&
|
||||||
profile.posLevel &&
|
profile.posLevel &&
|
||||||
(profile.posType.posTypeName === "บริหาร" ||
|
(profile.posType.posTypeName === "บริหาร" || profile.posType.posTypeName === "อำนวยการ")
|
||||||
profile.posType.posTypeName === "อำนวยการ")
|
|
||||||
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
||||||
: profile.posLevel?.posLevelName ?? null;
|
: (profile.posLevel?.posLevelName ?? null);
|
||||||
|
|
||||||
/* =========================================
|
/* =========================================
|
||||||
* 8. map response
|
* 8. map response
|
||||||
|
|
@ -1961,7 +1981,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
});
|
});
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
const currentHolder = profile.current_holders?.find(
|
const currentHolder = profile.current_holders?.find(
|
||||||
x =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft === false &&
|
x.orgRevision?.orgRevisionIsDraft === false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent === true,
|
x.orgRevision?.orgRevisionIsCurrent === true,
|
||||||
);
|
);
|
||||||
|
|
@ -1997,8 +2017,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
.getOne();
|
.getOne();
|
||||||
|
|
||||||
if (pos?.current_holder) {
|
if (pos?.current_holder) {
|
||||||
commanderFullname =
|
commanderFullname = `${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`;
|
||||||
`${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`;
|
|
||||||
commanderPositionName = pos.current_holder.position;
|
commanderPositionName = pos.current_holder.position;
|
||||||
commanderId = pos.current_holder.id;
|
commanderId = pos.current_holder.id;
|
||||||
}
|
}
|
||||||
|
|
@ -2052,7 +2071,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
mouthSalaryAmount: profile.mouthSalaryAmount,
|
mouthSalaryAmount: profile.mouthSalaryAmount,
|
||||||
|
|
||||||
posType: profile.posType?.posTypeName ?? null,
|
posType: profile.posType?.posTypeName ?? null,
|
||||||
posLevel: profile.posType?.posTypeShortName == null && profile.posLevel?.posLevelName == null
|
posLevel:
|
||||||
|
profile.posType?.posTypeShortName == null && profile.posLevel?.posLevelName == null
|
||||||
? null
|
? null
|
||||||
: `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`,
|
: `${profile.posType?.posTypeShortName} ${profile.posLevel?.posLevelName}`,
|
||||||
oc,
|
oc,
|
||||||
|
|
@ -2091,9 +2111,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
* 2. current holder
|
* 2. current holder
|
||||||
* ========================================= */
|
* ========================================= */
|
||||||
const currentHolder = profile.current_holders?.find(
|
const currentHolder = profile.current_holders?.find(
|
||||||
x =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft === false &&
|
x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true,
|
||||||
x.orgRevision?.orgRevisionIsCurrent === true,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/* =================================================
|
/* =================================================
|
||||||
|
|
@ -2130,8 +2149,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
.getOne();
|
.getOne();
|
||||||
|
|
||||||
if (pos?.current_holder) {
|
if (pos?.current_holder) {
|
||||||
commanderFullname =
|
commanderFullname = `${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`;
|
||||||
`${pos.current_holder.prefix}${pos.current_holder.firstName} ${pos.current_holder.lastName}`;
|
|
||||||
commanderPositionName = pos.current_holder.position;
|
commanderPositionName = pos.current_holder.position;
|
||||||
commanderId = pos.current_holder.id;
|
commanderId = pos.current_holder.id;
|
||||||
}
|
}
|
||||||
|
|
@ -2175,10 +2193,9 @@ export class OrganizationDotnetController extends Controller {
|
||||||
const positionLeaveName =
|
const positionLeaveName =
|
||||||
profile.posType &&
|
profile.posType &&
|
||||||
profile.posLevel &&
|
profile.posLevel &&
|
||||||
(profile.posType.posTypeName === "บริหาร" ||
|
(profile.posType.posTypeName === "บริหาร" || profile.posType.posTypeName === "อำนวยการ")
|
||||||
profile.posType.posTypeName === "อำนวยการ")
|
|
||||||
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
||||||
: profile.posLevel?.posLevelName ?? null;
|
: (profile.posLevel?.posLevelName ?? null);
|
||||||
|
|
||||||
/* =========================================
|
/* =========================================
|
||||||
* 8. map response
|
* 8. map response
|
||||||
|
|
@ -2287,7 +2304,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
});
|
});
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
const currentHolder = profile.current_holders?.find(
|
const currentHolder = profile.current_holders?.find(
|
||||||
x =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft === false &&
|
x.orgRevision?.orgRevisionIsDraft === false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent === true,
|
x.orgRevision?.orgRevisionIsCurrent === true,
|
||||||
);
|
);
|
||||||
|
|
@ -2310,9 +2327,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
* 2. current holder
|
* 2. current holder
|
||||||
* ========================================= */
|
* ========================================= */
|
||||||
const currentHolder = profile.current_holders?.find(
|
const currentHolder = profile.current_holders?.find(
|
||||||
x =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft === false &&
|
x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true,
|
||||||
x.orgRevision?.orgRevisionIsCurrent === true,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/* =========================================
|
/* =========================================
|
||||||
|
|
@ -4180,7 +4196,6 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("find/employee/position")
|
@Post("find/employee/position")
|
||||||
async GetProfileByPositionEmpAsync(
|
async GetProfileByPositionEmpAsync(
|
||||||
@Request() req: RequestWithUser,
|
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
empPosId: string[];
|
empPosId: string[];
|
||||||
|
|
@ -4601,8 +4616,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
orgChild2: true,
|
orgChild2: true,
|
||||||
orgChild3: true,
|
orgChild3: true,
|
||||||
orgChild4: true,
|
orgChild4: true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||||
|
|
@ -4879,9 +4894,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
// }),
|
// }),
|
||||||
// );
|
// );
|
||||||
const profile_ = profile.map((item: Profile) => {
|
const profile_ = profile.map((item: Profile) => {
|
||||||
const holder = item.current_holders?.find(
|
const holder = item.current_holders?.find((x) => x.orgRevisionId === findRevision?.id);
|
||||||
(x) => x.orgRevisionId === findRevision?.id,
|
|
||||||
);
|
|
||||||
|
|
||||||
const rootName = holder?.orgRoot?.orgRootName ?? null;
|
const rootName = holder?.orgRoot?.orgRootName ?? null;
|
||||||
|
|
||||||
|
|
@ -5101,7 +5114,6 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("keycloak-all-officer")
|
@Post("keycloak-all-officer")
|
||||||
async PostProfileWithKeycloakAllOfficer(
|
async PostProfileWithKeycloakAllOfficer(
|
||||||
@Request() req: RequestWithUser,
|
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
node: number;
|
node: number;
|
||||||
|
|
@ -5272,7 +5284,6 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("keycloak-all-officer/date")
|
@Post("keycloak-all-officer/date")
|
||||||
async PostProfileWithKeycloakAllOfficerDate(
|
async PostProfileWithKeycloakAllOfficerDate(
|
||||||
@Request() req: RequestWithUser,
|
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
node: number;
|
node: number;
|
||||||
|
|
@ -5451,7 +5462,6 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("none-validate-keycloak-all-officer")
|
@Post("none-validate-keycloak-all-officer")
|
||||||
async PostProfileWithNoneValidateKeycloakAllOfficer(
|
async PostProfileWithNoneValidateKeycloakAllOfficer(
|
||||||
@Request() req: RequestWithUser,
|
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
node: number;
|
node: number;
|
||||||
|
|
@ -5621,7 +5631,6 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("find-node-name")
|
@Post("find-node-name")
|
||||||
async findNodeName(
|
async findNodeName(
|
||||||
@Request() req: RequestWithUser,
|
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
node: number;
|
node: number;
|
||||||
|
|
@ -5730,7 +5739,6 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("officer-by-admin-role")
|
@Post("officer-by-admin-role")
|
||||||
async GetOfficersByAdminRole(
|
async GetOfficersByAdminRole(
|
||||||
@Request() req: RequestWithUser,
|
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
node: number;
|
node: number;
|
||||||
|
|
@ -5785,8 +5793,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
typeCondition = {};
|
typeCondition = {};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if (body.role === "BROTHER") {
|
||||||
else if (body.role === "BROTHER") {
|
|
||||||
switch (body.node) {
|
switch (body.node) {
|
||||||
case 0:
|
case 0:
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
|
|
@ -6069,7 +6076,6 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("keycloak-all-employee")
|
@Post("keycloak-all-employee")
|
||||||
async PostProfileWithKeycloakAllEmployee(
|
async PostProfileWithKeycloakAllEmployee(
|
||||||
@Request() req: RequestWithUser,
|
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
node: number;
|
node: number;
|
||||||
|
|
@ -6223,7 +6229,6 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("none-validate-keycloak-all-employee")
|
@Post("none-validate-keycloak-all-employee")
|
||||||
async PostProfileWithNoneValidateKeycloakAllEmployee(
|
async PostProfileWithNoneValidateKeycloakAllEmployee(
|
||||||
@Request() req: RequestWithUser,
|
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
node: number;
|
node: number;
|
||||||
|
|
@ -6377,7 +6382,6 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("employee-by-admin-role")
|
@Post("employee-by-admin-role")
|
||||||
async GetEmployeesByAdminRole(
|
async GetEmployeesByAdminRole(
|
||||||
@Request() req: RequestWithUser,
|
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
node: number;
|
node: number;
|
||||||
|
|
@ -6434,8 +6438,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
typeCondition = {};
|
typeCondition = {};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if (body.role === "BROTHER") {
|
||||||
else if (body.role === "BROTHER") {
|
|
||||||
switch (body.node) {
|
switch (body.node) {
|
||||||
case 0:
|
case 0:
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
|
|
@ -7350,10 +7353,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
|
|
||||||
@Post("profile-leave/keycloak")
|
@Post("profile-leave/keycloak")
|
||||||
async GetProfileLeaveReportByKeycloakIdAsync(
|
async GetProfileLeaveReportByKeycloakIdAsync(
|
||||||
@Body() body: {
|
@Body() body: { keycloakId: string; report?: string },
|
||||||
keycloakId: string,
|
|
||||||
report?: string
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
relations: {
|
relations: {
|
||||||
|
|
@ -7396,14 +7396,14 @@ export class OrganizationDotnetController extends Controller {
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
keycloak: body.keycloakId,
|
keycloak: body.keycloakId,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
/* =========================================
|
/* =========================================
|
||||||
* current holder
|
* current holder
|
||||||
* ========================================= */
|
* ========================================= */
|
||||||
const currentHolder = profile.current_holders?.find(
|
const currentHolder = profile.current_holders?.find(
|
||||||
x =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft === false &&
|
x.orgRevision?.orgRevisionIsDraft === false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent === true,
|
x.orgRevision?.orgRevisionIsCurrent === true,
|
||||||
);
|
);
|
||||||
|
|
@ -7425,18 +7425,20 @@ export class OrganizationDotnetController extends Controller {
|
||||||
let _positions: any[] = [];
|
let _positions: any[] = [];
|
||||||
let _educations: any[] = [];
|
let _educations: any[] = [];
|
||||||
if (body.report && ["LEAVE16", "LEAVE18"].includes(body.report.trim().toUpperCase())) {
|
if (body.report && ["LEAVE16", "LEAVE18"].includes(body.report.trim().toUpperCase())) {
|
||||||
|
|
||||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
||||||
let _currentDate = CURRENT_DATE[0].today;
|
let _currentDate = CURRENT_DATE[0].today;
|
||||||
if (profile && profile?.isLeave) {
|
if (profile && profile?.isLeave) {
|
||||||
_currentDate =
|
_currentDate =
|
||||||
profile && profile.leaveDate ? Extension.toDateOnlyString(profile.leaveDate) : _currentDate;
|
profile && profile.leaveDate
|
||||||
|
? Extension.toDateOnlyString(profile.leaveDate)
|
||||||
|
: _currentDate;
|
||||||
}
|
}
|
||||||
const positions = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [
|
const positions = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [
|
||||||
profile!.id,
|
profile!.id,
|
||||||
_currentDate,
|
_currentDate,
|
||||||
]);
|
]);
|
||||||
_positions = positions[0].length > 0
|
_positions =
|
||||||
|
positions[0].length > 0
|
||||||
? _positions.slice(0, -1).map((x: any, idx: number) => ({
|
? _positions.slice(0, -1).map((x: any, idx: number) => ({
|
||||||
positionName: x.positionName,
|
positionName: x.positionName,
|
||||||
dateStart: x.commandDateAffect ?? null,
|
dateStart: x.commandDateAffect ?? null,
|
||||||
|
|
@ -7448,7 +7450,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
where: { profileEmployeeId: profile!.id, isDeleted: false },
|
where: { profileEmployeeId: profile!.id, isDeleted: false },
|
||||||
order: { level: "ASC" },
|
order: { level: "ASC" },
|
||||||
});
|
});
|
||||||
_educations = profileEducations.length > 0
|
_educations =
|
||||||
|
profileEducations.length > 0
|
||||||
? profileEducations.map((x) => ({
|
? profileEducations.map((x) => ({
|
||||||
educationLevel: x.educationLevel,
|
educationLevel: x.educationLevel,
|
||||||
institute: x.institute ?? "-",
|
institute: x.institute ?? "-",
|
||||||
|
|
@ -7465,15 +7468,11 @@ export class OrganizationDotnetController extends Controller {
|
||||||
lastName: profile.lastName,
|
lastName: profile.lastName,
|
||||||
citizenId: profile.citizenId,
|
citizenId: profile.citizenId,
|
||||||
birthDate: profile.birthDate,
|
birthDate: profile.birthDate,
|
||||||
retireDate: profile.birthDate
|
retireDate: profile.birthDate ? calculateRetireLaw(profile.birthDate) : null,
|
||||||
? calculateRetireLaw(profile.birthDate)
|
|
||||||
: null,
|
|
||||||
govAge: profile.dateAppoint
|
govAge: profile.dateAppoint
|
||||||
? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี`
|
? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี`
|
||||||
: null,
|
: null,
|
||||||
age: profile.birthDate
|
age: profile.birthDate ? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0, "GET") : null,
|
||||||
? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0, "GET")
|
|
||||||
: null,
|
|
||||||
dateAppoint: profile.dateAppoint,
|
dateAppoint: profile.dateAppoint,
|
||||||
dateCurrent: new Date(),
|
dateCurrent: new Date(),
|
||||||
amount: profile.amount,
|
amount: profile.amount,
|
||||||
|
|
@ -7516,9 +7515,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
* current holder
|
* current holder
|
||||||
* ========================================= */
|
* ========================================= */
|
||||||
const currentHolder = profile.current_holders?.find(
|
const currentHolder = profile.current_holders?.find(
|
||||||
x =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft === false &&
|
x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true,
|
||||||
x.orgRevision?.orgRevisionIsCurrent === true,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let oc = "";
|
let oc = "";
|
||||||
|
|
@ -7542,10 +7540,9 @@ export class OrganizationDotnetController extends Controller {
|
||||||
const positionLeaveName =
|
const positionLeaveName =
|
||||||
profile.posType &&
|
profile.posType &&
|
||||||
profile.posLevel &&
|
profile.posLevel &&
|
||||||
(profile.posType.posTypeName === "บริหาร" ||
|
(profile.posType.posTypeName === "บริหาร" || profile.posType.posTypeName === "อำนวยการ")
|
||||||
profile.posType.posTypeName === "อำนวยการ")
|
|
||||||
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
||||||
: profile.posLevel?.posLevelName ?? null;
|
: (profile.posLevel?.posLevelName ?? null);
|
||||||
|
|
||||||
/* =========================================
|
/* =========================================
|
||||||
* position executive
|
* position executive
|
||||||
|
|
@ -7565,18 +7562,20 @@ export class OrganizationDotnetController extends Controller {
|
||||||
let _positions: any[] = [];
|
let _positions: any[] = [];
|
||||||
let _educations: any[] = [];
|
let _educations: any[] = [];
|
||||||
if (body.report && ["LEAVE16", "LEAVE18"].includes(body.report.trim().toUpperCase())) {
|
if (body.report && ["LEAVE16", "LEAVE18"].includes(body.report.trim().toUpperCase())) {
|
||||||
|
|
||||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
||||||
let _currentDate = CURRENT_DATE[0].today;
|
let _currentDate = CURRENT_DATE[0].today;
|
||||||
if (profile && profile?.isLeave) {
|
if (profile && profile?.isLeave) {
|
||||||
_currentDate =
|
_currentDate =
|
||||||
profile && profile.leaveDate ? Extension.toDateOnlyString(profile.leaveDate) : _currentDate;
|
profile && profile.leaveDate
|
||||||
|
? Extension.toDateOnlyString(profile.leaveDate)
|
||||||
|
: _currentDate;
|
||||||
}
|
}
|
||||||
const positions = await AppDataSource.query("CALL GetProfileSalaryPosition(?, ?)", [
|
const positions = await AppDataSource.query("CALL GetProfileSalaryPosition(?, ?)", [
|
||||||
profile!.id,
|
profile!.id,
|
||||||
_currentDate,
|
_currentDate,
|
||||||
]);
|
]);
|
||||||
_positions = positions[0].length > 0
|
_positions =
|
||||||
|
positions[0].length > 0
|
||||||
? _positions.slice(0, -1).map((x: any, idx: number) => ({
|
? _positions.slice(0, -1).map((x: any, idx: number) => ({
|
||||||
positionName: x.positionName,
|
positionName: x.positionName,
|
||||||
dateStart: x.commandDateAffect ?? null,
|
dateStart: x.commandDateAffect ?? null,
|
||||||
|
|
@ -7588,7 +7587,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
where: { profileId: profile!.id, isDeleted: false },
|
where: { profileId: profile!.id, isDeleted: false },
|
||||||
order: { level: "ASC" },
|
order: { level: "ASC" },
|
||||||
});
|
});
|
||||||
_educations = profileEducations.length > 0
|
_educations =
|
||||||
|
profileEducations.length > 0
|
||||||
? profileEducations.map((x) => ({
|
? profileEducations.map((x) => ({
|
||||||
educationLevel: x.educationLevel,
|
educationLevel: x.educationLevel,
|
||||||
institute: x.institute ?? "-",
|
institute: x.institute ?? "-",
|
||||||
|
|
@ -7605,15 +7605,11 @@ export class OrganizationDotnetController extends Controller {
|
||||||
lastName: profile.lastName,
|
lastName: profile.lastName,
|
||||||
citizenId: profile.citizenId,
|
citizenId: profile.citizenId,
|
||||||
birthDate: profile.birthDate,
|
birthDate: profile.birthDate,
|
||||||
retireDate: profile.birthDate
|
retireDate: profile.birthDate ? calculateRetireLaw(profile.birthDate) : null,
|
||||||
? calculateRetireLaw(profile.birthDate)
|
|
||||||
: null,
|
|
||||||
govAge: profile.dateAppoint
|
govAge: profile.dateAppoint
|
||||||
? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี`
|
? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี`
|
||||||
: null,
|
: null,
|
||||||
age: profile.birthDate
|
age: profile.birthDate ? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0, "GET") : null,
|
||||||
? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0, "GET")
|
|
||||||
: null,
|
|
||||||
dateAppoint: profile.dateAppoint,
|
dateAppoint: profile.dateAppoint,
|
||||||
dateCurrent: new Date(),
|
dateCurrent: new Date(),
|
||||||
amount: profile.amount,
|
amount: profile.amount,
|
||||||
|
|
@ -7661,7 +7657,6 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("find/insignia-requests-profile/{type}")
|
@Post("find/insignia-requests-profile/{type}")
|
||||||
async GetInsigniaRequestsProfileAsync(
|
async GetInsigniaRequestsProfileAsync(
|
||||||
@Request() req: RequestWithUser,
|
|
||||||
@Path() type: string,
|
@Path() type: string,
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
|
|
@ -7791,7 +7786,6 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("officer-by-admin-rolev2")
|
@Post("officer-by-admin-rolev2")
|
||||||
async GetOfficersByAdminRoleV2(
|
async GetOfficersByAdminRoleV2(
|
||||||
@Request() req: RequestWithUser,
|
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
node: number;
|
node: number;
|
||||||
|
|
@ -7836,8 +7830,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
typeCondition = {};
|
typeCondition = {};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if (body.role === "BROTHER") {
|
||||||
else if (body.role === "BROTHER") {
|
|
||||||
switch (body.node) {
|
switch (body.node) {
|
||||||
case 0:
|
case 0:
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
|
|
@ -8016,7 +8009,6 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("officer-by-admin-rolev3")
|
@Post("officer-by-admin-rolev3")
|
||||||
async GetOfficersByAdminRoleV3(
|
async GetOfficersByAdminRoleV3(
|
||||||
@Request() req: RequestWithUser,
|
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
node: number;
|
node: number;
|
||||||
|
|
@ -8073,8 +8065,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
typeCondition = {};
|
typeCondition = {};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if (body.role === "BROTHER") {
|
||||||
else if (body.role === "BROTHER") {
|
|
||||||
switch (body.node) {
|
switch (body.node) {
|
||||||
case 0:
|
case 0:
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
|
|
@ -8364,7 +8355,6 @@ export class OrganizationDotnetController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("officer-by-admin-rolev4")
|
@Post("officer-by-admin-rolev4")
|
||||||
async GetOfficersByAdminRoleV4(
|
async GetOfficersByAdminRoleV4(
|
||||||
@Request() req: RequestWithUser,
|
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
node: number;
|
node: number;
|
||||||
|
|
@ -8409,8 +8399,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
typeCondition = {};
|
typeCondition = {};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if (body.role === "BROTHER") {
|
||||||
else if (body.role === "BROTHER") {
|
|
||||||
switch (body.node) {
|
switch (body.node) {
|
||||||
case 0:
|
case 0:
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
|
|
@ -8608,8 +8597,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
);
|
);
|
||||||
|
|
||||||
return new HttpSuccess(
|
return new HttpSuccess(
|
||||||
(profile_ ?? []).sort((a, b) =>
|
(profile_ ?? []).sort((a, b) => a.posNo.localeCompare(b.posNo, undefined, { numeric: true })),
|
||||||
a.posNo.localeCompare(b.posNo, undefined, { numeric: true }))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8626,18 +8614,13 @@ export class OrganizationDotnetController extends Controller {
|
||||||
profileId: string;
|
profileId: string;
|
||||||
assignId: string;
|
assignId: string;
|
||||||
},
|
},
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
) {
|
) {
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { id: requestBody.profileId },
|
where: { id: requestBody.profileId },
|
||||||
relations: [
|
relations: ["current_holders", "current_holders.orgRevision"],
|
||||||
"current_holders",
|
|
||||||
"current_holders.orgRevision"
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!profile)
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
|
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
where: { id: requestBody.assignId.trim().toLocaleUpperCase() },
|
where: { id: requestBody.assignId.trim().toLocaleUpperCase() },
|
||||||
|
|
@ -8647,7 +8630,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลระบบสิทธิ์หน้าที่ความรับผิดชอบ");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลระบบสิทธิ์หน้าที่ความรับผิดชอบ");
|
||||||
|
|
||||||
const currentHolder = profile.current_holders?.find(
|
const currentHolder = profile.current_holders?.find(
|
||||||
h => h.orgRevision?.orgRevisionIsCurrent && !h.orgRevision?.orgRevisionIsDraft,
|
(h) => h.orgRevision?.orgRevisionIsCurrent && !h.orgRevision?.orgRevisionIsDraft,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!currentHolder)
|
if (!currentHolder)
|
||||||
|
|
@ -8690,7 +8673,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
profileId: profile.id,
|
profileId: profile.id,
|
||||||
})
|
})
|
||||||
.andWhere("assign.assignId = :assignId", {
|
.andWhere("assign.assignId = :assignId", {
|
||||||
assignId: assign.id
|
assignId: assign.id,
|
||||||
})
|
})
|
||||||
.getRawMany();
|
.getRawMany();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue