get ข้อมูล by keycloak (ลูกจ้าง)
This commit is contained in:
parent
24c5cbef55
commit
58fe2f08fd
21 changed files with 423 additions and 3 deletions
|
|
@ -35,6 +35,34 @@ export class ProfileAddressEmployeeController extends Controller {
|
|||
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
private profileAddressHistoryRepo = AppDataSource.getRepository(ProfileAddressHistory);
|
||||
|
||||
@Get("user")
|
||||
public async detailProfileAddressUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const getProfileAddress = await this.profileEmployeeRepo.findOne({
|
||||
where: { id: profile.id },
|
||||
select: [
|
||||
"id",
|
||||
"registrationAddress",
|
||||
"registrationProvinceId",
|
||||
"registrationDistrictId",
|
||||
"registrationSubDistrictId",
|
||||
"registrationZipCode",
|
||||
"currentAddress",
|
||||
"currentProvinceId",
|
||||
"currentDistrictId",
|
||||
"currentSubDistrictId",
|
||||
"currentZipCode",
|
||||
],
|
||||
});
|
||||
if (!getProfileAddress) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(getProfileAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary ข้อมูลที่อยู่
|
||||
|
|
|
|||
|
|
@ -36,8 +36,22 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
export class ProfileAssessmentsEmployeeController extends Controller {
|
||||
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
private profileAssessmentsRepository = AppDataSource.getRepository(ProfileAssessment);
|
||||
private profileAssessmentsHistoryRepository =
|
||||
AppDataSource.getRepository(ProfileAssessmentHistory);
|
||||
private profileAssessmentsHistoryRepository = AppDataSource.getRepository(ProfileAssessmentHistory);
|
||||
|
||||
@Get("user")
|
||||
public async detailProfileAssessmentsUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const getProfileAssessments = await this.profileAssessmentsRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
});
|
||||
if (!getProfileAssessments) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(getProfileAssessments);
|
||||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@Example({
|
||||
|
|
|
|||
|
|
@ -33,6 +33,18 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
private certificateRepo = AppDataSource.getRepository(ProfileCertificate);
|
||||
private certificateHistoryRepo = AppDataSource.getRepository(ProfileCertificateHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getCertificateUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const record = await this.certificateRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,20 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
|||
private changeNameRepository = AppDataSource.getRepository(ProfileChangeName);
|
||||
private changeNameHistoryRepository = AppDataSource.getRepository(ProfileChangeNameHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getChangeNameUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const lists = await this.changeNameRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
select: ["id", "prefix", "firstName", "lastName", "status"],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,18 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
private childrenRepository = AppDataSource.getRepository(ProfileChildren);
|
||||
private childrenHistoryRepository = AppDataSource.getRepository(ProfileChildrenHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getChildrenUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepository.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const lists = await this.childrenRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
public async getChildren(@Path() profileEmployeeId: string) {
|
||||
const lists = await this.childrenRepository.find({
|
||||
|
|
|
|||
|
|
@ -33,6 +33,29 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
|||
private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline);
|
||||
private disciplineHistoryRepository = AppDataSource.getRepository(ProfileDisciplineHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getDisciplineUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepository.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const lists = await this.disciplineRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
select: [
|
||||
"id",
|
||||
"date",
|
||||
"level",
|
||||
"detail",
|
||||
"unStigma",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
"lastUpdateFullName",
|
||||
"lastUpdatedAt",
|
||||
],
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,27 @@ export class ProfileDutyEmployeeController extends Controller {
|
|||
private dutyRepository = AppDataSource.getRepository(ProfileDuty);
|
||||
private dutyHistoryRepository = AppDataSource.getRepository(ProfileDutyHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getDutyUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepository.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const lists = await this.dutyRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
select: [
|
||||
"id",
|
||||
"dateStart",
|
||||
"dateEnd",
|
||||
"reference",
|
||||
"detail",
|
||||
"refCommandNo",
|
||||
"refCommandDate",
|
||||
],
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getDuty(@Path() profileId: string) {
|
||||
const lists = await this.dutyRepository.find({
|
||||
|
|
|
|||
|
|
@ -41,6 +41,21 @@ export class ProfileEducationsEmployeeController extends Controller {
|
|||
private profileEducationRepo = AppDataSource.getRepository(ProfileEducation);
|
||||
private profileEducationHistoryRepo = AppDataSource.getRepository(ProfileEducationHistory);
|
||||
|
||||
@Get("user")
|
||||
public async detailProfileEducationUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const getProfileEducation = await this.profileEducationRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
});
|
||||
if (!getProfileEducation) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(getProfileEducation);
|
||||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
"relationship",
|
||||
"profileId",
|
||||
],
|
||||
where: { id: profile.id },
|
||||
where: { profileId: profile.id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,32 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
|||
private ProfileFamilyCouple = AppDataSource.getRepository(ProfileFamilyCouple);
|
||||
private ProfileFamilyCoupleHistory = AppDataSource.getRepository(ProfileFamilyCoupleHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getFamilyCoupleUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"couplePrefix",
|
||||
"coupleFirstName",
|
||||
"coupleLastName",
|
||||
"coupleLastNameOld",
|
||||
"coupleCareer",
|
||||
"coupleCitizenId",
|
||||
"coupleLive",
|
||||
"relationship",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
||||
return new HttpSuccess(familyCouple);
|
||||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,30 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
|||
private ProfileFamilyFather = AppDataSource.getRepository(ProfileFamilyFather);
|
||||
private ProfileFamilyFatherHistory = AppDataSource.getRepository(ProfileFamilyFatherHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getFamilyFatherUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyFather = await this.ProfileFamilyFather.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"fatherPrefix",
|
||||
"fatherFirstName",
|
||||
"fatherLastName",
|
||||
"fatherCareer",
|
||||
"fatherCitizenId",
|
||||
"fatherLive",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
||||
return new HttpSuccess(familyFather);
|
||||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,31 @@ export class ProfileFamilyHistoryEmployeeController extends Controller {
|
|||
private childrenRepo = AppDataSource.getRepository(ProfileChildren);
|
||||
private childrenHistoryRepo = AppDataSource.getRepository(ProfileChildrenHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getFamilyHistoryUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const family = await this.familyHistoryRepo.find({
|
||||
take: 1,
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
where: { profileId: profile.id },
|
||||
});
|
||||
const children = await this.childrenRepo.find({
|
||||
order: { createdAt: "ASC" },
|
||||
where: { profileEmployeeId: profile.id },
|
||||
});
|
||||
return new HttpSuccess(
|
||||
family.length > 0
|
||||
? {
|
||||
...family[0],
|
||||
children,
|
||||
}
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,30 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
|||
private ProfileFamilyMother = AppDataSource.getRepository(ProfileFamilyMother);
|
||||
private ProfileFamilyMotherHistory = AppDataSource.getRepository(ProfileFamilyMotherHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getFamilyMotherUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyMother = await this.ProfileFamilyMother.findOne({
|
||||
select: [
|
||||
"id",
|
||||
"motherPrefix",
|
||||
"motherFirstName",
|
||||
"motherLastName",
|
||||
"motherCareer",
|
||||
"motherCitizenId",
|
||||
"motherLive",
|
||||
"profileId",
|
||||
],
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
||||
return new HttpSuccess(familyMother);
|
||||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,97 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
private positionRepo = AppDataSource.getRepository(EmployeePosition);
|
||||
private posMasterRepo = AppDataSource.getRepository(EmployeePosMaster);
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary ข้อมูลราชการ
|
||||
*
|
||||
*/
|
||||
@Get("user")
|
||||
public async getGovHistoryUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const record = await this.profileEmployeeRepo.findOne({
|
||||
where: { id: profile.id },
|
||||
relations: {
|
||||
posType: true,
|
||||
posLevel: true,
|
||||
},
|
||||
});
|
||||
const posMaster = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
current_holderId: profile.id,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
relations: {
|
||||
orgRoot: true,
|
||||
orgChild1: true,
|
||||
orgChild2: true,
|
||||
orgChild3: true,
|
||||
orgChild4: true,
|
||||
},
|
||||
});
|
||||
const position = await this.positionRepo.findOne({
|
||||
where: {
|
||||
positionIsSelected: true,
|
||||
posMaster: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
current_holderId: profile.id,
|
||||
},
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
const fullNameParts = [
|
||||
posMaster == null || posMaster.orgChild4 == null ? null : posMaster.orgChild4.orgChild4Name,
|
||||
posMaster == null || posMaster.orgChild3 == null ? null : posMaster.orgChild3.orgChild3Name,
|
||||
posMaster == null || posMaster.orgChild2 == null ? null : posMaster.orgChild2.orgChild2Name,
|
||||
posMaster == null || posMaster.orgChild1 == null ? null : posMaster.orgChild1.orgChild1Name,
|
||||
posMaster == null || posMaster.orgRoot == null ? null : posMaster.orgRoot.orgRootName,
|
||||
];
|
||||
const org = fullNameParts.filter((part) => part !== undefined && part !== null).join("/");
|
||||
let orgShortName = "";
|
||||
if (posMaster != null) {
|
||||
if (posMaster.orgChild1Id === null) {
|
||||
orgShortName = posMaster.orgRoot?.orgRootShortName;
|
||||
} else if (posMaster.orgChild2Id === null) {
|
||||
orgShortName = posMaster.orgChild1?.orgChild1ShortName;
|
||||
} else if (posMaster.orgChild3Id === null) {
|
||||
orgShortName = posMaster.orgChild2?.orgChild2ShortName;
|
||||
} else if (posMaster.orgChild4Id === null) {
|
||||
orgShortName = posMaster.orgChild3?.orgChild3ShortName;
|
||||
} else {
|
||||
orgShortName = posMaster.orgChild4?.orgChild4ShortName;
|
||||
}
|
||||
}
|
||||
const data = {
|
||||
org: org, //สังกัด
|
||||
position: record.position, //ตำแหน่ง
|
||||
posLevel: record.posLevel == null ? null : record.posLevel.posLevelName, //ระดับ
|
||||
posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง
|
||||
posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท
|
||||
dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate),
|
||||
dateRetireLaw: record.dateRetireLaw ?? null,
|
||||
govAge: record.dateStart == null ? null : calculateAge(record.dateStart),
|
||||
dateAppoint: record.dateAppoint,
|
||||
dateStart: record.dateStart,
|
||||
govAgeAbsent: record.govAgeAbsent,
|
||||
govAgePlus: record.govAgePlus,
|
||||
reasonSameDate: record.reasonSameDate,
|
||||
};
|
||||
|
||||
return new HttpSuccess(data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary ข้อมูลราชการ
|
||||
|
|
|
|||
|
|
@ -29,6 +29,18 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
private honorRepo = AppDataSource.getRepository(ProfileHonor);
|
||||
private honorHistoryRepo = AppDataSource.getRepository(ProfileHonorHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getHonorUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const record = await this.honorRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,23 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
private insigniaHistoryRepo = AppDataSource.getRepository(ProfileInsigniaHistory);
|
||||
private insigniaMetaRepo = AppDataSource.getRepository(Insignia);
|
||||
|
||||
@Get("user")
|
||||
public async getInsigniaUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const record = await this.insigniaRepo.find({
|
||||
relations: {
|
||||
insignia: {
|
||||
insigniaType: true,
|
||||
},
|
||||
},
|
||||
where: { profileEmployeeId: profile.id },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,19 @@ export class ProfileLeaveEmployeeController extends Controller {
|
|||
private leaveHistoryRepo = AppDataSource.getRepository(ProfileLeaveHistory);
|
||||
private leaveTypeRepository = AppDataSource.getRepository(LeaveType);
|
||||
|
||||
@Get("user")
|
||||
public async getLeaveUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const record = await this.leaveRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileEmployeeId: profile.id },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getLeave(@Path() profileId: string) {
|
||||
const record = await this.leaveRepo.find({
|
||||
|
|
|
|||
|
|
@ -33,6 +33,18 @@ export class ProfileNopaidEmployeeController extends Controller {
|
|||
private nopaidRepository = AppDataSource.getRepository(ProfileNopaid);
|
||||
private nopaidHistoryRepository = AppDataSource.getRepository(ProfileNopaidHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getNopaidUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepository.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const lists = await this.nopaidRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getNopaid(@Path() profileId: string) {
|
||||
const lists = await this.nopaidRepository.find({
|
||||
|
|
|
|||
|
|
@ -33,6 +33,18 @@ export class ProfileOtherEmployeeController extends Controller {
|
|||
private otherRepository = AppDataSource.getRepository(ProfileOther);
|
||||
private otherHistoryRepository = AppDataSource.getRepository(ProfileOtherHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getOtherUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepository.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const lists = await this.otherRepository.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
});
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getOther(@Path() profileId: string) {
|
||||
const lists = await this.otherRepository.find({
|
||||
|
|
|
|||
|
|
@ -34,6 +34,19 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
|
||||
private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getSalaryUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const record = await this.salaryRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { order: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getSalaryEmployee(@Path() profileId: string) {
|
||||
const record = await this.salaryRepo.find({
|
||||
|
|
|
|||
|
|
@ -33,6 +33,18 @@ export class ProfileTrainingEmployeeController extends Controller {
|
|||
private trainingRepo = AppDataSource.getRepository(ProfileTraining);
|
||||
private trainingHistoryRepo = AppDataSource.getRepository(ProfileTrainingHistory);
|
||||
|
||||
@Get("user")
|
||||
public async getTrainingUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const record = await this.trainingRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue