role เมนู ลูกจ้างประจำ กทม.
This commit is contained in:
parent
359d22beec
commit
7237c68cb8
23 changed files with 327 additions and 155 deletions
|
|
@ -117,7 +117,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
* @param {string} id Id โปรไฟล์
|
||||
*/
|
||||
@Get("kp7-short/{id}")
|
||||
async kp7ShortById(@Path() id: string) {
|
||||
async kp7ShortById(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
|
|
@ -136,6 +136,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
where: { id: id },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id);
|
||||
|
||||
const province = await this.provinceRepository.findOneBy({
|
||||
id: profile.registrationProvinceId,
|
||||
|
|
@ -240,7 +241,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
* @param {string} id Id โปรไฟล์
|
||||
*/
|
||||
@Get("kk1/{id}")
|
||||
public async getKk1Employee(@Path() id: string) {
|
||||
public async getKk1Employee(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
const profiles = await this.profileRepo.findOne({
|
||||
// select: [
|
||||
// "citizenId",
|
||||
|
|
@ -257,6 +258,9 @@ export class ProfileEmployeeController extends Controller {
|
|||
relations: ["currentSubDistrict", "currentDistrict", "currentProvince"],
|
||||
where: { id: id },
|
||||
});
|
||||
if(profiles){
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profiles.id);
|
||||
}
|
||||
const profileOc = await this.profileRepo.findOne({
|
||||
relations: [
|
||||
"current_holders",
|
||||
|
|
@ -576,8 +580,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Post()
|
||||
async createProfile(@Body() body: CreateProfileEmployee, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionCreate(request, "SYS_REGISTRY_TEMP");
|
||||
async createProfile(@Body() body: CreateProfileEmployee, @Request() request: RequestWithUser) { //ตส
|
||||
if (await this.profileRepo.findOneBy({ citizenId: body.citizenId })) {
|
||||
throw new HttpError(
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
|
|
@ -630,7 +633,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
@Path() id: string,
|
||||
@Body() body: UpdateProfileEmployee,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_REGISTRY_EMP");
|
||||
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", id)
|
||||
const exists =
|
||||
!!body.citizenId &&
|
||||
(await this.profileRepo.findOne({
|
||||
|
|
@ -694,11 +697,11 @@ export class ProfileEmployeeController extends Controller {
|
|||
*/
|
||||
@Delete("{id}")
|
||||
async deleteProfile(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request, "SYS_REGISTRY_EMP");
|
||||
const result = await this.profileRepo.findOne({ where: { id: id } });
|
||||
if (!result) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(request, "SYS_REGISTRY_EMP", result.id);
|
||||
await this.informationHistoryRepository.delete({ profileEmployeeId: id });
|
||||
await this.profileRepo.remove(result);
|
||||
return new HttpSuccess();
|
||||
|
|
@ -1054,7 +1057,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
* @param {string} id Id ทะเบียนประวัติ
|
||||
*/
|
||||
@Get("{id}")
|
||||
async detailProfile(@Path() id: string) {
|
||||
async detailProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id);
|
||||
const profile = await this.profileRepo.findOne({
|
||||
relations: {
|
||||
posLevel: true,
|
||||
|
|
@ -1307,7 +1311,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("history/{id}")
|
||||
async getProfileHistory(@Path() id: string) {
|
||||
async getProfileHistory(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id);
|
||||
const profile = await this.profileHistoryRepo.find({
|
||||
relations: {
|
||||
posLevel: true,
|
||||
|
|
@ -2072,7 +2077,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
@Path() id: string,
|
||||
@Body() body: UpdatePositionTempProfileEmployee,
|
||||
) {
|
||||
await new permission().PermissionCreate(request, "SYS_REGISTRY_TEMP");
|
||||
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", id)
|
||||
if (body.posLevelId === "") body.posLevelId = null;
|
||||
if (body.posTypeId === "") body.posTypeId = null;
|
||||
|
||||
|
|
@ -2202,9 +2207,11 @@ export class ProfileEmployeeController extends Controller {
|
|||
@Put("citizenId/{id}")
|
||||
async checkCitizenIdProfile(
|
||||
@Path() id: string,
|
||||
@Request() req: RequestWithUser,
|
||||
@Body()
|
||||
requestBody: { citizenId: string },
|
||||
) {
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", id)
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: Not(id), citizenId: requestBody.citizenId },
|
||||
});
|
||||
|
|
@ -2553,6 +2560,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
@Get("keycloak/position/{revisionId}")
|
||||
async getProfileByKeycloakByRevision(
|
||||
@Path() revisionId: string,
|
||||
@Path() req: RequestWithUser,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -2562,7 +2570,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
}
|
||||
|
||||
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profile.id)
|
||||
const _profile = {
|
||||
profileId: profile.id,
|
||||
rank: profile.rank,
|
||||
|
|
@ -2651,7 +2659,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
* @summary ข้อมูลบุลคลที่มีอายุเกษียณราชการตามปี
|
||||
*
|
||||
*/
|
||||
@Get("profileid/retire/{year}")
|
||||
@Get("profileid/retire/{year}") //ตส
|
||||
async getProfileByRetireYear(@Path() year: number) {
|
||||
const profiles = await this.profileRepo
|
||||
.createQueryBuilder("profileEmployee")
|
||||
|
|
@ -2849,12 +2857,13 @@ export class ProfileEmployeeController extends Controller {
|
|||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: { isLeave: boolean; leaveReason: string; dateLeave: Date },
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserCreate(request, "SYS_REGISTRY_EMP", profile.id)
|
||||
|
||||
profile.isLeave = requestBody.isLeave;
|
||||
profile.leaveReason = requestBody.leaveReason;
|
||||
|
|
@ -2885,7 +2894,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
@Path() profileEmployeeId: string,
|
||||
@Body() body: UpdateInformationProfileEmployee,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_REGISTRY_TEMP");
|
||||
|
||||
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profileEmployeeId)
|
||||
const profileEmp = await this.profileRepo.findOneBy({ id: profileEmployeeId });
|
||||
if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
|
||||
|
|
@ -2913,7 +2923,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
* @param {string} profileEmployeeId profileEmployeeId ทะเบียนประวัติลูกจ้างชั่วคราว
|
||||
*/
|
||||
@Get("information/{profileEmployeeId}")
|
||||
async getInformationById(@Path() profileEmployeeId: string) {
|
||||
async getInformationById(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId)
|
||||
const profileInformation = await this.profileRepo.findOne({
|
||||
where: { id: profileEmployeeId },
|
||||
});
|
||||
|
|
@ -2943,7 +2954,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
* @param {string} profileEmployeeId profileEmployeeId ทะเบียนประวัติลูกจ้างชั่วคราว
|
||||
*/
|
||||
@Get("information/history/{profileEmployeeId}")
|
||||
async getInformationHistory(@Path() profileEmployeeId: string) {
|
||||
async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId)
|
||||
const profileInformation = await this.profileRepo.find({
|
||||
relations: {
|
||||
information_histories: true,
|
||||
|
|
@ -2984,7 +2996,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
* @param {string} profileEmployeeId profileEmployeeId ทะเบียนประวัติลูกจ้างชั่วคราว
|
||||
*/
|
||||
@Get("employment/{profileEmployeeId}")
|
||||
async ProfileEmployeeEmployment(@Path() profileEmployeeId: string) {
|
||||
async ProfileEmployeeEmployment(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId)
|
||||
const employment = await this.employmentRepository.find({
|
||||
where: { profileEmployeeId: profileEmployeeId },
|
||||
order: { createdAt: "ASC" },
|
||||
|
|
@ -3005,10 +3018,13 @@ export class ProfileEmployeeController extends Controller {
|
|||
* @param {string} id Id ข้อมูลการจ้าง
|
||||
*/
|
||||
@Get("employment/id/{id}")
|
||||
async GetEmploymentById(@Path() id: string) {
|
||||
async GetEmploymentById(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
const employment = await this.employmentRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (employment) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", employment.profileEmployeeId)
|
||||
}
|
||||
return new HttpSuccess(employment);
|
||||
}
|
||||
|
||||
|
|
@ -3020,7 +3036,13 @@ export class ProfileEmployeeController extends Controller {
|
|||
* @param {string} id Id ข้อมูลการจ้าง
|
||||
*/
|
||||
@Get("employment/history/{id}")
|
||||
async GetHistoryEmploymentById(@Path() id: string) {
|
||||
async GetHistoryEmploymentById(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
const employment = await this.employmentRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (employment) {
|
||||
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", employment.profileEmployeeId)
|
||||
}
|
||||
const employmentHistory = await this.employmentHistoryRepository.find({
|
||||
where: { profileEmployeeEmploymentId: id },
|
||||
order: { lastUpdatedAt: "ASC" },
|
||||
|
|
@ -3045,6 +3067,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
where: { id: profileEmployeeId },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserList(request, "SYS_REGISTRY_EMP", profile.id)
|
||||
|
||||
const employment = new ProfileEmployeeEmployment();
|
||||
// const history = new ProfileEmployeeEmploymentHistory();
|
||||
|
|
@ -3076,7 +3099,12 @@ export class ProfileEmployeeController extends Controller {
|
|||
*/
|
||||
@Delete("employment/{id}")
|
||||
async DeleteEmployment(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request, "SYS_REGISTRY_TEMP");
|
||||
const employment = await this.employmentRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (employment) {
|
||||
await new permission().PermissionOrgUserDelete(request, "SYS_REGISTRY_EMP", employment.profileEmployeeId)
|
||||
}
|
||||
await this.employmentHistoryRepository.delete({
|
||||
profileEmployeeEmploymentId: id,
|
||||
});
|
||||
|
|
@ -3101,9 +3129,10 @@ export class ProfileEmployeeController extends Controller {
|
|||
@Path() id: string,
|
||||
@Body() body: UpdateEmploymentProfileEmployee,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_REGISTRY_TEMP");
|
||||
|
||||
const employment = await this.employmentRepository.findOneBy({ id });
|
||||
if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", employment.profileEmployeeId)
|
||||
|
||||
const history = new ProfileEmployeeEmploymentHistory();
|
||||
Object.assign(history, { ...employment, id: undefined });
|
||||
|
|
@ -3386,7 +3415,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
*/
|
||||
@Get("profileid/position/{id}")
|
||||
async getProfileByProfileid(
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
@Path() id: string,
|
||||
) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -3396,6 +3425,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||
}
|
||||
await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_EMP", profile.id);
|
||||
|
||||
const orgRevisionPublish = await this.orgRevisionRepo
|
||||
.createQueryBuilder("orgRevision")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue