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

@ -43,6 +43,7 @@ import { ProfileEmployee } from "../entities/ProfileEmployee";
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")
@Tags("Profile")
@ -136,6 +137,16 @@ export class ProfileController 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}/`;
@ -144,21 +155,34 @@ export class ProfileController 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.profileSalary.length > 0 ? profile.profileSalary[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.profileSalary.length > 0 && profile.profileSalary[0].amount != null
? Extension.ToThaiNumber(profile.profileSalary[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.profileSalary.length > 0 ? profile.profileSalary[0].date : null,
PositionName: profile.position,
: "",
AppointText: profile.dateAppoint != null ? profile.dateAppoint : "",
SalaryDate:
profile.profileSalary.length > 0 && profile.profileSalary[0].date != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.profileSalary[0].date))
: "",
PositionName: profile.position != null ? profile.position : "",
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
};
@ -524,6 +548,28 @@ export class ProfileController extends Controller {
return new HttpSuccess();
}
/**
* API
*
* @summary ORG_065 - (ADMIN) #70
*
* @param {string} id Id
*/
@Get("user")
async getProfileByUser(@Request() request: RequestWithUser) {
const profile = await this.profileRepo.findOne({
relations: {
posLevel: true,
posType: true,
},
where: { keycloak: request.user.sub },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(profile);
}
/**
* API
*
@ -1061,6 +1107,8 @@ export class ProfileController extends Controller {
profileId: profile.id,
prefix: profile.prefix,
rank: profile.rank,
avatar: profile.avatar,
avatarName: profile.avatarName,
firstName: profile.firstName,
lastName: profile.lastName,
citizenId: profile.citizenId,