Merge branch 'develop' into adiDev
# Conflicts: # src/controllers/ProfileController.ts
This commit is contained in:
commit
48ce332d19
6 changed files with 420 additions and 418 deletions
|
|
@ -1389,10 +1389,10 @@ export class CommandController extends Controller {
|
||||||
where: { id },
|
where: { id },
|
||||||
relations: ["commandSigns"],
|
relations: ["commandSigns"],
|
||||||
order: {
|
order: {
|
||||||
commandSigns:{
|
commandSigns: {
|
||||||
createdAt: "ASC"
|
createdAt: "ASC",
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!command) {
|
if (!command) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
|
||||||
|
|
@ -1488,8 +1488,8 @@ export class CommandController extends Controller {
|
||||||
commandSign.lastUpdateFullName = request.user.name;
|
commandSign.lastUpdateFullName = request.user.name;
|
||||||
commandSign.lastUpdatedAt = new Date();
|
commandSign.lastUpdatedAt = new Date();
|
||||||
await this.commandSignRepository.save(commandSign);
|
await this.commandSignRepository.save(commandSign);
|
||||||
if(commandSign.isSignatory == true)
|
if (commandSign.isSignatory == true)
|
||||||
await this.PutSelectPending(commandSign.commandId, { sign: true }, request);
|
await this.PutSelectPending(commandSign.commandId, { sign: true }, request);
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -1517,6 +1517,8 @@ export class CommandController extends Controller {
|
||||||
prefix: string | null;
|
prefix: string | null;
|
||||||
firstName: string | null;
|
firstName: string | null;
|
||||||
lastName: string | null;
|
lastName: string | null;
|
||||||
|
remarkVertical?: string | null;
|
||||||
|
remarkHorizontal?: string | null;
|
||||||
}[];
|
}[];
|
||||||
},
|
},
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
|
|
@ -1601,6 +1603,14 @@ export class CommandController extends Controller {
|
||||||
let commandRecive = new CommandRecive();
|
let commandRecive = new CommandRecive();
|
||||||
commandRecive = Object.assign(new CommandRecive(), item);
|
commandRecive = Object.assign(new CommandRecive(), item);
|
||||||
commandRecive.order = order;
|
commandRecive.order = order;
|
||||||
|
// commandRecive.amount = "xxxxxxxxxx";
|
||||||
|
// commandRecive.positionSalaryAmount = "xxxxxxxxxx";
|
||||||
|
// commandRecive.mouthSalaryAmount = "xxxxxxxxxx";
|
||||||
|
commandRecive.remarkVertical =
|
||||||
|
item.remarkVertical == null ? null_ : item.remarkVertical;
|
||||||
|
commandRecive.remarkHorizontal =
|
||||||
|
item.remarkHorizontal == null ? null_ : item.remarkHorizontal;
|
||||||
|
commandRecive.order = order;
|
||||||
commandRecive.commandId = command.id;
|
commandRecive.commandId = command.id;
|
||||||
commandRecive.createdUserId = request.user.sub;
|
commandRecive.createdUserId = request.user.sub;
|
||||||
commandRecive.createdFullName = request.user.name;
|
commandRecive.createdFullName = request.user.name;
|
||||||
|
|
|
||||||
|
|
@ -1679,7 +1679,7 @@ export class PositionController extends Controller {
|
||||||
}
|
}
|
||||||
masterId = [...new Set(masterId)];
|
masterId = [...new Set(masterId)];
|
||||||
}
|
}
|
||||||
|
|
||||||
const revisionCondition = {
|
const revisionCondition = {
|
||||||
orgRevisionId: body.revisionId,
|
orgRevisionId: body.revisionId,
|
||||||
};
|
};
|
||||||
|
|
@ -1695,157 +1695,156 @@ export class PositionController extends Controller {
|
||||||
child4: null,
|
child4: null,
|
||||||
privilege: "OWNER",
|
privilege: "OWNER",
|
||||||
};
|
};
|
||||||
const conditions = [
|
const conditions = [
|
||||||
|
{
|
||||||
|
...checkChildConditions,
|
||||||
|
...typeCondition,
|
||||||
|
...revisionCondition,
|
||||||
|
...(body.keyword &&
|
||||||
|
(masterId.length > 0
|
||||||
|
? { id: In(masterId) }
|
||||||
|
: { posMasterNo: Like(`%${body.keyword}%`) })),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
let [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||||
|
.createQueryBuilder("posMaster")
|
||||||
|
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
||||||
|
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
||||||
|
.leftJoinAndSelect("posMaster.orgChild2", "orgChild2")
|
||||||
|
.leftJoinAndSelect("posMaster.orgChild3", "orgChild3")
|
||||||
|
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
|
||||||
|
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
|
||||||
|
.leftJoinAndSelect("posMaster.next_holder", "next_holder")
|
||||||
|
.leftJoinAndSelect("posMaster.orgRevision", "orgRevision")
|
||||||
|
.where(conditions)
|
||||||
|
.andWhere(
|
||||||
|
_data.root != undefined && _data.root != null
|
||||||
|
? _data.root[0] != null
|
||||||
|
? `posMaster.orgRootId IN (:...root)`
|
||||||
|
: `posMaster.orgRootId is null`
|
||||||
|
: "1=1",
|
||||||
{
|
{
|
||||||
...checkChildConditions,
|
root: _data.root,
|
||||||
...typeCondition,
|
|
||||||
...revisionCondition,
|
|
||||||
...(body.keyword &&
|
|
||||||
(masterId.length > 0
|
|
||||||
? { id: In(masterId) }
|
|
||||||
: { posMasterNo: Like(`%${body.keyword}%`) })),
|
|
||||||
},
|
},
|
||||||
];
|
)
|
||||||
|
.andWhere(
|
||||||
let [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
_data.child1 != undefined && _data.child1 != null
|
||||||
.createQueryBuilder("posMaster")
|
? _data.child1[0] != null
|
||||||
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
? `posMaster.orgChild1Id IN (:...child1)`
|
||||||
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
: `posMaster.orgChild1Id is null`
|
||||||
.leftJoinAndSelect("posMaster.orgChild2", "orgChild2")
|
: "1=1",
|
||||||
.leftJoinAndSelect("posMaster.orgChild3", "orgChild3")
|
{
|
||||||
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
|
child1: _data.child1,
|
||||||
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
|
},
|
||||||
.leftJoinAndSelect("posMaster.next_holder", "next_holder")
|
)
|
||||||
.leftJoinAndSelect("posMaster.orgRevision", "orgRevision")
|
.andWhere(
|
||||||
.where(conditions)
|
_data.child2 != undefined && _data.child2 != null
|
||||||
.andWhere(
|
? _data.child2[0] != null
|
||||||
_data.root != undefined && _data.root != null
|
? `posMaster.orgChild2Id IN (:...child2)`
|
||||||
? _data.root[0] != null
|
: `posMaster.orgChild2Id is null`
|
||||||
? `posMaster.orgRootId IN (:...root)`
|
: "1=1",
|
||||||
: `posMaster.orgRootId is null`
|
{
|
||||||
: "1=1",
|
child2: _data.child2,
|
||||||
{
|
},
|
||||||
root: _data.root,
|
)
|
||||||
},
|
.andWhere(
|
||||||
)
|
_data.child3 != undefined && _data.child3 != null
|
||||||
.andWhere(
|
? _data.child3[0] != null
|
||||||
_data.child1 != undefined && _data.child1 != null
|
? `posMaster.orgChild3Id IN (:...child3)`
|
||||||
? _data.child1[0] != null
|
: `posMaster.orgChild3Id is null`
|
||||||
? `posMaster.orgChild1Id IN (:...child1)`
|
: "1=1",
|
||||||
: `posMaster.orgChild1Id is null`
|
{
|
||||||
: "1=1",
|
child3: _data.child3,
|
||||||
{
|
},
|
||||||
child1: _data.child1,
|
)
|
||||||
},
|
.andWhere(
|
||||||
)
|
_data.child4 != undefined && _data.child4 != null
|
||||||
.andWhere(
|
? _data.child4[0] != null
|
||||||
_data.child2 != undefined && _data.child2 != null
|
? `posMaster.orgChild4Id IN (:...child4)`
|
||||||
? _data.child2[0] != null
|
: `posMaster.orgChild4Id is null`
|
||||||
? `posMaster.orgChild2Id IN (:...child2)`
|
: "1=1",
|
||||||
: `posMaster.orgChild2Id is null`
|
{
|
||||||
: "1=1",
|
child4: _data.child4,
|
||||||
{
|
},
|
||||||
child2: _data.child2,
|
)
|
||||||
},
|
.orWhere(
|
||||||
)
|
new Brackets((qb) => {
|
||||||
.andWhere(
|
qb.andWhere(
|
||||||
_data.child3 != undefined && _data.child3 != null
|
body.keyword != null && body.keyword != ""
|
||||||
? _data.child3[0] != null
|
? body.isAll == false
|
||||||
? `posMaster.orgChild3Id IN (:...child3)`
|
? searchShortName
|
||||||
: `posMaster.orgChild3Id is null`
|
: `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
)
|
||||||
child3: _data.child3,
|
.andWhere(checkChildConditions)
|
||||||
},
|
.andWhere(typeCondition)
|
||||||
)
|
.andWhere(revisionCondition);
|
||||||
.andWhere(
|
}),
|
||||||
_data.child4 != undefined && _data.child4 != null
|
)
|
||||||
? _data.child4[0] != null
|
.orWhere(
|
||||||
? `posMaster.orgChild4Id IN (:...child4)`
|
new Brackets((qb) => {
|
||||||
: `posMaster.orgChild4Id is null`
|
qb.andWhere(
|
||||||
: "1=1",
|
body.keyword != null && body.keyword != ""
|
||||||
{
|
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
||||||
child4: _data.child4,
|
: "1=1",
|
||||||
},
|
{
|
||||||
)
|
keyword: `%${body.keyword}%`,
|
||||||
.orWhere(
|
},
|
||||||
new Brackets((qb) => {
|
)
|
||||||
qb.andWhere(
|
.andWhere(checkChildConditions)
|
||||||
body.keyword != null && body.keyword != ""
|
.andWhere(typeCondition)
|
||||||
? body.isAll == false
|
.andWhere(revisionCondition);
|
||||||
? searchShortName
|
}),
|
||||||
: `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'`
|
)
|
||||||
: "1=1",
|
.orWhere(
|
||||||
)
|
new Brackets((qb) => {
|
||||||
.andWhere(checkChildConditions)
|
qb.andWhere(
|
||||||
.andWhere(typeCondition)
|
body.keyword != null && body.keyword != ""
|
||||||
.andWhere(revisionCondition);
|
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
|
||||||
}),
|
: "1=1",
|
||||||
)
|
{
|
||||||
.orWhere(
|
keyword: `%${body.keyword}%`,
|
||||||
new Brackets((qb) => {
|
},
|
||||||
qb.andWhere(
|
)
|
||||||
body.keyword != null && body.keyword != ""
|
.andWhere(checkChildConditions)
|
||||||
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
.andWhere(typeCondition)
|
||||||
: "1=1",
|
.andWhere(revisionCondition);
|
||||||
{
|
}),
|
||||||
keyword: `%${body.keyword}%`,
|
)
|
||||||
},
|
.orderBy("posMaster.posMasterOrder", "ASC")
|
||||||
)
|
.skip((body.page - 1) * body.pageSize)
|
||||||
.andWhere(checkChildConditions)
|
.take(body.pageSize)
|
||||||
.andWhere(typeCondition)
|
.getManyAndCount();
|
||||||
.andWhere(revisionCondition);
|
|
||||||
}),
|
//แก้ค้นหา
|
||||||
)
|
let _position: any[] = [];
|
||||||
.orWhere(
|
let x: any = null;
|
||||||
new Brackets((qb) => {
|
let y: any = null;
|
||||||
qb.andWhere(
|
if (body.keyword != null && body.keyword != "") {
|
||||||
body.keyword != null && body.keyword != ""
|
const position = await this.positionRepository.find({
|
||||||
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
|
relations: ["posType", "posLevel", "posExecutive"],
|
||||||
: "1=1",
|
where: { posMasterId: In(posMaster.map((x) => x.id)) },
|
||||||
{
|
order: { createdAt: "ASC" },
|
||||||
keyword: `%${body.keyword}%`,
|
});
|
||||||
},
|
for (let data of position) {
|
||||||
)
|
x = data.posMasterId;
|
||||||
.andWhere(checkChildConditions)
|
if (y != x) {
|
||||||
.andWhere(typeCondition)
|
if (
|
||||||
.andWhere(revisionCondition);
|
data.positionName.includes(body.keyword) ||
|
||||||
}),
|
data.posType.posTypeName.includes(body.keyword) ||
|
||||||
)
|
data.posLevel.posLevelName.includes(body.keyword)
|
||||||
.orderBy("posMaster.posMasterOrder", "ASC")
|
) {
|
||||||
.skip((body.page - 1) * body.pageSize)
|
_position.push(data);
|
||||||
.take(body.pageSize)
|
|
||||||
.getManyAndCount();
|
|
||||||
|
|
||||||
//แก้ค้นหา
|
|
||||||
let _position: any[] = [];
|
|
||||||
let x: any = null;
|
|
||||||
let y: any = null;
|
|
||||||
if (body.keyword != null && body.keyword != ""){
|
|
||||||
const position = await this.positionRepository.find({
|
|
||||||
relations: ["posType", "posLevel", "posExecutive"],
|
|
||||||
where: { posMasterId: In(posMaster.map(x => x.id))},
|
|
||||||
order: { createdAt: "ASC" }
|
|
||||||
});
|
|
||||||
for(let data of position){
|
|
||||||
x = data.posMasterId
|
|
||||||
if(y != x){
|
|
||||||
if(
|
|
||||||
data.positionName.includes(body.keyword) ||
|
|
||||||
data.posType.posTypeName.includes(body.keyword) ||
|
|
||||||
data.posLevel.posLevelName.includes(body.keyword)
|
|
||||||
){
|
|
||||||
_position.push(data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
y = x;
|
|
||||||
}
|
}
|
||||||
|
y = x;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(_position.length > 0){
|
|
||||||
posMaster = posMaster.filter((x) => _position.some(y => y.posMasterId === x.id));
|
if (_position.length > 0) {
|
||||||
}
|
posMaster = posMaster.filter((x) => _position.some((y) => y.posMasterId === x.id));
|
||||||
|
}
|
||||||
|
|
||||||
const formattedData = await Promise.all(
|
const formattedData = await Promise.all(
|
||||||
posMaster.map(async (posMaster) => {
|
posMaster.map(async (posMaster) => {
|
||||||
|
|
@ -3312,10 +3311,10 @@ export class PositionController extends Controller {
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
const _posType = await this.posTypeRepository.find({
|
const _posType = await this.posTypeRepository.find({
|
||||||
where: { posTypeName: In(["ทั่วไป", "วิชาการ"]) }
|
where: { posTypeName: In(["ทั่วไป", "วิชาการ"]) },
|
||||||
});
|
});
|
||||||
const _posLevel = await this.posLevelRepository.find({
|
const _posLevel = await this.posLevelRepository.find({
|
||||||
where: { posLevelName: In(["ปฏิบัติงาน", "ปฏิบัติการ"]) }
|
where: { posLevelName: In(["ปฏิบัติงาน", "ปฏิบัติการ"]) },
|
||||||
});
|
});
|
||||||
|
|
||||||
const formattedData = await Promise.all(
|
const formattedData = await Promise.all(
|
||||||
|
|
@ -3382,12 +3381,13 @@ export class PositionController extends Controller {
|
||||||
nodeId = posMaster.orgRootId;
|
nodeId = posMaster.orgRootId;
|
||||||
}
|
}
|
||||||
|
|
||||||
let _position: any
|
let _position: any;
|
||||||
if( posLevel == null && posType == null && body.position != null) {
|
if (posLevel == null && posType == null && body.position != null) {
|
||||||
_position = posMaster.positions
|
_position = posMaster.positions
|
||||||
.filter((x:any) =>
|
.filter(
|
||||||
_posType.some((y:any) => y.id == x.posTypeId) &&
|
(x: any) =>
|
||||||
_posLevel.some((z:any) => z.id == x.posLevelId)
|
_posType.some((y: any) => y.id == x.posTypeId) &&
|
||||||
|
_posLevel.some((z: any) => z.id == x.posLevelId),
|
||||||
)
|
)
|
||||||
.map((position) => ({
|
.map((position) => ({
|
||||||
id: position.id,
|
id: position.id,
|
||||||
|
|
@ -3405,8 +3405,7 @@ export class PositionController extends Controller {
|
||||||
positionIsSelected: position.positionIsSelected,
|
positionIsSelected: position.positionIsSelected,
|
||||||
isSpecial: position.isSpecial,
|
isSpecial: position.isSpecial,
|
||||||
}));
|
}));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
_position = posMaster.positions.map((position) => ({
|
_position = posMaster.positions.map((position) => ({
|
||||||
id: position.id,
|
id: position.id,
|
||||||
positionName: position.positionName,
|
positionName: position.positionName,
|
||||||
|
|
@ -4594,7 +4593,7 @@ export class PositionController extends Controller {
|
||||||
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
|
.leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
|
||||||
.where(conditions)
|
.where(conditions)
|
||||||
.andWhere({
|
.andWhere({
|
||||||
current_holderId: Not(IsNull()),
|
current_holderId: IsNull(),
|
||||||
})
|
})
|
||||||
.andWhere(
|
.andWhere(
|
||||||
_data.root != undefined && _data.root != null
|
_data.root != undefined && _data.root != null
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import {
|
||||||
UpdateProfileMother,
|
UpdateProfileMother,
|
||||||
UpdateProfileCouple,
|
UpdateProfileCouple,
|
||||||
} from "../entities/Profile";
|
} from "../entities/Profile";
|
||||||
import { Any, Brackets, In, IsNull, Like, Not } from "typeorm";
|
import { Brackets, IsNull, Like, Not } from "typeorm";
|
||||||
import { OrgRevision } from "../entities/OrgRevision";
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
import { PosMaster } from "../entities/PosMaster";
|
import { PosMaster } from "../entities/PosMaster";
|
||||||
import { PosLevel } from "../entities/PosLevel";
|
import { PosLevel } from "../entities/PosLevel";
|
||||||
|
|
@ -40,7 +40,6 @@ import {
|
||||||
calculateAge,
|
calculateAge,
|
||||||
calculateRetireDate,
|
calculateRetireDate,
|
||||||
calculateRetireLaw,
|
calculateRetireLaw,
|
||||||
calculateRetireYear,
|
|
||||||
removeProfileInOrganize,
|
removeProfileInOrganize,
|
||||||
setLogDataDiff,
|
setLogDataDiff,
|
||||||
} from "../interfaces/utils";
|
} from "../interfaces/utils";
|
||||||
|
|
@ -54,25 +53,22 @@ import { ProfileCertificate } from "../entities/ProfileCertificate";
|
||||||
import { ProfileTraining } from "../entities/ProfileTraining";
|
import { ProfileTraining } from "../entities/ProfileTraining";
|
||||||
import { ProfileDiscipline } from "../entities/ProfileDiscipline";
|
import { ProfileDiscipline } from "../entities/ProfileDiscipline";
|
||||||
import { ProfileEducation } from "../entities/ProfileEducation";
|
import { ProfileEducation } from "../entities/ProfileEducation";
|
||||||
import { CreateProfileSalary, ProfileSalary } from "../entities/ProfileSalary";
|
import { ProfileSalary } from "../entities/ProfileSalary";
|
||||||
import { ProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
|
import { ProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
|
||||||
import { ProfileFamilyMother } from "../entities/ProfileFamilyMother";
|
import { ProfileFamilyMother } from "../entities/ProfileFamilyMother";
|
||||||
import { ProfileFamilyFather } from "../entities/ProfileFamilyFather";
|
import { ProfileFamilyFather } from "../entities/ProfileFamilyFather";
|
||||||
import CallAPI from "../interfaces/call-api";
|
|
||||||
import Extension from "../interfaces/extension";
|
import Extension from "../interfaces/extension";
|
||||||
import { Prefixe } from "../entities/Prefixe";
|
|
||||||
import { ProfileInsignia } from "../entities/ProfileInsignia";
|
import { ProfileInsignia } from "../entities/ProfileInsignia";
|
||||||
import { ProfileDisciplineHistory } from "../entities/ProfileDisciplineHistory";
|
|
||||||
import { ProfileLeave } from "../entities/ProfileLeave";
|
import { ProfileLeave } from "../entities/ProfileLeave";
|
||||||
import { updateName } from "../keycloak";
|
import { updateName } from "../keycloak";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
import { PosMasterAct } from "../entities/PosMasterAct";
|
import { PosMasterAct } from "../entities/PosMasterAct";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { OrgChild1 } from "../entities/OrgChild1";
|
|
||||||
import { viewCommanderDirector } from "../entities/view/viewCommanderDirector";
|
|
||||||
import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory";
|
import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory";
|
||||||
import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory";
|
import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory";
|
||||||
import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory";
|
import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory";
|
||||||
|
import { viewDirector } from "../entities/view/viewDirector";
|
||||||
|
import { viewDirectorActing } from "../entities/view/viewDirectorActing";
|
||||||
@Route("api/v1/org/profile")
|
@Route("api/v1/org/profile")
|
||||||
@Tags("Profile")
|
@Tags("Profile")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -105,17 +101,13 @@ export class ProfileController extends Controller {
|
||||||
private educationRepository = AppDataSource.getRepository(ProfileEducation);
|
private educationRepository = AppDataSource.getRepository(ProfileEducation);
|
||||||
private salaryRepository = AppDataSource.getRepository(ProfileSalary);
|
private salaryRepository = AppDataSource.getRepository(ProfileSalary);
|
||||||
private profileEducationRepository = AppDataSource.getRepository(ProfileEducation);
|
private profileEducationRepository = AppDataSource.getRepository(ProfileEducation);
|
||||||
private prefixRepo = AppDataSource.getRepository(Prefixe);
|
|
||||||
private provinceRepo = AppDataSource.getRepository(Province);
|
private provinceRepo = AppDataSource.getRepository(Province);
|
||||||
private districtRepo = AppDataSource.getRepository(District);
|
private districtRepo = AppDataSource.getRepository(District);
|
||||||
private subDistrictRepo = AppDataSource.getRepository(SubDistrict);
|
private subDistrictRepo = AppDataSource.getRepository(SubDistrict);
|
||||||
private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
||||||
private profileDisciplineRepo = AppDataSource.getRepository(ProfileDiscipline);
|
private profileDisciplineRepo = AppDataSource.getRepository(ProfileDiscipline);
|
||||||
private disciplineHistoryRepository = AppDataSource.getRepository(ProfileDisciplineHistory);
|
|
||||||
private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave);
|
private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave);
|
||||||
private posMasterActRepository = AppDataSource.getRepository(PosMasterAct);
|
private posMasterActRepository = AppDataSource.getRepository(PosMasterAct);
|
||||||
private orgChild1Repository = AppDataSource.getRepository(OrgChild1);
|
|
||||||
private viewCommanderDirectorRepository = AppDataSource.getRepository(viewCommanderDirector);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* report ประวัติแบบย่อ ข้าราชการ
|
* report ประวัติแบบย่อ ข้าราชการ
|
||||||
|
|
@ -265,7 +257,7 @@ export class ProfileController extends Controller {
|
||||||
? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString())
|
? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString())
|
||||||
: "-",
|
: "-",
|
||||||
registrationAddress: Extension.ToThaiNumber(
|
registrationAddress: Extension.ToThaiNumber(
|
||||||
`${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
|
`${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
|
||||||
),
|
),
|
||||||
salaryDate:
|
salaryDate:
|
||||||
profile.profileSalary.length > 0 && profile.profileSalary[0].date != null
|
profile.profileSalary.length > 0 && profile.profileSalary[0].date != null
|
||||||
|
|
@ -280,9 +272,7 @@ export class ProfileController extends Controller {
|
||||||
: "-",
|
: "-",
|
||||||
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||||
educations: Education,
|
educations: Education,
|
||||||
url: ImgUrl
|
url: ImgUrl ? ImgUrl : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
|
||||||
? ImgUrl
|
|
||||||
: `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
|
|
@ -679,116 +669,84 @@ export class ProfileController extends Controller {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
|
fullName: `${profiles?.prefix}${profiles?.firstName} ${profiles?.lastName}`,
|
||||||
prefix: profiles?.prefix != null ? profiles.prefix : "",
|
prefix: profiles?.prefix != null ? profiles.prefix : "",
|
||||||
firstName: profiles?.firstName != null ? profiles.firstName : "",
|
firstName: profiles?.firstName != null ? profiles.firstName : "",
|
||||||
lastName: profiles?.lastName != null ? profiles.lastName : "",
|
lastName: profiles?.lastName != null ? profiles.lastName : "",
|
||||||
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||||
birthDate: profiles?.birthDate
|
birthDate: profiles?.birthDate
|
||||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate))
|
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate))
|
||||||
: "",
|
: "",
|
||||||
retireDate:
|
retireDate:
|
||||||
profiles.dateRetireLaw != null
|
profiles.dateRetireLaw != null
|
||||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateRetireLaw))
|
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateRetireLaw))
|
||||||
: "",
|
: "",
|
||||||
appointDate: profiles?.dateAppoint
|
appointDate: profiles?.dateAppoint
|
||||||
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateAppoint))
|
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateAppoint))
|
||||||
: "",
|
: "",
|
||||||
citizenId:
|
citizenId:
|
||||||
profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
|
profiles.citizenId != null ? Extension.ToThaiNumber(profiles.citizenId.toString()) : "",
|
||||||
fatherFullName:
|
fatherFullName:
|
||||||
profileFamilyFather?.fatherPrefix ||
|
profileFamilyFather?.fatherPrefix ||
|
||||||
profileFamilyFather?.fatherFirstName ||
|
profileFamilyFather?.fatherFirstName ||
|
||||||
profileFamilyFather?.fatherLastName
|
profileFamilyFather?.fatherLastName
|
||||||
? `${profileFamilyFather?.fatherPrefix ?? ""}${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim()
|
? `${profileFamilyFather?.fatherPrefix ?? ""}${profileFamilyFather?.fatherFirstName ?? ""} ${profileFamilyFather?.fatherLastName ?? ""}`.trim()
|
||||||
: null,
|
: null,
|
||||||
motherFullName:
|
motherFullName:
|
||||||
profileFamilyMother?.motherPrefix ||
|
profileFamilyMother?.motherPrefix ||
|
||||||
profileFamilyMother?.motherFirstName ||
|
profileFamilyMother?.motherFirstName ||
|
||||||
profileFamilyMother?.motherLastName
|
profileFamilyMother?.motherLastName
|
||||||
? `${profileFamilyMother?.motherPrefix ?? ""}${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim()
|
? `${profileFamilyMother?.motherPrefix ?? ""}${profileFamilyMother?.motherFirstName ?? ""} ${profileFamilyMother?.motherLastName ?? ""}`.trim()
|
||||||
: null,
|
: null,
|
||||||
coupleFullName:
|
coupleFullName:
|
||||||
profileFamilyCouple?.couplePrefix ||
|
profileFamilyCouple?.couplePrefix ||
|
||||||
profileFamilyCouple?.coupleFirstName ||
|
profileFamilyCouple?.coupleFirstName ||
|
||||||
profileFamilyCouple?.coupleLastNameOld
|
profileFamilyCouple?.coupleLastNameOld
|
||||||
? `${profileFamilyCouple?.couplePrefix ?? ""}${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastName ?? ""}`.trim()
|
? `${profileFamilyCouple?.couplePrefix ?? ""}${profileFamilyCouple?.coupleFirstName ?? ""} ${profileFamilyCouple?.coupleLastName ?? ""}`.trim()
|
||||||
: null,
|
: null,
|
||||||
coupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null,
|
coupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null,
|
||||||
currentAddress:
|
currentAddress:
|
||||||
profiles.currentAddress != null ? Extension.ToThaiNumber(profiles.currentAddress) : "",
|
profiles.currentAddress != null ? Extension.ToThaiNumber(profiles.currentAddress) : "",
|
||||||
currentSubDistrict:
|
currentSubDistrict:
|
||||||
profiles.currentSubDistrict != null
|
profiles.currentSubDistrict != null
|
||||||
? Extension.ToThaiNumber(profiles.currentSubDistrict.name)
|
? Extension.ToThaiNumber(profiles.currentSubDistrict.name)
|
||||||
: "",
|
: "",
|
||||||
currentDistrict:
|
currentDistrict:
|
||||||
profiles.currentDistrict != null
|
profiles.currentDistrict != null
|
||||||
? Extension.ToThaiNumber(profiles.currentDistrict.name)
|
? Extension.ToThaiNumber(profiles.currentDistrict.name)
|
||||||
: "",
|
: "",
|
||||||
currentProvince:
|
currentProvince:
|
||||||
profiles.currentProvince != null
|
profiles.currentProvince != null
|
||||||
? Extension.ToThaiNumber(profiles.currentProvince.name)
|
? Extension.ToThaiNumber(profiles.currentProvince.name)
|
||||||
: "",
|
: "",
|
||||||
telephone:
|
telephone:
|
||||||
profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "",
|
profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "",
|
||||||
url: ImgUrl
|
url: ImgUrl
|
||||||
? ImgUrl
|
? ImgUrl
|
||||||
: `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
|
: `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
|
||||||
url1: _ImgUrl[0] ? _ImgUrl[0] : null,
|
url1: _ImgUrl[0] ? _ImgUrl[0] : null,
|
||||||
yearUpload1: profiles.profileAvatars[0] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt)) : null,
|
yearUpload1: profiles.profileAvatars[0] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[0].createdAt)) : null,
|
||||||
url2: _ImgUrl[1] ? _ImgUrl[1] : null,
|
url2: _ImgUrl[1] ? _ImgUrl[1] : null,
|
||||||
yearUpload2: profiles.profileAvatars[1] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[1].createdAt)) : null,
|
yearUpload2: profiles.profileAvatars[1] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[1].createdAt)) : null,
|
||||||
url3: _ImgUrl[2] ? _ImgUrl[2] : null,
|
url3: _ImgUrl[2] ? _ImgUrl[2] : null,
|
||||||
yearUpload3: profiles.profileAvatars[2] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[2].createdAt)) : null,
|
yearUpload3: profiles.profileAvatars[2] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[2].createdAt)) : null,
|
||||||
url4: _ImgUrl[3] ? _ImgUrl[3] : null,
|
url4: _ImgUrl[3] ? _ImgUrl[3] : null,
|
||||||
yearUpload4: profiles.profileAvatars[3] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[3].createdAt)) : null,
|
yearUpload4: profiles.profileAvatars[3] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[3].createdAt)) : null,
|
||||||
url5: _ImgUrl[4] ? _ImgUrl[4] : null,
|
url5: _ImgUrl[4] ? _ImgUrl[4] : null,
|
||||||
yearUpload5: profiles.profileAvatars[4] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[4].createdAt)) : null,
|
yearUpload5: profiles.profileAvatars[4] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[4].createdAt)) : null,
|
||||||
url6: _ImgUrl[5] ? _ImgUrl[5] : null,
|
url6: _ImgUrl[5] ? _ImgUrl[5] : null,
|
||||||
yearUpload6: profiles.profileAvatars[5] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[5].createdAt)) : null,
|
yearUpload6: profiles.profileAvatars[5] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[5].createdAt)) : null,
|
||||||
url7: _ImgUrl[6] ? _ImgUrl[6] : null,
|
url7: _ImgUrl[6] ? _ImgUrl[6] : null,
|
||||||
yearUpload7: profiles.profileAvatars[6] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[6].createdAt)) : null,
|
yearUpload7: profiles.profileAvatars[6] ? Extension.ToThaiNumber(Extension.ToThaiShortYear(profiles.profileAvatars[6].createdAt)) : null,
|
||||||
|
insignias,
|
||||||
// BirthDay: profiles?.birthDate
|
leaves,
|
||||||
// ? Extension.ToThaiNumber(new Date(profiles.birthDate).getDate().toString())
|
certs,
|
||||||
// : null,
|
trainings,
|
||||||
// BirthDayText:
|
disciplines,
|
||||||
// profiles.birthDate != null
|
educations,
|
||||||
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate).toString())
|
salarys,
|
||||||
// : "",
|
};
|
||||||
// BirthMonth: profiles?.birthDate
|
|
||||||
// ? Extension.ToThaiNumber(new Date(profiles.birthDate).getMonth() + (1).toString())
|
|
||||||
// : null, // Months are zero-based
|
|
||||||
// BirthYear: profiles?.birthDate
|
|
||||||
// ? Extension.ToThaiNumber(new Date(profiles.birthDate).getFullYear().toString())
|
|
||||||
// : null,
|
|
||||||
// BirthYearText:
|
|
||||||
// profiles.birthDate != null
|
|
||||||
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate).toString())
|
|
||||||
// : "",
|
|
||||||
// Address: "",
|
|
||||||
// District: "",
|
|
||||||
// Area: "",
|
|
||||||
// Province: "",
|
|
||||||
// CouplePrefix: profileFamilyCouple?.couplePrefix ?? "",
|
|
||||||
// FatherPrefix: profileFamilyFather?.fatherPrefix ?? "",
|
|
||||||
// MotherPrefix: profileFamilyMother?.motherPrefix ?? "",
|
|
||||||
// Division: "",
|
|
||||||
// Institute: "",
|
|
||||||
// StartDate: profiles?.dateStart
|
|
||||||
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateStart))
|
|
||||||
// : "",
|
|
||||||
// AvatarId: profiles?.avatar ?? null,
|
|
||||||
|
|
||||||
insignias,
|
|
||||||
leaves,
|
|
||||||
certs,
|
|
||||||
trainings,
|
|
||||||
disciplines,
|
|
||||||
educations,
|
|
||||||
salarys,
|
|
||||||
};
|
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
template: "kk1",
|
template: "kk1",
|
||||||
|
|
@ -1288,6 +1246,92 @@ export class ProfileController extends Controller {
|
||||||
|
|
||||||
return new HttpSuccess({ caregiver, commander, chairman });
|
return new HttpSuccess({ caregiver, commander, chairman });
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("commander-director-act")
|
||||||
|
async getProfileCommanderDirectorAct(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@Body() body: { isDirector: boolean; keyword: string; page: number; pageSize: number },
|
||||||
|
) {
|
||||||
|
const posMaster = await this.posMasterRepo.findOne({
|
||||||
|
where: {
|
||||||
|
current_holder: { keycloak: request.user.sub },
|
||||||
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
|
||||||
|
|
||||||
|
let condition: any = {
|
||||||
|
orgRootId: posMaster.orgRootId || "",
|
||||||
|
};
|
||||||
|
if (body.isDirector == true) {
|
||||||
|
condition = {
|
||||||
|
orgRootId: posMaster.orgRootId || "",
|
||||||
|
isDirector: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
|
||||||
|
.createQueryBuilder("viewDirectorActing")
|
||||||
|
.andWhere(condition)
|
||||||
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "CONCAT(viewDirectorActing.prefix,viewDirectorActing.firstName,' ',viewDirectorActing.lastName) LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "viewDirectorActing.citizenId LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "viewDirectorActing.position LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "viewDirectorActing.posLevel LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "viewDirectorActing.posType LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.orWhere(
|
||||||
|
body.keyword != null && body.keyword != ""
|
||||||
|
? "viewDirectorActing.actFullName LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${body.keyword}%`,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.skip((body.page - 1) * body.pageSize)
|
||||||
|
.take(body.pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
return new HttpSuccess({ data: lists, total });
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|
@ -1314,14 +1358,14 @@ export class ProfileController extends Controller {
|
||||||
isDirector: true,
|
isDirector: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const [lists, total] = await AppDataSource.getRepository(viewCommanderDirector)
|
const [lists, total] = await AppDataSource.getRepository(viewDirector)
|
||||||
.createQueryBuilder("viewCommanderDirector")
|
.createQueryBuilder("viewDirector")
|
||||||
.andWhere(condition)
|
.andWhere(condition)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.orWhere(
|
qb.orWhere(
|
||||||
body.keyword != null && body.keyword != ""
|
body.keyword != null && body.keyword != ""
|
||||||
? "CONCAT(viewCommanderDirector.prefix,viewCommanderDirector.firstName,' ',viewCommanderDirector.lastName) LIKE :keyword"
|
? "CONCAT(viewDirector.prefix,viewDirector.firstName,' ',viewDirector.lastName) LIKE :keyword"
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
keyword: `%${body.keyword}%`,
|
keyword: `%${body.keyword}%`,
|
||||||
|
|
@ -1329,7 +1373,7 @@ export class ProfileController extends Controller {
|
||||||
)
|
)
|
||||||
.orWhere(
|
.orWhere(
|
||||||
body.keyword != null && body.keyword != ""
|
body.keyword != null && body.keyword != ""
|
||||||
? "viewCommanderDirector.citizenId LIKE :keyword"
|
? "viewDirector.citizenId LIKE :keyword"
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
keyword: `%${body.keyword}%`,
|
keyword: `%${body.keyword}%`,
|
||||||
|
|
@ -1337,7 +1381,7 @@ export class ProfileController extends Controller {
|
||||||
)
|
)
|
||||||
.orWhere(
|
.orWhere(
|
||||||
body.keyword != null && body.keyword != ""
|
body.keyword != null && body.keyword != ""
|
||||||
? "viewCommanderDirector.position LIKE :keyword"
|
? "viewDirector.position LIKE :keyword"
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
keyword: `%${body.keyword}%`,
|
keyword: `%${body.keyword}%`,
|
||||||
|
|
@ -1345,7 +1389,7 @@ export class ProfileController extends Controller {
|
||||||
)
|
)
|
||||||
.orWhere(
|
.orWhere(
|
||||||
body.keyword != null && body.keyword != ""
|
body.keyword != null && body.keyword != ""
|
||||||
? "viewCommanderDirector.posLevel LIKE :keyword"
|
? "viewDirector.posLevel LIKE :keyword"
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
keyword: `%${body.keyword}%`,
|
keyword: `%${body.keyword}%`,
|
||||||
|
|
@ -1353,15 +1397,7 @@ export class ProfileController extends Controller {
|
||||||
)
|
)
|
||||||
.orWhere(
|
.orWhere(
|
||||||
body.keyword != null && body.keyword != ""
|
body.keyword != null && body.keyword != ""
|
||||||
? "viewCommanderDirector.posType LIKE :keyword"
|
? "viewDirector.posType LIKE :keyword"
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.orWhere(
|
|
||||||
body.keyword != null && body.keyword != ""
|
|
||||||
? "viewCommanderDirector.actFullName LIKE :keyword"
|
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
keyword: `%${body.keyword}%`,
|
keyword: `%${body.keyword}%`,
|
||||||
|
|
@ -2639,7 +2675,6 @@ export class ProfileController extends Controller {
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
|
||||||
}
|
}
|
||||||
let dateLeave_: any = body.date;
|
|
||||||
let null_: any = null;
|
let null_: any = null;
|
||||||
profile.isLeave = false;
|
profile.isLeave = false;
|
||||||
profile.leaveReason = null_;
|
profile.leaveReason = null_;
|
||||||
|
|
@ -2697,7 +2732,7 @@ export class ProfileController extends Controller {
|
||||||
|
|
||||||
return new HttpSuccess({ retireDate, age });
|
return new HttpSuccess({ retireDate, age });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API แก้ไขประวัติในเมนูร้องขอแก้ไขทะเบียนประวัติ
|
* API แก้ไขประวัติในเมนูร้องขอแก้ไขทะเบียนประวัติ
|
||||||
*
|
*
|
||||||
|
|
@ -2712,7 +2747,6 @@ export class ProfileController extends Controller {
|
||||||
@Body() body: UpdateProfileReqEdit,
|
@Body() body: UpdateProfileReqEdit,
|
||||||
) {
|
) {
|
||||||
const record = await this.profileRepo.findOneBy({ id });
|
const record = await this.profileRepo.findOneBy({ id });
|
||||||
const before = structuredClone(record);
|
|
||||||
|
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||||
|
|
||||||
|
|
@ -2761,15 +2795,14 @@ export class ProfileController extends Controller {
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body() body: UpdateProfileFather,
|
@Body() body: UpdateProfileFather,
|
||||||
) {
|
) {
|
||||||
|
const profile = await this.profileRepo.findOneBy({ id: id });
|
||||||
const profile = await this.profileRepo.findOneBy({ id:id });
|
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastestData:any = await this.profileFamilyFatherRepository.findOne({
|
let lastestData: any = await this.profileFamilyFatherRepository.findOne({
|
||||||
where:{ profileId:id },
|
where: { profileId: id },
|
||||||
order:{ createdAt: "DESC" }
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.keys(body).forEach((key) => {
|
Object.keys(body).forEach((key) => {
|
||||||
|
|
@ -2778,9 +2811,9 @@ export class ProfileController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!lastestData) {
|
if (!lastestData) {
|
||||||
lastestData = new ProfileFamilyFather();
|
lastestData = new ProfileFamilyFather();
|
||||||
Object.assign(lastestData, body);
|
Object.assign(lastestData, body);
|
||||||
lastestData.profileId = id;
|
lastestData.profileId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(lastestData, body);
|
Object.assign(lastestData, body);
|
||||||
|
|
@ -2813,15 +2846,14 @@ export class ProfileController extends Controller {
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body() body: UpdateProfileMother,
|
@Body() body: UpdateProfileMother,
|
||||||
) {
|
) {
|
||||||
|
const profile = await this.profileRepo.findOneBy({ id: id });
|
||||||
const profile = await this.profileRepo.findOneBy({ id:id });
|
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastestData = await this.profileFamilyMotherRepository.findOne({
|
let lastestData = await this.profileFamilyMotherRepository.findOne({
|
||||||
where:{ profileId:id },
|
where: { profileId: id },
|
||||||
order:{ createdAt: "DESC" }
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.keys(body).forEach((key) => {
|
Object.keys(body).forEach((key) => {
|
||||||
|
|
@ -2865,15 +2897,14 @@ export class ProfileController extends Controller {
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body() body: UpdateProfileCouple,
|
@Body() body: UpdateProfileCouple,
|
||||||
) {
|
) {
|
||||||
|
const profile = await this.profileRepo.findOneBy({ id: id });
|
||||||
const profile = await this.profileRepo.findOneBy({ id:id });
|
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastestData = await this.profileFamilyCoupleRepository.findOne({
|
let lastestData = await this.profileFamilyCoupleRepository.findOne({
|
||||||
where:{ profileId:id },
|
where: { profileId: id },
|
||||||
order:{ createdAt: "DESC" }
|
order: { createdAt: "DESC" },
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.keys(body).forEach((key) => {
|
Object.keys(body).forEach((key) => {
|
||||||
|
|
@ -3011,8 +3042,6 @@ export class ProfileController extends Controller {
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ลบทะเบียนประวัติ
|
* API ลบทะเบียนประวัติ
|
||||||
*
|
*
|
||||||
|
|
@ -3064,7 +3093,7 @@ export class ProfileController extends Controller {
|
||||||
async getProfileIdByKeycloak(@Request() request: RequestWithUser) {
|
async getProfileIdByKeycloak(@Request() request: RequestWithUser) {
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { keycloak: request.user.sub },
|
where: { keycloak: request.user.sub },
|
||||||
select:["id"]
|
select: ["id"],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -6717,7 +6746,6 @@ export class ProfileController extends Controller {
|
||||||
});
|
});
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
const before = structuredClone(profile);
|
const before = structuredClone(profile);
|
||||||
const _null: any = null;
|
|
||||||
profile.isLeave = requestBody.isLeave;
|
profile.isLeave = requestBody.isLeave;
|
||||||
profile.leaveReason = requestBody.leaveReason;
|
profile.leaveReason = requestBody.leaveReason;
|
||||||
profile.dateLeave = requestBody.dateLeave;
|
profile.dateLeave = requestBody.dateLeave;
|
||||||
|
|
@ -7173,31 +7201,6 @@ export class ProfileController extends Controller {
|
||||||
.take(50)
|
.take(50)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
const profiles = await Promise.all(
|
|
||||||
profile.map(async (_data) => {
|
|
||||||
if (_data.current_holders.length == 0 && _data.next_holders.length == 0) {
|
|
||||||
const salary = await this.salaryRepository.find({
|
|
||||||
where: {
|
|
||||||
profileId: _data.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const insignia = await this.profileInsigniaRepo.find({
|
|
||||||
where: {
|
|
||||||
profileId: _data.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const discipline = await this.profileDisciplineRepo.find({
|
|
||||||
where: {
|
|
||||||
profileId: _data.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
await this.salaryRepository.remove(salary);
|
|
||||||
await this.profileInsigniaRepo.remove(insignia);
|
|
||||||
await this.profileDisciplineRepo.remove(discipline);
|
|
||||||
await this.profileRepo.remove(_data);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
import { ViewColumn, ViewEntity } from "typeorm";
|
|
||||||
|
|
||||||
@ViewEntity({
|
|
||||||
expression: `SELECT
|
|
||||||
\`bma_ehr_organization_demo\`.\`profile\`.\`id\` AS \`Id\`,
|
|
||||||
\`bma_ehr_organization_demo\`.\`profile\`.\`prefix\` AS \`prefix\`,
|
|
||||||
\`bma_ehr_organization_demo\`.\`profile\`.\`firstName\` AS \`firstName\`,
|
|
||||||
\`bma_ehr_organization_demo\`.\`profile\`.\`lastName\` AS \`lastName\`,
|
|
||||||
\`bma_ehr_organization_demo\`.\`profile\`.\`citizenId\` AS \`citizenId\`,
|
|
||||||
\`bma_ehr_organization_demo\`.\`profile\`.\`position\` AS \`position\`,
|
|
||||||
\`bma_ehr_organization_demo\`.\`posMaster\`.\`isDirector\` AS \`isDirector\`,
|
|
||||||
\`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`,
|
|
||||||
\`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`,
|
|
||||||
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`,
|
|
||||||
NULL AS \`actFullName\`
|
|
||||||
FROM
|
|
||||||
(((\`bma_ehr_organization_demo\`.\`posMaster\`
|
|
||||||
JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))
|
|
||||||
JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`)))
|
|
||||||
JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`)))
|
|
||||||
UNION SELECT
|
|
||||||
\`profileChild\`.\`id\` AS \`Id\`,
|
|
||||||
\`profileChild\`.\`prefix\` AS \`prefix\`,
|
|
||||||
\`profileChild\`.\`firstName\` AS \`firstName\`,
|
|
||||||
\`profileChild\`.\`lastName\` AS \`lastName\`,
|
|
||||||
\`profileChild\`.\`citizenId\` AS \`citizenId\`,
|
|
||||||
\`profileChild\`.\`position\` AS \`position\`,
|
|
||||||
\`posMasterChild\`.\`isDirector\` AS \`isDirector\`,
|
|
||||||
\`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`,
|
|
||||||
\`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`,
|
|
||||||
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`,
|
|
||||||
CONCAT(\`bma_ehr_organization_demo\`.\`profile\`.\`prefix\`,
|
|
||||||
\`bma_ehr_organization_demo\`.\`profile\`.\`firstName\`,
|
|
||||||
' ',
|
|
||||||
\`bma_ehr_organization_demo\`.\`profile\`.\`lastName\`) AS \`actFullName\`
|
|
||||||
FROM
|
|
||||||
((((((\`bma_ehr_organization_demo\`.\`posMasterAct\`
|
|
||||||
JOIN \`bma_ehr_organization_demo\`.\`posMaster\` \`posMasterChild\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterChildId\` = \`posMasterChild\`.\`id\`)))
|
|
||||||
JOIN \`bma_ehr_organization_demo\`.\`profile\` \`profileChild\` ON ((\`posMasterChild\`.\`current_holderId\` = \`profileChild\`.\`id\`)))
|
|
||||||
JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`profileChild\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`)))
|
|
||||||
JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`profileChild\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`)))
|
|
||||||
JOIN \`bma_ehr_organization_demo\`.\`posMaster\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterId\` = \`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`)))
|
|
||||||
JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))`,
|
|
||||||
})
|
|
||||||
export class viewCommanderDirector {
|
|
||||||
@ViewColumn()
|
|
||||||
id: string;
|
|
||||||
@ViewColumn()
|
|
||||||
prefix: string;
|
|
||||||
@ViewColumn()
|
|
||||||
firstName: string;
|
|
||||||
@ViewColumn()
|
|
||||||
lastName: string;
|
|
||||||
@ViewColumn()
|
|
||||||
citizenId: string;
|
|
||||||
@ViewColumn()
|
|
||||||
position: string;
|
|
||||||
@ViewColumn()
|
|
||||||
posLevel: string;
|
|
||||||
@ViewColumn()
|
|
||||||
posType: string;
|
|
||||||
@ViewColumn()
|
|
||||||
isDirector: boolean;
|
|
||||||
@ViewColumn()
|
|
||||||
orgRootId: string;
|
|
||||||
@ViewColumn()
|
|
||||||
actFullName: string;
|
|
||||||
}
|
|
||||||
|
|
@ -25,7 +25,7 @@ import { ViewColumn, ViewEntity } from "typeorm";
|
||||||
JOIN \`bma_ehr_organization_demo\`.\`posMaster\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterId\` = \`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`)))
|
JOIN \`bma_ehr_organization_demo\`.\`posMaster\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterId\` = \`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`)))
|
||||||
JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))`,
|
JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))`,
|
||||||
})
|
})
|
||||||
export class viewCommanderDirector {
|
export class viewDirectorActing {
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
id: string;
|
id: string;
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
|
|
|
||||||
58
src/migration/1730703510080-add_table_commandSign2.ts
Normal file
58
src/migration/1730703510080-add_table_commandSign2.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddTableCommandSign21730703510080 implements MigrationInterface {
|
||||||
|
name = 'AddTableCommandSign21730703510080'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`CREATE VIEW \`view_director_acting\` AS SELECT
|
||||||
|
\`profileChild\`.\`id\` AS \`Id\`,
|
||||||
|
\`profileChild\`.\`prefix\` AS \`prefix\`,
|
||||||
|
\`profileChild\`.\`firstName\` AS \`firstName\`,
|
||||||
|
\`profileChild\`.\`lastName\` AS \`lastName\`,
|
||||||
|
\`profileChild\`.\`citizenId\` AS \`citizenId\`,
|
||||||
|
\`profileChild\`.\`position\` AS \`position\`,
|
||||||
|
\`posMasterChild\`.\`isDirector\` AS \`isDirector\`,
|
||||||
|
\`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`,
|
||||||
|
\`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`,
|
||||||
|
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`,
|
||||||
|
CONCAT(\`bma_ehr_organization_demo\`.\`profile\`.\`prefix\`,
|
||||||
|
\`bma_ehr_organization_demo\`.\`profile\`.\`firstName\`,
|
||||||
|
' ',
|
||||||
|
\`bma_ehr_organization_demo\`.\`profile\`.\`lastName\`) AS \`actFullName\`
|
||||||
|
FROM
|
||||||
|
((((((\`bma_ehr_organization_demo\`.\`posMasterAct\`
|
||||||
|
JOIN \`bma_ehr_organization_demo\`.\`posMaster\` \`posMasterChild\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterChildId\` = \`posMasterChild\`.\`id\`)))
|
||||||
|
JOIN \`bma_ehr_organization_demo\`.\`profile\` \`profileChild\` ON ((\`posMasterChild\`.\`current_holderId\` = \`profileChild\`.\`id\`)))
|
||||||
|
JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`profileChild\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`)))
|
||||||
|
JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`profileChild\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`)))
|
||||||
|
JOIN \`bma_ehr_organization_demo\`.\`posMaster\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterId\` = \`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`)))
|
||||||
|
JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))`);
|
||||||
|
await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director_acting","SELECT \n `profileChild`.`id` AS `Id`,\n `profileChild`.`prefix` AS `prefix`,\n `profileChild`.`firstName` AS `firstName`,\n `profileChild`.`lastName` AS `lastName`,\n `profileChild`.`citizenId` AS `citizenId`,\n `profileChild`.`position` AS `position`,\n `posMasterChild`.`isDirector` AS `isDirector`,\n `bma_ehr_organization_demo`.`posLevel`.`posLevelName` AS `posLevel`,\n `bma_ehr_organization_demo`.`posType`.`posTypeName` AS `posType`,\n `bma_ehr_organization_demo`.`posMaster`.`orgRootId` AS `orgRootId`,\n CONCAT(`bma_ehr_organization_demo`.`profile`.`prefix`,\n `bma_ehr_organization_demo`.`profile`.`firstName`,\n ' ',\n `bma_ehr_organization_demo`.`profile`.`lastName`) AS `actFullName`\n FROM\n ((((((`bma_ehr_organization_demo`.`posMasterAct`\n JOIN `bma_ehr_organization_demo`.`posMaster` `posMasterChild` ON ((`bma_ehr_organization_demo`.`posMasterAct`.`posMasterChildId` = `posMasterChild`.`id`)))\n JOIN `bma_ehr_organization_demo`.`profile` `profileChild` ON ((`posMasterChild`.`current_holderId` = `profileChild`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posLevel` ON ((`profileChild`.`posLevelId` = `bma_ehr_organization_demo`.`posLevel`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posType` ON ((`profileChild`.`posTypeId` = `bma_ehr_organization_demo`.`posType`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posMaster` ON ((`bma_ehr_organization_demo`.`posMasterAct`.`posMasterId` = `bma_ehr_organization_demo`.`posMaster`.`id`)))\n JOIN `bma_ehr_organization_demo`.`profile` ON ((`bma_ehr_organization_demo`.`posMaster`.`current_holderId` = `bma_ehr_organization_demo`.`profile`.`id`)))"]);
|
||||||
|
await queryRunner.query(`CREATE VIEW \`view_director\` AS SELECT
|
||||||
|
\`bma_ehr_organization_demo\`.\`profile\`.\`id\` AS \`Id\`,
|
||||||
|
\`bma_ehr_organization_demo\`.\`profile\`.\`prefix\` AS \`prefix\`,
|
||||||
|
\`bma_ehr_organization_demo\`.\`profile\`.\`firstName\` AS \`firstName\`,
|
||||||
|
\`bma_ehr_organization_demo\`.\`profile\`.\`lastName\` AS \`lastName\`,
|
||||||
|
\`bma_ehr_organization_demo\`.\`profile\`.\`citizenId\` AS \`citizenId\`,
|
||||||
|
\`bma_ehr_organization_demo\`.\`profile\`.\`position\` AS \`position\`,
|
||||||
|
\`bma_ehr_organization_demo\`.\`posMaster\`.\`isDirector\` AS \`isDirector\`,
|
||||||
|
\`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`,
|
||||||
|
\`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`,
|
||||||
|
\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`,
|
||||||
|
NULL AS \`actFullName\`
|
||||||
|
FROM
|
||||||
|
(((\`bma_ehr_organization_demo\`.\`posMaster\`
|
||||||
|
JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))
|
||||||
|
JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`)))
|
||||||
|
JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`)))`);
|
||||||
|
await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director","SELECT \n `bma_ehr_organization_demo`.`profile`.`id` AS `Id`,\n `bma_ehr_organization_demo`.`profile`.`prefix` AS `prefix`,\n `bma_ehr_organization_demo`.`profile`.`firstName` AS `firstName`,\n `bma_ehr_organization_demo`.`profile`.`lastName` AS `lastName`,\n `bma_ehr_organization_demo`.`profile`.`citizenId` AS `citizenId`,\n `bma_ehr_organization_demo`.`profile`.`position` AS `position`,\n `bma_ehr_organization_demo`.`posMaster`.`isDirector` AS `isDirector`,\n `bma_ehr_organization_demo`.`posLevel`.`posLevelName` AS `posLevel`,\n `bma_ehr_organization_demo`.`posType`.`posTypeName` AS `posType`,\n `bma_ehr_organization_demo`.`posMaster`.`orgRootId` AS `orgRootId`,\n NULL AS `actFullName`\n FROM\n (((`bma_ehr_organization_demo`.`posMaster`\n JOIN `bma_ehr_organization_demo`.`profile` ON ((`bma_ehr_organization_demo`.`posMaster`.`current_holderId` = `bma_ehr_organization_demo`.`profile`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posLevel` ON ((`bma_ehr_organization_demo`.`profile`.`posLevelId` = `bma_ehr_organization_demo`.`posLevel`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posType` ON ((`bma_ehr_organization_demo`.`profile`.`posTypeId` = `bma_ehr_organization_demo`.`posType`.`id`)))"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director","bma_ehr_organization_demo"]);
|
||||||
|
await queryRunner.query(`DROP VIEW \`view_director\``);
|
||||||
|
await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director_acting","bma_ehr_organization_demo"]);
|
||||||
|
await queryRunner.query(`DROP VIEW \`view_director_acting\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue