ทะเบียนประวัติใหม่
This commit is contained in:
parent
769352b4c2
commit
23b1b58dca
2 changed files with 76 additions and 1 deletions
|
|
@ -19,7 +19,7 @@ import { AppDataSource } from "../database/data-source";
|
|||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Profile, CreateProfile, UpdateProfile, ProfileHistory } from "../entities/Profile";
|
||||
import { Profile, CreateProfile, UpdateProfile, ProfileHistory, CreateProfileAllFields } from "../entities/Profile";
|
||||
import { Brackets, IsNull, Like, Not } from "typeorm";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
|
|
@ -199,6 +199,41 @@ export class ProfileController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API สร้างทะเบียนประวัติใหม่
|
||||
*
|
||||
* @summary ORG_065 - สร้างทะเบียนประวัติใหม่ (ADMIN) #XXX
|
||||
*
|
||||
*/
|
||||
@Post("all")
|
||||
async createProfileAll(@Request() request: RequestWithUser, @Body() body: CreateProfileAllFields) {
|
||||
if (await this.profileRepo.findOneBy({ citizenId: body.citizenId })) {
|
||||
throw new HttpError(
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
"เลขประจำตัวประชาชนนี้มีอยู่ในระบบแล้ว",
|
||||
);
|
||||
}
|
||||
|
||||
if (body.posLevelId === "") body.posLevelId = null;
|
||||
if (body.posTypeId === "") body.posTypeId = null;
|
||||
|
||||
if (body.posLevelId && !(await this.posLevelRepo.findOneBy({ id: body.posLevelId }))) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่งนี้");
|
||||
}
|
||||
|
||||
if (body.posTypeId && !(await this.posTypeRepo.findOneBy({ id: body.posTypeId }))) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
|
||||
}
|
||||
|
||||
const profile: Profile = Object.assign(new Profile(), body);
|
||||
profile.createdUserId = request.user.sub;
|
||||
profile.createdFullName = request.user.name;
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
await this.profileRepo.save(profile);
|
||||
return new HttpSuccess(profile.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API คำนวนวันเกษียณ
|
||||
*
|
||||
|
|
|
|||
|
|
@ -563,6 +563,46 @@ export class CreateProfile {
|
|||
// bloodGroup: string | null;
|
||||
}
|
||||
|
||||
export class CreateProfileAllFields {
|
||||
rank: string;
|
||||
prefix: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
citizenId: string;
|
||||
position: string;
|
||||
posLevelId: string | null;
|
||||
posTypeId: string | null;
|
||||
email: string;
|
||||
phone: string;
|
||||
keycloak: string;
|
||||
isProbation: boolean;
|
||||
isLeave : boolean;
|
||||
dateRetire : Date | null;
|
||||
dateAppoint : Date | null;
|
||||
dateStart: Date | null;
|
||||
govAgeAbsent: number;
|
||||
govAgePlus: number;
|
||||
birthDate: Date | null;
|
||||
reasonSameDate : Date | null;
|
||||
ethnicity : string;
|
||||
telephoneNumber : string;
|
||||
nationality : string;
|
||||
gender : string;
|
||||
relationship : string;
|
||||
religion : string;
|
||||
bloodGroup : string;
|
||||
registrationAddress : string;
|
||||
registrationProvinceId : string;
|
||||
registrationDistrictId: string;
|
||||
registrationSubDistrictId : string;
|
||||
registrationZipCode : string;
|
||||
currentAddress : string;
|
||||
currentProvinceId : string;
|
||||
currentDistrictId : string;
|
||||
currentSubDistrictId : string;
|
||||
currentZipCode : string;
|
||||
};
|
||||
|
||||
export type UpdateProfile = {
|
||||
rank?: string | null;
|
||||
prefix?: string | null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue