Migrate เพิ่มฟิลด์ privac + API update status privac #2186
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
This commit is contained in:
parent
b8421d29ed
commit
f6b03752e1
4 changed files with 146 additions and 0 deletions
|
|
@ -30,6 +30,7 @@ import {
|
|||
UpdateProfileFather,
|
||||
UpdateProfileMother,
|
||||
UpdateProfileCouple,
|
||||
UpdatePrivacyDto
|
||||
} from "../entities/Profile";
|
||||
import { Brackets, In, IsNull, Like, Not } from "typeorm";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
|
|
@ -5176,6 +5177,67 @@ export class ProfileController extends Controller {
|
|||
return new HttpSuccess(lastestData.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API อัพเดทสถานะ privacy
|
||||
*
|
||||
* @summary API อัพเดทสถานะ privacy
|
||||
*
|
||||
*/
|
||||
@Put("privacy")
|
||||
async updatePrivacy(
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Body() body: UpdatePrivacyDto
|
||||
) {
|
||||
let isEmployee = false;
|
||||
let profile: any = null;
|
||||
profile = await this.profileRepo.findOneBy({
|
||||
keycloak: request.user.sub,
|
||||
});
|
||||
|
||||
if (!profile) {
|
||||
profile = await this.profileEmpRepo.findOne({
|
||||
where: { keycloak: request.user.sub },
|
||||
});
|
||||
isEmployee = true;
|
||||
}
|
||||
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const system = body.system.trim().toUpperCase();
|
||||
switch (system) {
|
||||
case "CHECKIN":
|
||||
profile.privacyCheckin = body.accept;
|
||||
break;
|
||||
|
||||
case "USER":
|
||||
profile.privacyUser = body.accept;
|
||||
break;
|
||||
|
||||
case "MGT":
|
||||
profile.privacyMgt = body.accept;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new HttpError(
|
||||
HttpStatus.BAD_REQUEST,
|
||||
"system ไม่ถูกต้อง"
|
||||
);
|
||||
}
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
profile.lastUpdateFullName = request.user.name;
|
||||
profile.lastUpdatedAt = new Date();
|
||||
|
||||
if (isEmployee) {
|
||||
await this.profileEmpRepo.save(profile, { data: request });
|
||||
} else {
|
||||
await this.profileRepo.save(profile, { data: request });
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขทะเบียนประวัติ
|
||||
*
|
||||
|
|
@ -7354,6 +7416,9 @@ export class ProfileController extends Controller {
|
|||
type: profile.employeeClass,
|
||||
salary: profile.amount,
|
||||
posNo: null,
|
||||
privacyCheckin: profile.privacyCheckin,
|
||||
privacyUser: profile.privacyUser,
|
||||
privacyMgt : profile.privacyMgt
|
||||
// root?.orgRootShortName && posMaster?.posMasterNo
|
||||
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
|
||||
// : "",
|
||||
|
|
@ -7523,6 +7588,9 @@ export class ProfileController extends Controller {
|
|||
salary: profile ? profile.amount : null,
|
||||
amountSpecial: profile ? profile.amountSpecial : null,
|
||||
posNo: null,
|
||||
privacyCheckin: profile.privacyCheckin,
|
||||
privacyUser: profile.privacyUser,
|
||||
privacyMgt : profile.privacyMgt
|
||||
// root?.orgRootShortName && posMaster?.posMasterNo
|
||||
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
|
||||
// : "",
|
||||
|
|
|
|||
|
|
@ -421,6 +421,24 @@ export class Profile extends EntityBase {
|
|||
})
|
||||
statusCheckEdit: string;
|
||||
|
||||
@Column({
|
||||
comment: "สถานะยืนยัน privacyCheckin",
|
||||
default: false,
|
||||
})
|
||||
privacyCheckin: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "สถานะยืนยัน privacyUser",
|
||||
default: false,
|
||||
})
|
||||
privacyUser: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "สถานะยืนยัน privacyMgt",
|
||||
default: false,
|
||||
})
|
||||
privacyMgt: boolean;
|
||||
|
||||
@OneToMany(() => PosMaster, (posMaster) => posMaster.current_holder)
|
||||
current_holders: PosMaster[];
|
||||
|
||||
|
|
@ -957,3 +975,8 @@ export type UpdateProfileAddress = {
|
|||
currentSubDistrictId?: string | null;
|
||||
currentZipCode?: string | null;
|
||||
};
|
||||
|
||||
export class UpdatePrivacyDto {
|
||||
system: string;
|
||||
accept: boolean;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -688,6 +688,24 @@ export class ProfileEmployee extends EntityBase {
|
|||
})
|
||||
statusCheckEdit: string;
|
||||
|
||||
@Column({
|
||||
comment: "สถานะยืนยัน privacyCheckin",
|
||||
default: false,
|
||||
})
|
||||
privacyCheckin: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "สถานะยืนยัน privacyUser",
|
||||
default: false,
|
||||
})
|
||||
privacyUser: boolean;
|
||||
|
||||
@Column({
|
||||
comment: "สถานะยืนยัน privacyMgt",
|
||||
default: false,
|
||||
})
|
||||
privacyMgt: boolean;
|
||||
|
||||
@OneToMany(() => ProfileEmployeeInformationHistory, (v) => v.profileEmployeeInformation)
|
||||
information_histories: ProfileEmployeeInformationHistory[];
|
||||
|
||||
|
|
|
|||
37
src/migration/1768555527430-add_fields_privacy.ts
Normal file
37
src/migration/1768555527430-add_fields_privacy.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddFieldsPrivacy1768555527430 implements MigrationInterface {
|
||||
name = 'AddFieldsPrivacy1768555527430'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`privacyCheckin\` tinyint NOT NULL COMMENT 'สถานะยืนยัน privacyCheckin' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`privacyUser\` tinyint NOT NULL COMMENT 'สถานะยืนยัน privacyUser' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`privacyMgt\` tinyint NOT NULL COMMENT 'สถานะยืนยัน privacyMgt' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`privacyCheckin\` tinyint NOT NULL COMMENT 'สถานะยืนยัน privacyCheckin' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`privacyUser\` tinyint NOT NULL COMMENT 'สถานะยืนยัน privacyUser' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`privacyMgt\` tinyint NOT NULL COMMENT 'สถานะยืนยัน privacyMgt' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`privacyCheckin\` tinyint NOT NULL COMMENT 'สถานะยืนยัน privacyCheckin' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`privacyUser\` tinyint NOT NULL COMMENT 'สถานะยืนยัน privacyUser' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`privacyMgt\` tinyint NOT NULL COMMENT 'สถานะยืนยัน privacyMgt' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`privacyCheckin\` tinyint NOT NULL COMMENT 'สถานะยืนยัน privacyCheckin' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`privacyUser\` tinyint NOT NULL COMMENT 'สถานะยืนยัน privacyUser' DEFAULT 0`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`privacyMgt\` tinyint NOT NULL COMMENT 'สถานะยืนยัน privacyMgt' DEFAULT 0`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
|
||||
await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`privacyMgt\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`privacyUser\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`privacyCheckin\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`privacyMgt\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`privacyUser\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`privacyCheckin\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`privacyMgt\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`privacyUser\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`privacyCheckin\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`privacyMgt\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`privacyUser\``);
|
||||
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`privacyCheckin\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue