Merge branch 'develop' into adiDev

# Conflicts:
#	src/controllers/ProfileController.ts
#	src/controllers/ProfileEmployeeController.ts
This commit is contained in:
AdisakKanthawilang 2024-05-24 11:09:26 +07:00
commit 63d357ea30
45 changed files with 1184 additions and 167 deletions

View file

@ -35,6 +35,7 @@ import { Position } from "../entities/Position";
import { Province } from "../entities/Province";
import { District } from "../entities/District";
import { SubDistrict } from "../entities/SubDistrict";
import Extension from "../interfaces/extension";
@Route("api/v1/org/profile-employee")
@Tags("ProfileEmployee")
@ -126,6 +127,16 @@ export class ProfileEmployeeController extends Controller {
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4;
let _regisAddres =
profile && profile.registrationAddress != null ? profile.registrationAddress : "";
let _subDistrict =
subDistrict && subDistrict.name != null ? `\r\nตำบล/แขวง ${province?.name}` : "";
let _district = district && district.name != null ? `\r\nเขต/อำเภอ ${district?.name}` : "";
let _province = province && province.name != null ? `\r\nจังหวัด ${province?.name}` : "";
let registrationZipCode =
profile && profile.registrationZipCode != null
? ` รหัสไปรษณีย์ ${profile.registrationZipCode}`
: "";
let _root = root == null || root == undefined ? "" : `${root.orgRootName}`;
let _child1 = child1 == null || child1 == undefined ? "" : `${child1.orgChild1Name}/`;
let _child2 = child2 == null || child2 == undefined ? "" : `${child2.orgChild2Name}/`;
@ -134,21 +145,34 @@ export class ProfileEmployeeController extends Controller {
const mapData = {
Id: profile.id,
CitizenId: profile.citizenId,
Prefix: profile.prefix,
FirstName: profile.firstName,
LastName: profile.lastName,
DateOfBirth: profile.birthDate,
DateRetire: profile.dateRetire,
RegistrationAddress: `${profile.registrationAddress}\r\nตำบล/แขวง ${province?.name}\r\nเขต/อำเภอ ${district?.name}\r\nจังหวัด ${subDistrict?.name} รหัสไปรษณีย์ ${profile.registrationZipCode}`,
SalaryAmount: profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null,
CitizenId: profile.citizenId != null ? Extension.ToThaiNumber(profile.citizenId) : "",
Prefix: profile.prefix != null ? profile.prefix : "",
FirstName: profile.firstName != null ? profile.firstName : "",
LastName: profile.lastName != null ? profile.lastName : "",
DateOfBirth:
profile.birthDate != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.birthDate))
: "",
DateRetire:
profile.dateRetire != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.dateRetire))
: "",
RegistrationAddress: `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
SalaryAmount:
profile.profileSalarys.length > 0 && profile.profileSalarys[0].amount != null
? Extension.ToThaiNumber(profile.profileSalarys[0].amount.toLocaleString())
: "",
Education:
profile.profileEducations.length > 0
profile.profileEducations.length > 0 &&
profile.profileEducations[profile.profileEducations.length - 1].institute != null
? profile.profileEducations[profile.profileEducations.length - 1].institute
: null,
AppointText: profile.dateAppoint,
SalaryDate: profile.profileSalarys.length > 0 ? profile.profileSalarys[0].date : null,
PositionName: profile.position,
: "",
AppointText: profile.dateAppoint != null ? profile.dateAppoint : "",
SalaryDate:
profile.profileSalarys.length > 0 && profile.profileSalarys[0].date != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.profileSalarys[0].date))
: "",
PositionName: profile.position != null ? profile.position : "",
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
};
@ -343,6 +367,31 @@ export class ProfileEmployeeController extends Controller {
return new HttpSuccess();
}
/**
* API
*
* @summary ORG_065 - (ADMIN) #70
*
* @param {string} id Id
*/
@Get("user")
async detailProfileUser(@Request() request: RequestWithUser) {
const profile = await this.profileRepo.findOne({
relations: {
posLevel: true,
posType: true,
// gender: true,
// relationship: true,
// bloodGroup: true,
},
where: { keycloak: request.user.sub },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(profile);
}
/**
* API
*