permisstion ทะเบียนประวัติ(ที่ระบบอื่นๆ)

This commit is contained in:
Bright 2024-08-28 17:04:39 +07:00
parent ff8917195f
commit 4bee31e74e
18 changed files with 496 additions and 5 deletions

View file

@ -36,6 +36,18 @@ export class ProfileAvatarController extends Controller {
return new HttpSuccess(profile);
}
@Get("profileId-admin/{id}")
async getProfileAdmin(@Path() id: string) {
const profile = await this.profileRepository.findOne({
select: ["id", "avatar", "avatarName"],
where: { id },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(profile);
}
@Get("select/{profileId}/{id}")
public async selectAvatar(@Path() profileId: string, @Path() id: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);

View file

@ -26,6 +26,31 @@ export class ProfileAvatarEmployeeController extends Controller {
return new HttpSuccess(lists);
}
@Get("profileEmployeeId/{id}")
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id);
const profile = await this.profileRepository.findOne({
select: ["id", "avatar", "avatarName"],
where: { id },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(profile);
}
@Get("profileEmployeeId-admin/{id}")
async getProfileAdmin(@Path() id: string) {
const profile = await this.profileRepository.findOne({
select: ["id", "avatar", "avatarName"],
where: { id },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(profile);
}
@Get("select/{profileEmployeeId}/{id}")
public async selectAvatarEmployee(
@Path() profileEmployeeId: string,

View file

@ -26,6 +26,31 @@ export class ProfileAvatarEmployeeTempController extends Controller {
return new HttpSuccess(lists);
}
@Get("profileEmployeeId/{id}")
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_TEMP", id);
const profile = await this.profileRepository.findOne({
select: ["id", "avatar", "avatarName"],
where: { id },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(profile);
}
@Get("profileEmployeeId-admin/{id}")
async getProfileAdmin(@Path() id: string) {
const profile = await this.profileRepository.findOne({
select: ["id", "avatar", "avatarName"],
where: { id },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(profile);
}
@Get("select/{profileEmployeeId}/{id}")
public async selectAvatarEmployee(
@Path() profileEmployeeId: string,

View file

@ -2486,6 +2486,21 @@ export class ProfileController extends Controller {
return new HttpSuccess(profile);
}
@Get("admin/{id}")
async getProfileAdmin(@Path() id: string) {
const profile = await this.profileRepo.findOne({
relations: {
posLevel: true,
posType: true,
},
where: { id },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(profile);
}
// @Get("keycloak/{id}")
// async getProfileByKeycloakId(@Path() id: string) {
// const profile = await this.profileRepo.findOne({

View file

@ -76,6 +76,26 @@ export class ProfileDisciplineController extends Controller {
return new HttpSuccess(lists);
}
@Get("admin/{profileId}")
public async getDisciplineAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_SALARY_OFFICER");
const lists = await this.disciplineRepository.find({
where: { profileId: profileId },
select: [
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
});
return new HttpSuccess(lists);
}
@Get("history/{disciplineId}")
@Example({
status: 200,

View file

@ -91,6 +91,26 @@ export class ProfileDisciplineEmployeeController extends Controller {
return new HttpSuccess(lists);
}
@Get("admin/{profileId}")
public async getDisciplineAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_WAGE");
const lists = await this.disciplineRepository.find({
where: { profileEmployeeId: profileId },
select: [
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
});
return new HttpSuccess(lists);
}
@Get("history/{disciplineId}")
public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) {
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });

View file

@ -91,6 +91,26 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
return new HttpSuccess(lists);
}
@Get("admin/{profileId}")
public async getDisciplineAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_WAGE");
const lists = await this.disciplineRepository.find({
where: { profileEmployeeId: profileId },
select: [
"id",
"date",
"level",
"detail",
"unStigma",
"refCommandNo",
"refCommandDate",
"lastUpdateFullName",
"lastUpdatedAt",
],
});
return new HttpSuccess(lists);
}
@Get("history/{disciplineId}")
public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) {
await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");

View file

@ -1076,6 +1076,21 @@ export class ProfileEmployeeController extends Controller {
return new HttpSuccess(profile);
}
@Get("admin/{id}")
async detailProfileAdmin(@Path() id: string) {
const profile = await this.profileRepo.findOne({
relations: {
posLevel: true,
posType: true,
},
where: { id },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(profile);
}
/**
* API
*

View file

@ -1073,6 +1073,21 @@ export class ProfileEmployeeTempController extends Controller {
return new HttpSuccess(profile);
}
@Get("admin/{id}")
async detailProfileAdmin(@Path() id: string) {
const profile = await this.profileRepo.findOne({
relations: {
posLevel: true,
posType: true,
},
where: { id },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(profile);
}
/**
* API
*

View file

@ -238,6 +238,99 @@ export class ProfileGovernmentHistoryController extends Controller {
return new HttpSuccess(data);
}
@Get("admin/{profileId}")
public async getGovHistoryAdmin(@Path() profileId: string) {
const orgRevision = await this.orgRevisionRepository.findOne({
select: ["id"],
where: {
orgRevisionIsDraft: false,
orgRevisionIsCurrent: true,
},
});
const record = await this.profileRepo.findOne({
where: { id: profileId },
relations: {
posType: true,
posLevel: true,
},
});
const posMaster = await this.posMasterRepo.findOne({
where: {
orgRevisionId: orgRevision?.id,
current_holderId: profileId,
},
order: { createdAt: "DESC" },
relations: {
orgRoot: true,
orgChild1: true,
orgChild2: true,
orgChild3: true,
orgChild4: true,
},
});
const position = await this.positionRepo.findOne({
where: {
positionIsSelected: true,
posMaster: {
orgRevisionId: orgRevision?.id,
current_holderId: profileId,
},
},
order: { createdAt: "DESC" },
relations: {
posExecutive: true,
},
});
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, //สังกัด
positionField: position == null ? null : position.positionField, //สายงาน
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, //ประเภท
posExecutive:
position == null || position.posExecutive == null
? null
: position.posExecutive.posExecutiveName, //ตำแหน่งทางการบริหาร
positionArea: position == null ? null : position.positionArea, //ด้าน/สาขา
positionExecutiveField: position == null ? null : position.positionExecutiveField, //ด้านทางการบริหาร
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 by keycloak

View file

@ -234,6 +234,89 @@ export class ProfileGovernmentEmployeeController extends Controller {
return new HttpSuccess(data);
}
@Get("admin/{profileEmployeeId}")
public async getGovHistoryAdmin(@Path() profileEmployeeId: string) {
const orgRevision = await this.orgRevisionRepository.findOne({
select: ["id"],
where: {
orgRevisionIsDraft: false,
orgRevisionIsCurrent: true,
},
});
const record = await this.profileEmployeeRepo.findOne({
where: { id: profileEmployeeId },
relations: {
posType: true,
posLevel: true,
},
});
const posMaster = await this.posMasterRepo.findOne({
where: {
orgRevisionId: orgRevision?.id,
current_holderId: profileEmployeeId,
},
order: { createdAt: "DESC" },
relations: {
orgRoot: true,
orgChild1: true,
orgChild2: true,
orgChild3: true,
orgChild4: true,
},
});
const position = await this.positionRepo.findOne({
where: {
positionIsSelected: true,
posMaster: {
orgRevisionId: orgRevision?.id,
current_holderId: profileEmployeeId,
},
},
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), //วันเกษียณ
dateAppoint: record.dateAppoint, //วันที่สั่งบรรจุ
dateStart: record.dateStart, //วันที่เริ่มปฎิบัติงานราชการ
reasonSameDate: record.reasonSameDate, //เหตุผลที่วันที่ไม่ตรงกัน
dateRetire: record.dateRetire ?? null, //วันครบเกษียณอายุ
govAge: record.dateStart == null ? null : calculateAge(record.dateStart), //อายุราชการ
govAgeAbsent: record.govAgeAbsent ?? null, // ขาดราชการ
govAgePlus: record.govAgePlus, // อายุราชการเกื้อกูล
dateRetireLaw: record.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย
};
return new HttpSuccess(data);
}
/**
*
* @summary by keycloak

View file

@ -234,6 +234,90 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
return new HttpSuccess(data);
}
@Get("admin/{profileEmployeeId}")
@Example({})
public async getGovHistoryAdmin(@Path() profileEmployeeId: string) {
const orgRevision = await this.orgRevisionRepository.findOne({
select: ["id"],
where: {
orgRevisionIsDraft: false,
orgRevisionIsCurrent: true,
},
});
const record = await this.profileEmployeeRepo.findOne({
where: { id: profileEmployeeId },
relations: {
posType: true,
posLevel: true,
},
});
const posMaster = await this.posMasterRepo.findOne({
where: {
orgRevisionId: orgRevision?.id,
current_holderId: profileEmployeeId,
},
order: { createdAt: "DESC" },
relations: {
orgRoot: true,
orgChild1: true,
orgChild2: true,
orgChild3: true,
orgChild4: true,
},
});
const position = await this.positionRepo.findOne({
where: {
positionIsSelected: true,
posMaster: {
orgRevisionId: orgRevision?.id,
current_holderId: profileEmployeeId,
},
},
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), //วันเกษียณ
dateAppoint: record.dateAppoint, //วันที่สั่งบรรจุ
dateStart: record.dateStart, //วันที่เริ่มปฎิบัติงานราชการ
reasonSameDate: record.reasonSameDate, //เหตุผลที่วันที่ไม่ตรงกัน
dateRetire: record.dateRetire ?? null, //วันครบเกษียณอายุ
govAge: record.dateStart == null ? null : calculateAge(record.dateStart), //อายุราชการ
govAgeAbsent: record.govAgeAbsent ?? null, // ขาดราชการ
govAgePlus: record.govAgePlus, // อายุราชการเกื้อกูล
dateRetireLaw: record.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย
};
return new HttpSuccess(data);
}
/**
*
* @summary by keycloak

View file

@ -169,6 +169,16 @@ export class ProfileLeaveController extends Controller {
return new HttpSuccess(record);
}
@Get("admin/{profileId}")
public async getLeaveAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_SALARY_OFFICER");
const record = await this.leaveRepo.find({
relations: { leaveType: true },
where: { profileId },
});
return new HttpSuccess(record);
}
@Get("history/{leaveId}")
@Example({
status: 200,

View file

@ -58,6 +58,16 @@ export class ProfileLeaveEmployeeController extends Controller {
return new HttpSuccess(record);
}
@Get("admin/{profileId}")
public async getLeaveAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_WAGE");
const record = await this.leaveRepo.find({
relations: { leaveType: true },
where: { profileEmployeeId: profileId },
});
return new HttpSuccess(record);
}
@Get("history/{leaveId}")
public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) {
const _record = await this.leaveRepo.findOneBy({ id: leaveId });

View file

@ -58,9 +58,19 @@ export class ProfileLeaveEmployeeTempController extends Controller {
return new HttpSuccess(record);
}
@Get("admin/{profileId}")
public async getLeaveAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_WAGE");
const record = await this.leaveRepo.find({
relations: { leaveType: true },
where: { profileEmployeeId: profileId },
});
return new HttpSuccess(record);
}
@Get("history/{leaveId}")
public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) {
await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.leaveHistoryRepo.find({
relations: { leaveType: true },
where: { profileLeaveId: leaveId },

View file

@ -81,6 +81,16 @@ export class ProfileSalaryController extends Controller {
return new HttpSuccess(record);
}
@Get("admin/{profileId}")
public async getSalaryAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_SALARY_OFFICER");
const record = await this.salaryRepo.find({
where: { profileId: profileId },
order: { order: "ASC" },
});
return new HttpSuccess(record);
}
@Get("history/{salaryId}")
@Example({
status: 200,

View file

@ -49,10 +49,24 @@ export class ProfileSalaryEmployeeController extends Controller {
@Get("{profileId}")
public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) {
const _record = await this.salaryRepo.findOneBy({ id: profileId });
if (_record) {
// const _record = await this.salaryRepo.findOneBy({ id: profileId });
// if (_record) {
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileId);
}
// }
const record = await this.salaryRepo.find({
where: { profileEmployeeId: profileId },
order: { order: "ASC" },
});
return new HttpSuccess(record);
}
@Get("admin/{profileId}")
public async getSalaryEmployeeAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_WAGE");
// const _record = await this.salaryRepo.findOneBy({ id: profileId });
// if (_record) {
// await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileId);
// }
const record = await this.salaryRepo.find({
where: { profileEmployeeId: profileId },
order: { order: "ASC" },

View file

@ -49,7 +49,17 @@ export class ProfileSalaryEmployeeTempController extends Controller {
@Get("{profileId}")
public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const record = await this.salaryRepo.find({
where: { profileEmployeeId: profileId },
order: { order: "ASC" },
});
return new HttpSuccess(record);
}
@Get("admin/{profileId}")
public async getSalaryEmployeeAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_WAGE");
const record = await this.salaryRepo.find({
where: { profileEmployeeId: profileId },
order: { order: "ASC" },