no message

This commit is contained in:
Kittapath 2024-02-21 13:53:02 +07:00
parent b04699e5f4
commit 614fe24e12

View file

@ -51,6 +51,12 @@ export class ProfileController extends Controller {
requestBody: CreateProfile,
@Request() request: { user: Record<string, any> },
) {
const _profile = await this.profileRepository.findOne({
where: { citizenId: requestBody.citizenId },
});
if (_profile) {
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "เลขบัตรนี้มีอยู่ในระบบแล้ว");
}
if (requestBody.posLevelId == "") {
requestBody.posLevelId = null;
}
@ -124,6 +130,13 @@ export class ProfileController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
}
const _profile = await this.profileRepository.findOne({
where: { id: Not(id), citizenId: requestBody.citizenId },
});
if (_profile) {
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "เลขบัตรนี้มีอยู่ในระบบแล้ว");
}
if (requestBody.posLevelId == "") {
requestBody.posLevelId = null;
}
@ -155,9 +168,9 @@ export class ProfileController extends Controller {
}
const checkCitizenId = await this.profileRepository.findOne({
where: {
where: {
id: Not(id),
citizenId: requestBody.citizenId ,
citizenId: requestBody.citizenId,
},
});
@ -619,17 +632,37 @@ export class ProfileController extends Controller {
.orderBy("posMaster.posMasterOrder", "ASC")
.getOne();
}
fullName_ = (findProfile?.prefix ?? "") + (findProfile?.firstName ?? "") + " " + (findProfile?.lastName ?? "");
fullName_ =
(findProfile?.prefix ?? "") +
(findProfile?.firstName ?? "") +
" " +
(findProfile?.lastName ?? "");
position_ = findProfile?.position ?? "";
commanderFullname_ = (findCmd?.current_holder?.prefix ?? "") + (findCmd?.current_holder?.firstName ?? "") + " " + (findCmd?.current_holder?.lastName ?? "");
commanderFullname_ =
(findCmd?.current_holder?.prefix ?? "") +
(findCmd?.current_holder?.firstName ?? "") +
" " +
(findCmd?.current_holder?.lastName ?? "");
commanderPosition_ = findCmd?.current_holder?.position ?? "";
commanderAboveFullname_ = (findOSAB?.current_holder?.prefix ?? "") + (findOSAB?.current_holder?.firstName ?? "") + " " + (findOSAB?.current_holder?.lastName ?? "");
commanderAboveFullname_ =
(findOSAB?.current_holder?.prefix ?? "") +
(findOSAB?.current_holder?.firstName ?? "") +
" " +
(findOSAB?.current_holder?.lastName ?? "");
commanderAbovePosition_ = findOSAB?.current_holder?.position ?? "";
if (findCmd?.current_holderId == findProfile?.id) {
commanderFullname_ = (findOSAB?.current_holder?.prefix ?? "") + (findOSAB?.current_holder?.firstName ?? "") + " " + (findOSAB?.current_holder?.lastName ?? "");
commanderFullname_ =
(findOSAB?.current_holder?.prefix ?? "") +
(findOSAB?.current_holder?.firstName ?? "") +
" " +
(findOSAB?.current_holder?.lastName ?? "");
commanderPosition_ = findOSAB?.current_holder?.position ?? "";
commanderAboveFullname_ = (findTSAB?.current_holder?.prefix ?? "") + (findTSAB?.current_holder?.firstName ?? "") + " " + (findTSAB?.current_holder?.lastName ?? "");
commanderAboveFullname_ =
(findTSAB?.current_holder?.prefix ?? "") +
(findTSAB?.current_holder?.firstName ?? "") +
" " +
(findTSAB?.current_holder?.lastName ?? "");
commanderAbovePosition_ = findTSAB?.current_holder?.position ?? "";
const formattedDataTSAB = {
@ -653,4 +686,30 @@ export class ProfileController extends Controller {
};
return new HttpSuccess(formattedData);
}
/**
* API
*
* @summary (ADMIN)
*
* @param {string} id Id
*/
@Put("citizenId/{id}")
async checkCitizenIdProfile(
@Path() id: string,
@Body()
requestBody: { citizenId: string },
) {
const profile = await this.profileRepository.findOne({
where: { id: Not(id), citizenId: requestBody.citizenId },
});
if (profile) {
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "เลขบัตรนี้มีอยู่ในระบบแล้ว");
}
try {
return new HttpSuccess();
} catch (error) {
return error;
}
}
}