Merge branch 'develop' into adiDev
This commit is contained in:
commit
884fe694d0
11 changed files with 78 additions and 14 deletions
|
|
@ -24,7 +24,7 @@ import {
|
|||
ProfileChildren,
|
||||
UpdateProfileChildren,
|
||||
} from "../entities/ProfileChildren";
|
||||
|
||||
import Extension from "../interfaces/extension";
|
||||
@Route("api/v1/org/profile/family/children")
|
||||
@Tags("ProfileChildren")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -67,6 +67,7 @@ export class ProfileChildrenController extends Controller {
|
|||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
data.childrenCitizenId = Extension.CheckCitizen(String(data.childrenCitizenId));
|
||||
await this.childrenRepository.save(data);
|
||||
if(data){
|
||||
const history: ProfileChildrenHistory = Object.assign(new ProfileChildrenHistory(), {
|
||||
|
|
@ -101,6 +102,7 @@ export class ProfileChildrenController extends Controller {
|
|||
Object.assign(record, body);
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
||||
history.profileChildrenId = record.id;
|
||||
history.childrenCareer = record.childrenCareer;
|
||||
history.childrenFirstName = record.childrenFirstName;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import {
|
|||
UpdateProfileChildren,
|
||||
} from "../entities/ProfileChildren";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
|
||||
import Extension from "../interfaces/extension";
|
||||
@Route("api/v1/org/profile-employee/family/children")
|
||||
@Tags("ProfileChildren")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -73,6 +73,7 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
};
|
||||
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
data.childrenCitizenId = Extension.CheckCitizen(String(data.childrenCitizenId));
|
||||
await this.childrenRepository.save(data);
|
||||
if(data){
|
||||
const history: ProfileChildrenHistory = Object.assign(new ProfileChildrenHistory(), {
|
||||
|
|
@ -108,6 +109,7 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
Object.assign(record, body);
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
||||
history.profileChildrenId = record.id;
|
||||
history.childrenCareer = record.childrenCareer;
|
||||
history.childrenFirstName = record.childrenFirstName;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import { Profile } from "../entities/Profile";
|
||||
import { ProfileFamilyCouple, CreateProfileFamilyCouple, UpdateProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
|
||||
import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory";
|
||||
|
||||
import Extension from "../interfaces/extension";
|
||||
@Route("api/v1/org/profile/family/couple")
|
||||
@Tags("ProfileFamilyCouple")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -142,6 +142,7 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId));
|
||||
familyCouple.createdUserId = req.user.sub;
|
||||
familyCouple.createdFullName = req.user.name;
|
||||
familyCouple.lastUpdateUserId = req.user.sub;
|
||||
|
|
@ -187,6 +188,7 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
Object.assign(familyCouple, body);
|
||||
familyCouple.lastUpdateUserId = req.user.sub,
|
||||
familyCouple.lastUpdateFullName = req.user.name;
|
||||
familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId));
|
||||
history.profileFamilyCoupleId = familyCouple.id;
|
||||
history.couplePrefix = familyCouple.couplePrefix,
|
||||
history.coupleFirstName = familyCouple.coupleFirstName,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { ProfileFamilyCouple, CreateProfileEmployeeFamilyCouple, UpdateProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
|
||||
import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory";
|
||||
|
||||
import Extension from "../interfaces/extension";
|
||||
@Route("api/v1/org/profile-employee/family/couple")
|
||||
@Tags("ProfileEmployeeFamilyCouple")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -142,6 +142,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId));
|
||||
familyCouple.createdUserId = req.user.sub;
|
||||
familyCouple.createdFullName = req.user.name;
|
||||
familyCouple.lastUpdateUserId = req.user.sub;
|
||||
|
|
@ -187,6 +188,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
|||
Object.assign(familyCouple, body);
|
||||
familyCouple.lastUpdateUserId = req.user.sub,
|
||||
familyCouple.lastUpdateFullName = req.user.name;
|
||||
familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId));
|
||||
history.profileFamilyCoupleId = familyCouple.id;
|
||||
history.couplePrefix = familyCouple.couplePrefix,
|
||||
history.coupleFirstName = familyCouple.coupleFirstName,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import { Profile } from "../entities/Profile";
|
||||
import { ProfileFamilyFather, CreateProfileFamilyFather, UpdateProfileFamilyFather } from "../entities/ProfileFamilyFather";
|
||||
import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory";
|
||||
|
||||
import Extension from "../interfaces/extension";
|
||||
@Route("api/v1/org/profile/family/father")
|
||||
@Tags("ProfileFamilyFather")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -136,6 +136,7 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId));
|
||||
familyFather.createdUserId = req.user.sub;
|
||||
familyFather.createdFullName = req.user.name;
|
||||
familyFather.lastUpdateUserId = req.user.sub;
|
||||
|
|
@ -175,7 +176,7 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
Object.assign(familyFather, body);
|
||||
familyFather.lastUpdateUserId = req.user.sub,
|
||||
familyFather.lastUpdateFullName = req.user.name;
|
||||
|
||||
familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId));
|
||||
history.profileFamilyFatherId = familyFather.id; //profileFamilyFatherId
|
||||
history.fatherPrefix = familyFather.fatherPrefix,
|
||||
history.fatherFirstName = familyFather.fatherFirstName,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { ProfileFamilyFather, CreateProfileEmployeeFamilyFather, UpdateProfileFamilyFather } from "../entities/ProfileFamilyFather";
|
||||
import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory";
|
||||
|
||||
import Extension from "../interfaces/extension";
|
||||
@Route("api/v1/org/profile-employee/family/father")
|
||||
@Tags("ProfileEmployeeFamilyFather")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -136,6 +136,7 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId));
|
||||
familyFather.createdUserId = req.user.sub;
|
||||
familyFather.createdFullName = req.user.name;
|
||||
familyFather.lastUpdateUserId = req.user.sub;
|
||||
|
|
@ -175,7 +176,7 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
|||
Object.assign(familyFather, body);
|
||||
familyFather.lastUpdateUserId = req.user.sub,
|
||||
familyFather.lastUpdateFullName = req.user.name;
|
||||
|
||||
familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId));
|
||||
history.profileFamilyFatherId = familyFather.id;
|
||||
history.fatherPrefix = familyFather.fatherPrefix,
|
||||
history.fatherFirstName = familyFather.fatherFirstName,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import { Profile } from "../entities/Profile";
|
||||
import { ProfileFamilyMother, CreateProfileFamilyMother, UpdateProfileFamilyMother } from "../entities/ProfileFamilyMother";
|
||||
import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory";
|
||||
|
||||
import Extension from "../interfaces/extension";
|
||||
@Route("api/v1/org/profile/family/mother")
|
||||
@Tags("ProfileFamilyMother")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -136,6 +136,7 @@ export class ProfileFamilyMotherController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
familyMother.motherCitizenId = Extension.CheckCitizen(String(body.motherCitizenId));
|
||||
familyMother.createdUserId = req.user.sub;
|
||||
familyMother.createdFullName = req.user.name;
|
||||
familyMother.lastUpdateUserId = req.user.sub;
|
||||
|
|
@ -175,7 +176,7 @@ export class ProfileFamilyMotherController extends Controller {
|
|||
Object.assign(familyMother, body);
|
||||
familyMother.lastUpdateUserId = req.user.sub,
|
||||
familyMother.lastUpdateFullName = req.user.name;
|
||||
|
||||
familyMother.motherCitizenId = Extension.CheckCitizen(String(body.motherCitizenId));
|
||||
history.profileFamilyMotherId = familyMother.id;
|
||||
history.motherPrefix = familyMother.motherPrefix,
|
||||
history.motherFirstName = familyMother.motherFirstName,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { ProfileFamilyMother, CreateProfileEmployeeFamilyMother, UpdateProfileFamilyMother } from "../entities/ProfileFamilyMother";
|
||||
import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory";
|
||||
|
||||
import Extension from "../interfaces/extension";
|
||||
@Route("api/v1/org/profile-employee/family/mother")
|
||||
@Tags("ProfileEmployeeFamilyMother")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -136,6 +136,7 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
familyMother.motherCitizenId = Extension.CheckCitizen(String(body.motherCitizenId));
|
||||
familyMother.createdUserId = req.user.sub;
|
||||
familyMother.createdFullName = req.user.name;
|
||||
familyMother.lastUpdateUserId = req.user.sub;
|
||||
|
|
@ -175,7 +176,7 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
|||
Object.assign(familyMother, body);
|
||||
familyMother.lastUpdateUserId = req.user.sub,
|
||||
familyMother.lastUpdateFullName = req.user.name;
|
||||
|
||||
familyMother.motherCitizenId = Extension.CheckCitizen(String(body.motherCitizenId));
|
||||
history.profileFamilyMotherId = familyMother.id;
|
||||
history.motherPrefix = familyMother.motherPrefix,
|
||||
history.motherFirstName = familyMother.motherFirstName,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import HttpStatus from "../interfaces/http-status";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
class Extension {
|
||||
public static ToThaiMonth(value: number) {
|
||||
switch (value) {
|
||||
|
|
@ -119,6 +121,40 @@ class Extension {
|
|||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
public static CheckCitizen(value: string) {
|
||||
let citizen = value
|
||||
if (citizen.length !== 13) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก",);
|
||||
}
|
||||
const citizenIdDigits = citizen.toString().split("").map(Number);
|
||||
const cal =
|
||||
citizenIdDigits[0] * 13 +
|
||||
citizenIdDigits[1] * 12 +
|
||||
citizenIdDigits[2] * 11 +
|
||||
citizenIdDigits[3] * 10 +
|
||||
citizenIdDigits[4] * 9 +
|
||||
citizenIdDigits[5] * 8 +
|
||||
citizenIdDigits[6] * 7 +
|
||||
citizenIdDigits[7] * 6 +
|
||||
citizenIdDigits[8] * 5 +
|
||||
citizenIdDigits[9] * 4 +
|
||||
citizenIdDigits[10] * 3 +
|
||||
citizenIdDigits[11] * 2;
|
||||
const calStp2 = cal % 11;
|
||||
let chkDigit = 11 - calStp2;
|
||||
if (chkDigit === 10) {
|
||||
chkDigit = 1;
|
||||
}
|
||||
else if (chkDigit === 11) {
|
||||
chkDigit = chkDigit % 10;
|
||||
}
|
||||
|
||||
if (citizenIdDigits[12] !== chkDigit) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
|
||||
}
|
||||
return citizen;
|
||||
}
|
||||
}
|
||||
|
||||
export default Extension;
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ export class UpdateTableProfileSalaryHistoryDeleteProfileId11715914699824 implem
|
|||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`nationality\` varchar(255) NULL COMMENT 'สัญชาติ'`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`nationality\` varchar(255) NULL COMMENT 'สัญชาติ'`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD CONSTRAINT \`FK_f5758428d496b6d2a051c8af92b\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
// await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD CONSTRAINT \`FK_f5758428d496b6d2a051c8af92b\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP FOREIGN KEY \`FK_f5758428d496b6d2a051c8af92b\``);
|
||||
// await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP FOREIGN KEY \`FK_f5758428d496b6d2a051c8af92b\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`nationality\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`nationality\``);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateTableProfileSalaryHistoryDeleteProfileId21715919796147 implements MigrationInterface {
|
||||
name = 'UpdateTableProfileSalaryHistoryDeleteProfileId21715919796147'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee'`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD CONSTRAINT \`FK_f5758428d496b6d2a051c8af92b\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP FOREIGN KEY \`FK_f5758428d496b6d2a051c8af92b\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP COLUMN \`profileEmployeeId\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue