แก้ไขประวัติการศึกษา Issue #1242
This commit is contained in:
parent
848b574713
commit
4051e90e63
3 changed files with 79 additions and 2 deletions
|
|
@ -12,11 +12,10 @@ import {
|
||||||
Patch,
|
Patch,
|
||||||
Put,
|
Put,
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
|
import { Not } from "typeorm"
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ProfileEducation,
|
ProfileEducation,
|
||||||
CreateProfileEducation,
|
CreateProfileEducation,
|
||||||
|
|
@ -118,6 +117,18 @@ export class ProfileEducationsController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||||
|
if (body.isEducation) {
|
||||||
|
await this.profileEducationRepo.update(
|
||||||
|
{ profileId: body.profileId, isEducation: true },
|
||||||
|
{ isEducation: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (body.isHigh) {
|
||||||
|
await this.profileEducationRepo.update(
|
||||||
|
{ profileId: body.profileId, isHigh: true },
|
||||||
|
{ isHigh: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
const before = null;
|
const before = null;
|
||||||
const data = new ProfileEducation();
|
const data = new ProfileEducation();
|
||||||
const meta = {
|
const meta = {
|
||||||
|
|
@ -157,6 +168,18 @@ export class ProfileEducationsController extends Controller {
|
||||||
const record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
const record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||||
|
if (body.isEducation) {
|
||||||
|
await this.profileEducationRepo.update(
|
||||||
|
{ profileId: record.profileId, isEducation: true, id: Not(educationId) },
|
||||||
|
{ isEducation: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (body.isHigh) {
|
||||||
|
await this.profileEducationRepo.update(
|
||||||
|
{ profileId: record.profileId, isHigh: true, id: Not(educationId) },
|
||||||
|
{ isHigh: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
const before = structuredClone(record);
|
const before = structuredClone(record);
|
||||||
// const before_null = null;
|
// const before_null = null;
|
||||||
const history = new ProfileEducationHistory();
|
const history = new ProfileEducationHistory();
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import {
|
||||||
Patch,
|
Patch,
|
||||||
Put,
|
Put,
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
|
import { Not } from "typeorm"
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
|
|
@ -124,6 +125,18 @@ export class ProfileEducationsEmployeeController extends Controller {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
|
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
|
||||||
|
if (body.isEducation) {
|
||||||
|
await this.profileEducationRepo.update(
|
||||||
|
{ profileEmployeeId: body.profileEmployeeId, isEducation: true },
|
||||||
|
{ isEducation: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (body.isHigh) {
|
||||||
|
await this.profileEducationRepo.update(
|
||||||
|
{ profileEmployeeId: body.profileEmployeeId, isHigh: true },
|
||||||
|
{ isHigh: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
const before = null;
|
const before = null;
|
||||||
const data = new ProfileEducation();
|
const data = new ProfileEducation();
|
||||||
const meta = {
|
const meta = {
|
||||||
|
|
@ -167,6 +180,18 @@ export class ProfileEducationsEmployeeController extends Controller {
|
||||||
"SYS_REGISTRY_EMP",
|
"SYS_REGISTRY_EMP",
|
||||||
record.profileEmployeeId,
|
record.profileEmployeeId,
|
||||||
);
|
);
|
||||||
|
if (body.isEducation) {
|
||||||
|
await this.profileEducationRepo.update(
|
||||||
|
{ profileEmployeeId: record.profileEmployeeId, isEducation: true, id: Not(educationId) },
|
||||||
|
{ isEducation: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (body.isHigh) {
|
||||||
|
await this.profileEducationRepo.update(
|
||||||
|
{ profileEmployeeId: record.profileEmployeeId, isHigh: true, id: Not(educationId) },
|
||||||
|
{ isHigh: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
const before = structuredClone(record);
|
const before = structuredClone(record);
|
||||||
const before_null = null;
|
const before_null = null;
|
||||||
const history = new ProfileEducationHistory();
|
const history = new ProfileEducationHistory();
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import {
|
||||||
Patch,
|
Patch,
|
||||||
Put,
|
Put,
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
|
import { Not } from "typeorm"
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
|
|
@ -114,6 +115,22 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
|
if (body.isEducation) {
|
||||||
|
await this.profileEducationRepo.update(
|
||||||
|
{ profileEmployeeId: body.profileEmployeeId, isEducation: true },
|
||||||
|
{ isEducation: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (body.isHigh) {
|
||||||
|
const existing = await this.profileEducationRepo.find({
|
||||||
|
where: { profileId: body.profileEmployeeId, isHigh: true },
|
||||||
|
});
|
||||||
|
console.log("isHigh ",existing)
|
||||||
|
await this.profileEducationRepo.update(
|
||||||
|
{ profileEmployeeId: body.profileEmployeeId, isHigh: true },
|
||||||
|
{ isHigh: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
const before = null;
|
const before = null;
|
||||||
const data = new ProfileEducation();
|
const data = new ProfileEducation();
|
||||||
const meta = {
|
const meta = {
|
||||||
|
|
@ -153,6 +170,18 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
||||||
await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
|
||||||
const record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
const record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
if (body.isEducation) {
|
||||||
|
await this.profileEducationRepo.update(
|
||||||
|
{ profileEmployeeId: record.profileEmployeeId, isEducation: true, id: Not(educationId) },
|
||||||
|
{ isEducation: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (body.isHigh) {
|
||||||
|
await this.profileEducationRepo.update(
|
||||||
|
{ profileEmployeeId: record.profileEmployeeId, isHigh: true, id: Not(educationId) },
|
||||||
|
{ isHigh: false }
|
||||||
|
);
|
||||||
|
}
|
||||||
const before = structuredClone(record);
|
const before = structuredClone(record);
|
||||||
// const before_null = null;
|
// const before_null = null;
|
||||||
const history = new ProfileEducationHistory();
|
const history = new ProfileEducationHistory();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue