Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
1cbd9e7c26
12 changed files with 130 additions and 75 deletions
|
|
@ -103,7 +103,6 @@ export class ProfileAddressEmployeeTempController extends Controller {
|
|||
*/
|
||||
@Get("history/user")
|
||||
public async getProfileAddressHistoryUser(@Request() request: RequestWithUser) {
|
||||
// await new permission().PermissionGet(request, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export class ProfileAvatarEmployeeTempController extends Controller {
|
|||
@Path() id: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); //ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); //ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
const result = await this.avatarRepository.findOneBy({ id: id });
|
||||
if (!result) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
|
|||
|
|
@ -2285,7 +2285,7 @@ export class ProfileController extends Controller {
|
|||
) {
|
||||
const _record = await this.profileRepo.findOneBy({ id: id });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_OFFICER", _record.id); //ไม่แน่ใจOFF
|
||||
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_OFFICER", _record.id);
|
||||
}
|
||||
const exists =
|
||||
!!body.citizenId &&
|
||||
|
|
@ -4838,7 +4838,7 @@ export class ProfileController extends Controller {
|
|||
*/
|
||||
@Get("profileid/retire/{year}")
|
||||
async getProfileByRetireYear(@Path() year: number, @Request() req: RequestWithUser) {
|
||||
// await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_OFFICER", id);//ไม่แน่ใจOFF
|
||||
// await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_OFFICER", id);//ไม่แน่ใจOFFปิดไว้ก่อน
|
||||
const profiles = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ export class ProfileDutyController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id); //ไม่แน่ใจOFF
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||
|
||||
const data = new ProfileDuty();
|
||||
|
||||
|
|
|
|||
|
|
@ -580,7 +580,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Post()
|
||||
async createProfile(@Body() body: CreateProfileEmployee, @Request() request: RequestWithUser) { //ไม่แน่ใจEMP
|
||||
async createProfile(@Body() body: CreateProfileEmployee, @Request() request: RequestWithUser) {
|
||||
//ไม่แน่ใจEMPปิดไว้ก่อน
|
||||
if (await this.profileRepo.findOneBy({ citizenId: body.citizenId })) {
|
||||
throw new HttpError(
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
|
|
@ -1058,7 +1059,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
*/
|
||||
@Get("{id}")
|
||||
async detailProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id); //ไม่แน่ใจEMP
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
relations: {
|
||||
posLevel: true,
|
||||
|
|
@ -2659,7 +2660,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
*/
|
||||
@Get("profileid/retire/{year}")
|
||||
async getProfileByRetireYear(@Path() year: number, @Request() req: RequestWithUser) {
|
||||
// await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", id);//ไม่แน่ใจEMP
|
||||
// await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", id);//ไม่แน่ใจEMPปิดไว้ก่อน
|
||||
const profiles = await this.profileRepo
|
||||
.createQueryBuilder("profileEmployee")
|
||||
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
|
||||
|
|
@ -2862,7 +2863,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
where: { id: id },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profile.id);
|
||||
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profile.id);//ไม่แน่ใจEMPปิดไว้ก่อน
|
||||
|
||||
profile.isLeave = requestBody.isLeave;
|
||||
profile.leaveReason = requestBody.leaveReason;
|
||||
|
|
|
|||
|
|
@ -1056,7 +1056,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
*/
|
||||
@Get("{id}")
|
||||
async detailProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); //ไม่แน่ใจTEMP
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const profile = await this.profileRepo.findOne({
|
||||
relations: {
|
||||
posLevel: true,
|
||||
|
|
@ -2075,7 +2075,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
@Path() id: string,
|
||||
@Body() body: UpdatePositionTempProfileEmployee,
|
||||
) {
|
||||
// await new permission().PermissionUpdate(request, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionUpdate(request, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
if (body.posLevelId === "") body.posLevelId = null;
|
||||
if (body.posTypeId === "") body.posTypeId = null;
|
||||
|
||||
|
|
@ -2555,7 +2555,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
*/
|
||||
@Get("keycloak/position/{revisionId}")
|
||||
async getProfileByKeycloakByRevision(
|
||||
//ไม่แน่ใจTEMP
|
||||
//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
@Path() revisionId: string,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
|
|
@ -2657,7 +2657,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
*/
|
||||
@Get("profileid/retire/{year}")
|
||||
async getProfileByRetireYear(@Path() year: number, @Request() req: RequestWithUser) {
|
||||
// await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
const profiles = await this.profileRepo
|
||||
.createQueryBuilder("profileEmployee")
|
||||
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
|
||||
|
|
@ -2856,7 +2856,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
requestBody: { isLeave: boolean; leaveReason: string; dateLeave: Date },
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
// await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -2891,7 +2891,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
@Path() profileEmployeeId: string,
|
||||
@Body() body: UpdateInformationProfileEmployee,
|
||||
) {
|
||||
// await new permission().PermissionUpdate(request, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionUpdate(request, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
const profileEmp = await this.profileRepo.findOneBy({ id: profileEmployeeId });
|
||||
if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
|
||||
|
|
@ -2920,7 +2920,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
*/
|
||||
@Get("information/{profileEmployeeId}")
|
||||
async getInformationById(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
const profileInformation = await this.profileRepo.findOne({
|
||||
where: { id: profileEmployeeId },
|
||||
});
|
||||
|
|
@ -2951,7 +2951,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
*/
|
||||
@Get("information/history/{profileEmployeeId}")
|
||||
async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
// await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
const profileInformation = await this.profileRepo.find({
|
||||
relations: {
|
||||
information_histories: true,
|
||||
|
|
@ -2996,7 +2996,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
@Path() profileEmployeeId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
// await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
const employment = await this.employmentRepository.find({
|
||||
where: { profileEmployeeId: profileEmployeeId },
|
||||
order: { createdAt: "ASC" },
|
||||
|
|
@ -3018,7 +3018,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
*/
|
||||
@Get("employment/id/{id}")
|
||||
async GetEmploymentById(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
const employment = await this.employmentRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -3034,7 +3034,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
*/
|
||||
@Get("employment/history/{id}")
|
||||
async GetHistoryEmploymentById(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
const employmentHistory = await this.employmentHistoryRepository.find({
|
||||
where: { profileEmployeeEmploymentId: id },
|
||||
order: { lastUpdatedAt: "ASC" },
|
||||
|
|
@ -3055,7 +3055,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
@Body() body: CreateEmploymentProfileEmployee,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
// await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: profileEmployeeId },
|
||||
});
|
||||
|
|
@ -3091,7 +3091,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
*/
|
||||
@Delete("employment/{id}")
|
||||
async DeleteEmployment(@Path() id: string) {
|
||||
// await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
await this.employmentHistoryRepository.delete({
|
||||
profileEmployeeEmploymentId: id,
|
||||
});
|
||||
|
|
@ -3116,7 +3116,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
@Path() id: string,
|
||||
@Body() body: UpdateEmploymentProfileEmployee,
|
||||
) {
|
||||
// await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
const employment = await this.employmentRepository.findOneBy({ id });
|
||||
if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
|
|
@ -3146,7 +3146,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
*/
|
||||
@Post("report")
|
||||
async sendReport(@Request() request: RequestWithUser, @Body() requestBody: { id: string[] }) {
|
||||
// await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
const profiles = await this.profileRepo.find({ where: { id: In(requestBody.id) } });
|
||||
|
||||
const _profiles = await Promise.all(
|
||||
|
|
@ -3185,7 +3185,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
},
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
// await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
await Promise.all(
|
||||
body.result.map(async (v) => {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -3245,7 +3245,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
keyword?: string;
|
||||
},
|
||||
) {
|
||||
// await new permission().PermissionPost(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionPost(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
let findProfile: any;
|
||||
let total: any;
|
||||
const skip = (page - 1) * pageSize;
|
||||
|
|
@ -3404,7 +3404,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
*/
|
||||
@Get("profileid/position/{id}")
|
||||
async getProfileByProfileid(@Request() req: RequestWithUser, @Path() id: string) {
|
||||
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
|
||||
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: id },
|
||||
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"],
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id); //ไม่แน่ใจOFF
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||
familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId));
|
||||
familyCouple.createdUserId = req.user.sub;
|
||||
familyCouple.createdFullName = req.user.name;
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id); //ไม่แน่ใจOFF
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||
familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId));
|
||||
familyFather.createdUserId = req.user.sub;
|
||||
familyFather.createdFullName = req.user.name;
|
||||
|
|
@ -239,7 +239,7 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
@Body() body: UpdateProfileFamilyFather,
|
||||
@Path() profileId: string,
|
||||
) {
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId); //ไม่แน่ใจOFF
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const familyFather = await this.ProfileFamilyFather.findOneBy({ profileId: profileId });
|
||||
if (!familyFather) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ export class ProfileFamilyMotherController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id); //ไม่แน่ใจOFF
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||
familyMother.motherCitizenId = Extension.CheckCitizen(String(body.motherCitizenId));
|
||||
familyMother.createdUserId = req.user.sub;
|
||||
familyMother.createdFullName = req.user.name;
|
||||
|
|
@ -238,7 +238,7 @@ export class ProfileFamilyMotherController extends Controller {
|
|||
@Body() body: UpdateProfileFamilyMother,
|
||||
@Path() profileId: string,
|
||||
) {
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId); //ไม่แน่ใจOFF
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const familyMother = await this.ProfileFamilyMother.findOneBy({ profileId: profileId });
|
||||
if (!familyMother) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { Position } from "../entities/Position";
|
|||
import { PosMaster } from "../entities/PosMaster";
|
||||
import { calculateAge, calculateRetireDate } from "../interfaces/utils";
|
||||
import permission from "../interfaces/permission";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
@Route("api/v1/org/profile/government")
|
||||
@Tags("ProfileGovernment")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -18,7 +19,7 @@ export class ProfileGovernmentHistoryController extends Controller {
|
|||
private govRepo = AppDataSource.getRepository(ProfileGovernment);
|
||||
private positionRepo = AppDataSource.getRepository(Position);
|
||||
private posMasterRepo = AppDataSource.getRepository(PosMaster);
|
||||
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
/**
|
||||
*
|
||||
* @summary ข้อมูลราชการ
|
||||
|
|
@ -26,6 +27,13 @@ export class ProfileGovernmentHistoryController extends Controller {
|
|||
*/
|
||||
@Get("user")
|
||||
public async getGovHistoryUser(@Request() request: { user: Record<string, any> }) {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
});
|
||||
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -39,10 +47,11 @@ export class ProfileGovernmentHistoryController extends Controller {
|
|||
});
|
||||
const posMaster = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
// orgRevision: {
|
||||
// orgRevisionIsCurrent: true,
|
||||
// orgRevisionIsDraft: false,
|
||||
// },
|
||||
orgRevisionId: orgRevision?.id,
|
||||
current_holderId: profile.id,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
|
|
@ -58,10 +67,11 @@ export class ProfileGovernmentHistoryController extends Controller {
|
|||
where: {
|
||||
positionIsSelected: true,
|
||||
posMaster: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
// orgRevision: {
|
||||
// orgRevisionIsCurrent: true,
|
||||
// orgRevisionIsDraft: false,
|
||||
// },
|
||||
orgRevisionId: orgRevision?.id,
|
||||
current_holderId: profile.id,
|
||||
},
|
||||
},
|
||||
|
|
@ -129,6 +139,13 @@ export class ProfileGovernmentHistoryController extends Controller {
|
|||
@Example({})
|
||||
public async getGovHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
});
|
||||
const record = await this.profileRepo.findOne({
|
||||
where: { id: profileId },
|
||||
relations: {
|
||||
|
|
@ -138,10 +155,11 @@ export class ProfileGovernmentHistoryController extends Controller {
|
|||
});
|
||||
const posMaster = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
// orgRevision: {
|
||||
// orgRevisionIsCurrent: true,
|
||||
// orgRevisionIsDraft: false,
|
||||
// },
|
||||
orgRevisionId: orgRevision?.id,
|
||||
current_holderId: profileId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
|
|
@ -157,10 +175,11 @@ export class ProfileGovernmentHistoryController extends Controller {
|
|||
where: {
|
||||
positionIsSelected: true,
|
||||
posMaster: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
// orgRevision: {
|
||||
// orgRevisionIsCurrent: true,
|
||||
// orgRevisionIsDraft: false,
|
||||
// },
|
||||
orgRevisionId: orgRevision?.id,
|
||||
current_holderId: profileId,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import { EmployeePosition } from "../entities/EmployeePosition";
|
|||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import { calculateAge, calculateRetireDate } from "../interfaces/utils";
|
||||
import permission from "../interfaces/permission";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
@Route("api/v1/org/profile-employee/government")
|
||||
@Tags("ProfileEmployeeGovernment")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -35,7 +36,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
private govRepo = AppDataSource.getRepository(ProfileGovernment);
|
||||
private positionRepo = AppDataSource.getRepository(EmployeePosition);
|
||||
private posMasterRepo = AppDataSource.getRepository(EmployeePosMaster);
|
||||
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
/**
|
||||
*
|
||||
* @summary ข้อมูลราชการ
|
||||
|
|
@ -43,6 +44,13 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
*/
|
||||
@Get("user")
|
||||
public async getGovHistoryUser(@Request() request: { user: Record<string, any> }) {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
});
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -56,10 +64,11 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
});
|
||||
const posMaster = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
// orgRevision: {
|
||||
// orgRevisionIsCurrent: true,
|
||||
// orgRevisionIsDraft: false,
|
||||
// },
|
||||
orgRevisionId: orgRevision?.id,
|
||||
current_holderId: profile.id,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
|
|
@ -136,6 +145,13 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
@Example({})
|
||||
public async getGovHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
});
|
||||
const record = await this.profileEmployeeRepo.findOne({
|
||||
where: { id: profileEmployeeId },
|
||||
relations: {
|
||||
|
|
@ -145,10 +161,11 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
});
|
||||
const posMaster = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
// orgRevision: {
|
||||
// orgRevisionIsCurrent: true,
|
||||
// orgRevisionIsDraft: false,
|
||||
// },
|
||||
orgRevisionId: orgRevision?.id,
|
||||
current_holderId: profileEmployeeId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
|
|
@ -164,10 +181,11 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
where: {
|
||||
positionIsSelected: true,
|
||||
posMaster: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
// orgRevision: {
|
||||
// orgRevisionIsCurrent: true,
|
||||
// orgRevisionIsDraft: false,
|
||||
// },
|
||||
orgRevisionId: orgRevision?.id,
|
||||
current_holderId: profileEmployeeId,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import { EmployeePosition } from "../entities/EmployeePosition";
|
|||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import { calculateAge, calculateRetireDate } from "../interfaces/utils";
|
||||
import permission from "../interfaces/permission";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
@Route("api/v1/org/profile-temp/government")
|
||||
@Tags("ProfileEmployeeGovernment")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -35,7 +36,7 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
|
|||
private govRepo = AppDataSource.getRepository(ProfileGovernment);
|
||||
private positionRepo = AppDataSource.getRepository(EmployeePosition);
|
||||
private posMasterRepo = AppDataSource.getRepository(EmployeePosMaster);
|
||||
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
/**
|
||||
*
|
||||
* @summary ข้อมูลราชการ
|
||||
|
|
@ -43,6 +44,13 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
|
|||
*/
|
||||
@Get("user")
|
||||
public async getGovHistoryUser(@Request() request: { user: Record<string, any> }) {
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
});
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
|
|
@ -56,10 +64,11 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
|
|||
});
|
||||
const posMaster = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
// orgRevision: {
|
||||
// orgRevisionIsCurrent: true,
|
||||
// orgRevisionIsDraft: false,
|
||||
// },
|
||||
orgRevisionId: orgRevision?.id,
|
||||
current_holderId: profile.id,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
|
|
@ -136,6 +145,13 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
|
|||
@Example({})
|
||||
public async getGovHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||
select: ["id"],
|
||||
where: {
|
||||
orgRevisionIsDraft: false,
|
||||
orgRevisionIsCurrent: true,
|
||||
},
|
||||
});
|
||||
const record = await this.profileEmployeeRepo.findOne({
|
||||
where: { id: profileEmployeeId },
|
||||
relations: {
|
||||
|
|
@ -145,10 +161,11 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
|
|||
});
|
||||
const posMaster = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
// orgRevision: {
|
||||
// orgRevisionIsCurrent: true,
|
||||
// orgRevisionIsDraft: false,
|
||||
// },
|
||||
orgRevisionId: orgRevision?.id,
|
||||
current_holderId: profileEmployeeId,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
|
|
@ -164,10 +181,11 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
|
|||
where: {
|
||||
positionIsSelected: true,
|
||||
posMaster: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
// orgRevision: {
|
||||
// orgRevisionIsCurrent: true,
|
||||
// orgRevisionIsDraft: false,
|
||||
// },
|
||||
orgRevisionId: orgRevision?.id,
|
||||
current_holderId: profileEmployeeId,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue