add admin path ทะเบียนประวัติ

This commit is contained in:
AdisakKanthawilang 2024-09-03 15:08:29 +07:00
parent a7c1b2e6a9
commit 4bfecf7899
12 changed files with 205 additions and 52 deletions

View file

@ -61,17 +61,34 @@ export class ProfileAbilityController extends Controller {
return new HttpSuccess(getProfileAbilityId);
}
@Get("history/{abilityId}")
public async getProfileAbilityHistory(
@Get("admin/history/{abilityId}")
public async getProfileAbilityAdminHistory(
@Path() abilityId: string,
@Request() req: RequestWithUser,
) {
// const _record = await this.profileAbilityRepo.findOne({
// where: { id: abilityId },
// });
// if (_record) {
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
// }
const _record = await this.profileAbilityRepo.findOne({
where: { id: abilityId },
});
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}
const record = await this.profileAbilityHistoryRepo.find({
where: { profileAbilityId: abilityId },
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Get("history/{abilityId}")
public async getProfileAbilityHistory(
@Path() abilityId: string,
) {
const record = await this.profileAbilityHistoryRepo.find({
where: { profileAbilityId: abilityId },
order: { createdAt: "DESC" },

View file

@ -65,10 +65,36 @@ export class ProfileAssessmentsController extends Controller {
return new HttpSuccess(getProfileAssessments);
}
@Get("admin/history/{assessmentId}")
public async getProfileAssessmentsAdminHistory(
@Path() assessmentId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.profileAssessmentsRepository.findOne({
where: {
id: assessmentId,
},
});
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}
const record = await this.profileAssessmentsHistoryRepository.find({
where: {
profileAssessmentId: assessmentId,
},
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Get("history/{assessmentId}")
public async getProfileAssessmentsHistory(
@Path() assessmentId: string,
@Request() req: RequestWithUser,
) {
const record = await this.profileAssessmentsHistoryRepository.find({
where: {
@ -80,14 +106,6 @@ export class ProfileAssessmentsController extends Controller {
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
// const _record = await this.profileAssessmentsRepository.findOne({
// where: {
// id: assessmentId,
// },
// });
// if (_record) {
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
// }
return new HttpSuccess(record);
}

View file

@ -55,12 +55,23 @@ export class ProfileCertificateController extends Controller {
return new HttpSuccess(record);
}
@Get("admin/history/{certificateId}")
public async certificateAdminHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}
const record = await this.certificateHistoryRepo.find({
where: {
profileCertificateId: certificateId,
},
order: { createdAt: "DESC" },
});
return new HttpSuccess(record);
}
@Get("history/{certificateId}")
public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
// const _record = await this.certificateRepo.findOneBy({ id: certificateId });
// if (_record) {
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
// }
public async certificateHistory(@Path() certificateId: string) {
const record = await this.certificateHistoryRepo.find({
where: {
profileCertificateId: certificateId,

View file

@ -65,8 +65,8 @@ export class ProfileDisciplineController extends Controller {
return new HttpSuccess(lists);
}
@Get("history/{disciplineId}")
public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) {
@Get("admin/history/{disciplineId}")
public async disciplineAdminHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) {
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
@ -78,7 +78,16 @@ export class ProfileDisciplineController extends Controller {
return new HttpSuccess(record);
}
@Post()
@Get("history/{disciplineId}")
public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) {
const record = await this.disciplineHistoryRepository.find({
where: { profileDisciplineId: disciplineId },
order: { createdAt: "DESC" },
});
return new HttpSuccess(record);
}
@Post()
public async newDiscipline(
@Request() req: RequestWithUser,
@Body() body: CreateProfileDiscipline,

View file

@ -51,8 +51,8 @@ export class ProfileDutyController extends Controller {
return new HttpSuccess(lists);
}
@Get("history/{dutyId}")
public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) {
@Get("admin/history/{dutyId}")
public async dutyAdminHistory(@Path() dutyId: string, @Request() req: RequestWithUser) {
const _record = await this.dutyRepository.findOneBy({ id: dutyId });
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
@ -64,6 +64,15 @@ export class ProfileDutyController extends Controller {
return new HttpSuccess(record);
}
@Get("history/{dutyId}")
public async dutyHistory(@Path() dutyId: string,) {
const record = await this.dutyHistoryRepository.find({
where: { profileDutyId: dutyId },
order: { createdAt: "DESC" },
});
return new HttpSuccess(record);
}
@Post()
public async newDuty(@Request() req: RequestWithUser, @Body() body: CreateProfileDuty) {
if (!body.profileId) {

View file

@ -63,15 +63,31 @@ export class ProfileEducationsController extends Controller {
return new HttpSuccess(getProfileEducation);
}
@Get("history/{educationId}")
public async getProfileEducationHistory(
@Get("admin/history/{educationId}")
public async getProfileEducationAdminHistory(
@Path() educationId: string,
@Request() req: RequestWithUser,
) {
// const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
// if (_record) {
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
// }
const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}
const record = await this.profileEducationHistoryRepo.find({
where: {
profileEducationId: educationId,
},
order: { createdAt: "DESC" },
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
return new HttpSuccess(record);
}
@Get("history/{educationId}")
public async getProfileEducationHistory(
@Path() educationId: string,
) {
const record = await this.profileEducationHistoryRepo.find({
where: {
profileEducationId: educationId,

View file

@ -73,8 +73,8 @@ export class ProfileHonorController extends Controller {
return new HttpSuccess(record);
}
@Get("history/{honorId}")
public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) {
@Get("admin/history/{honorId}")
public async honorAdminHistory(@Path() honorId: string, @Request() req: RequestWithUser) {
const _record = await this.honorRepo.findOneBy({ id: honorId });
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
@ -88,6 +88,17 @@ export class ProfileHonorController extends Controller {
return new HttpSuccess(record);
}
@Get("history/{honorId}")
public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) {
const record = await this.honorHistoryRepo.find({
where: {
profileHonorId: honorId,
},
order: { createdAt: "DESC" },
});
return new HttpSuccess(record);
}
@Post()
public async newHonor(@Request() req: RequestWithUser, @Body() body: CreateProfileHonor) {
if (!body.profileId) {

View file

@ -66,9 +66,12 @@ export class ProfileInsigniaController extends Controller {
});
return new HttpSuccess(record);
}
@Get("history/{InsigniaId}")
public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
@Get("admin/history/{InsigniaId}")
public async getInsigniaAdminHistory(
@Path() InsigniaId: string,
@Request() req: RequestWithUser,
) {
const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId });
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
@ -87,6 +90,22 @@ export class ProfileInsigniaController extends Controller {
return new HttpSuccess(record);
}
@Get("history/{InsigniaId}")
public async getInsigniaHistory(@Path() InsigniaId: string) {
const record = await this.insigniaHistoryRepo.find({
relations: {
insignia: {
insigniaType: true,
},
},
where: {
profileInsigniaId: InsigniaId,
},
order: { createdAt: "DESC" },
});
return new HttpSuccess(record);
}
@Post()
public async newInsignia(@Request() req: RequestWithUser, @Body() body: CreateProfileInsignia) {
if (!body.profileId) {

View file

@ -146,8 +146,8 @@ export class ProfileLeaveController extends Controller {
return new HttpSuccess(record);
}
@Get("history/{leaveId}")
public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) {
@Get("admin/history/{leaveId}")
public async leaveAdminHistory(@Path() leaveId: string, @Request() req: RequestWithUser) {
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
@ -160,6 +160,16 @@ export class ProfileLeaveController extends Controller {
return new HttpSuccess(record);
}
@Get("history/{leaveId}")
public async leaveHistory(@Path() leaveId: string,) {
const record = await this.leaveHistoryRepo.find({
relations: { leaveType: true },
where: { profileLeaveId: leaveId },
order: { createdAt: "DESC" },
});
return new HttpSuccess(record);
}
@Post()
public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileLeave) {
if (!body.profileId) {

View file

@ -52,12 +52,23 @@ export class ProfileOtherController extends Controller {
return new HttpSuccess(lists);
}
@Get("admin/history/{otherId}")
public async otherAdminHistory(@Path() otherId: string, @Request() req: RequestWithUser) {
const _record = await this.otherRepository.findOneBy({ id: otherId });
console.log(">>>>", _record);
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}
const record = await this.otherHistoryRepository.find({
where: { profileOtherId: otherId },
order: { createdAt: "DESC" },
});
return new HttpSuccess(record);
}
@Get("history/{otherId}")
public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) {
// const _record = await this.otherRepository.findOneBy({ id: otherId });
// if (_record) {
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
// }
public async otherHistory(@Path() otherId: string,) {
const record = await this.otherHistoryRepository.find({
where: { profileOtherId: otherId },
order: { createdAt: "DESC" },

View file

@ -63,12 +63,23 @@ export class ProfileSalaryController extends Controller {
return new HttpSuccess(record);
}
@Get("admin/history/{salaryId}")
public async salaryAdminHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}
const record = await this.salaryHistoryRepo.find({
where: {
profileSalaryId: salaryId,
},
order: { createdAt: "DESC" },
});
return new HttpSuccess(record);
}
@Get("history/{salaryId}")
public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
// const _record = await this.salaryRepo.findOneBy({ id: salaryId });
// if (_record) {
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
// }
public async salaryHistory(@Path() salaryId: string,) {
const record = await this.salaryHistoryRepo.find({
where: {
profileSalaryId: salaryId,

View file

@ -55,8 +55,8 @@ export class ProfileTrainingController extends Controller {
return new HttpSuccess(record);
}
@Get("history/{trainingId}")
public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) {
@Get("admin/history/{trainingId}")
public async trainingAdminHistory(@Path() trainingId: string, @Request() req: RequestWithUser) {
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
if (_record) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId);
@ -70,6 +70,17 @@ export class ProfileTrainingController extends Controller {
return new HttpSuccess(record);
}
@Get("history/{trainingId}")
public async trainingHistory(@Path() trainingId: string,) {
const record = await this.trainingHistoryRepo.find({
where: {
profileTrainingId: trainingId,
},
order: { createdAt: "DESC" },
});
return new HttpSuccess(record);
}
@Post()
public async newTraining(@Request() req: RequestWithUser, @Body() body: CreateProfileTraining) {
if (!body.profileId) {