add commander-director-act
This commit is contained in:
parent
8a2d5cce38
commit
4a036a5dd9
4 changed files with 268 additions and 207 deletions
|
|
@ -73,6 +73,8 @@ 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")
|
||||||
|
|
@ -265,7 +267,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 +282,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,109 +679,107 @@ 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 : `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
|
||||||
? ImgUrl
|
url1: _ImgUrl[0] ? _ImgUrl[0] : null,
|
||||||
: `https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg`,
|
url2: _ImgUrl[1] ? _ImgUrl[1] : null,
|
||||||
url1: _ImgUrl[0] ? _ImgUrl[0] : null,
|
url3: _ImgUrl[2] ? _ImgUrl[2] : null,
|
||||||
url2: _ImgUrl[1] ? _ImgUrl[1] : null,
|
url4: _ImgUrl[3] ? _ImgUrl[3] : null,
|
||||||
url3: _ImgUrl[2] ? _ImgUrl[2] : null,
|
url5: _ImgUrl[4] ? _ImgUrl[4] : null,
|
||||||
url4: _ImgUrl[3] ? _ImgUrl[3] : null,
|
url6: _ImgUrl[5] ? _ImgUrl[5] : null,
|
||||||
url5: _ImgUrl[4] ? _ImgUrl[4] : null,
|
url7: _ImgUrl[6] ? _ImgUrl[6] : null,
|
||||||
url6: _ImgUrl[5] ? _ImgUrl[5] : null,
|
|
||||||
url7: _ImgUrl[6] ? _ImgUrl[6] : null,
|
|
||||||
|
|
||||||
// BirthDay: profiles?.birthDate
|
|
||||||
// ? Extension.ToThaiNumber(new Date(profiles.birthDate).getDate().toString())
|
|
||||||
// : null,
|
|
||||||
// BirthDayText:
|
|
||||||
// profiles.birthDate != null
|
|
||||||
// ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.birthDate).toString())
|
|
||||||
// : "",
|
|
||||||
// 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,
|
// 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",
|
||||||
|
|
@ -1281,6 +1279,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 });
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|
@ -1307,14 +1391,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}%`,
|
||||||
|
|
@ -1322,7 +1406,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}%`,
|
||||||
|
|
@ -1330,7 +1414,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}%`,
|
||||||
|
|
@ -1338,7 +1422,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}%`,
|
||||||
|
|
@ -1346,15 +1430,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}%`,
|
||||||
|
|
@ -2690,7 +2766,7 @@ export class ProfileController extends Controller {
|
||||||
|
|
||||||
return new HttpSuccess({ retireDate, age });
|
return new HttpSuccess({ retireDate, age });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API แก้ไขประวัติในเมนูร้องขอแก้ไขทะเบียนประวัติ
|
* API แก้ไขประวัติในเมนูร้องขอแก้ไขทะเบียนประวัติ
|
||||||
*
|
*
|
||||||
|
|
@ -2754,15 +2830,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) => {
|
||||||
|
|
@ -2771,9 +2846,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);
|
||||||
|
|
@ -2806,15 +2881,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) => {
|
||||||
|
|
@ -2858,15 +2932,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) => {
|
||||||
|
|
@ -3004,8 +3077,6 @@ export class ProfileController extends Controller {
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ลบทะเบียนประวัติ
|
* API ลบทะเบียนประวัติ
|
||||||
*
|
*
|
||||||
|
|
@ -3057,7 +3128,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, "ไม่พบข้อมูล");
|
||||||
|
|
|
||||||
|
|
@ -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