Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-05-15 15:31:51 +07:00
commit 0df3191fcc
10 changed files with 126 additions and 37 deletions

View file

@ -42,13 +42,16 @@ export class ProfileAvatarController extends Controller {
Object.assign(data, { ...body, ...meta });
await this.avatarRepository.save(data);
let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}/profile-${data.id}`;
let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`;
let fileName = `profile-${data.id}`;
data.avatar = avatar;
data.avatarName = fileName;
await this.avatarRepository.save(data);
profile.avatar = avatar;
profile.avatarName = fileName;
await this.profileRepository.save(profile);
return new HttpSuccess(avatar);
return new HttpSuccess({ avatar: avatar, avatarName: fileName });
}
@Delete("{avatarId}")

View file

@ -36,6 +36,13 @@ export class Profile extends EntityBase {
})
avatar: string;
@Column({
nullable: true,
comment: "รูปถ่าย",
default: null,
})
avatarName: string;
@Column({
nullable: true,
comment: "ยศ",

View file

@ -12,6 +12,13 @@ export class ProfileAvatar extends EntityBase {
})
avatar: string;
@Column({
nullable: true,
comment: "รูปถ่าย",
default: null,
})
avatarName: string;
@Column({
nullable: true,
length: 40,

View file

@ -90,11 +90,8 @@ export class ProfileFamilyCouple extends EntityBase {
})
profileEmployeeId: string;
@OneToMany(
() => ProfileFamilyCoupleHistory,
(v) => v.histories,
)
profileFamilyCouple: ProfileFamilyCoupleHistory[];
@OneToMany(() => ProfileFamilyCoupleHistory, (v) => v.profileFamilyCouple)
histories: ProfileFamilyCoupleHistory[];
@ManyToOne(() => Profile, (v) => v.profileFamilyCouple)
@JoinColumn({ name: "profileId" })

View file

@ -7,54 +7,78 @@ export class ProfileFamilyCoupleHistory extends EntityBase {
@Column({
nullable: true,
default: null,
comment: "คำนำหน้าบิดา",
type: "boolean",
})
fatherPrefix: string;
couple: boolean;
@Column({
nullable: true,
default: null,
comment: "ชื่อบิดา",
comment: "คำนำหน้าคู่สมรส",
})
fatherFirstName: string;
couplePrefix: string;
@Column({
nullable: true,
default: null,
comment: "นามสกุลบิดา",
comment: "ชื่อคู่สมรส",
})
fatherLastName: string;
coupleFirstName: string;
@Column({
nullable: true,
default: null,
comment: "อาชีพบิดา",
comment: "นามสกุลคู่สมรส",
})
fatherCareer: string;
coupleLastName: string;
@Column({
nullable: true,
default: null,
comment: "เลขที่บัตรประชาชนบิดา",
comment: "นามสกุลคู่สมรส(เดิม)",
})
fatherCitizenId: string;
coupleLastNameOld: string;
@Column({
nullable: true,
default: null,
comment: "มีชีวิตบิดา",
comment: "อาชีพคู่สมรส",
})
fatherLive: boolean;
coupleCareer: string;
@Column({
nullable: true,
default: null,
length: 13,
comment: "เลขที่บัตรประชาชนคู่สมรส",
})
coupleCitizenId: string;
@Column({
nullable: true,
default: null,
type: "boolean",
comment: "มีชีวิตคู่สมรส",
})
coupleLive: boolean;
@Column({
nullable: true,
comment: "ความสัมพันธ์",
length: 40,
default: null,
})
relationship: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง ProfileFamilyFather",
comment: "คีย์นอก(FK)ของตาราง ProfileFamilyCouple",
default: null,
})
profileFamilyCoupleId: string;
@ManyToOne(() => ProfileFamilyCouple, (v) => v.profileFamilyCouple)
@ManyToOne(() => ProfileFamilyCouple, (v) => v.histories)
@JoinColumn({ name: "profileFamilyCoupleId" })
histories: ProfileFamilyCouple;
profileFamilyCouple: ProfileFamilyCouple;
}

View file

@ -66,11 +66,8 @@ export class ProfileFamilyFather extends EntityBase {
})
profileEmployeeId: string;
@OneToMany(
() => ProfileFamilyFatherHistory,
(v) => v.histories,
)
profileFamilyFather: ProfileFamilyFatherHistory[];
@OneToMany(() => ProfileFamilyFatherHistory, (v) => v.profileFamilyFather)
histories: ProfileFamilyFatherHistory[];
@ManyToOne(() => Profile, (v) => v.profileFamilyFather)
@JoinColumn({ name: "profileId" })

View file

@ -54,7 +54,7 @@ export class ProfileFamilyFatherHistory extends EntityBase {
})
profileFamilyFatherId: string;
@ManyToOne(() => ProfileFamilyFather, (v) => v.profileFamilyFather)
@ManyToOne(() => ProfileFamilyFather, (v) => v.histories)
@JoinColumn({ name: "profileFamilyFatherId" })
histories: ProfileFamilyFather;
profileFamilyFather: ProfileFamilyFather;
}

View file

@ -66,11 +66,8 @@ export class ProfileFamilyMother extends EntityBase {
})
profileEmployeeId: string;
@OneToMany(
() => ProfileFamilyMotherHistory,
(v) => v.histories,
)
profileFamilyMother: ProfileFamilyMotherHistory[];
@OneToMany(() => ProfileFamilyMotherHistory, (v) => v.profileFamilyMother)
histories: ProfileFamilyMotherHistory[];
@ManyToOne(() => Profile, (v) => v.profileFamilyMother)
@JoinColumn({ name: "profileId" })

View file

@ -4,7 +4,6 @@ import { ProfileFamilyMother } from "./ProfileFamilyMother";
@Entity("profileFamilyMotherHistory")
export class ProfileFamilyMotherHistory extends EntityBase {
@Column({
nullable: true,
default: null,
@ -55,7 +54,7 @@ export class ProfileFamilyMotherHistory extends EntityBase {
})
profileFamilyMotherId: string;
@ManyToOne(() => ProfileFamilyMother, (v) => v.profileFamilyMother)
@ManyToOne(() => ProfileFamilyMother, (v) => v.histories)
@JoinColumn({ name: "profileFamilyMotherId" })
histories: ProfileFamilyMother;
profileFamilyMother: ProfileFamilyMother;
}

View file

@ -0,0 +1,58 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableAvatarName1715760265657 implements MigrationInterface {
name = 'AddTableAvatarName1715760265657'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`fatherCareer\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`fatherCitizenId\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`fatherFirstName\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`fatherLastName\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`fatherLive\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`fatherPrefix\``);
await queryRunner.query(`ALTER TABLE \`profileAvatar\` ADD \`avatarName\` varchar(255) NULL COMMENT 'รูปถ่าย'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`couple\` tinyint NULL`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`couplePrefix\` varchar(255) NULL COMMENT 'คำนำหน้าคู่สมรส'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`coupleFirstName\` varchar(255) NULL COMMENT 'ชื่อคู่สมรส'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`coupleLastName\` varchar(255) NULL COMMENT 'นามสกุลคู่สมรส'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`coupleLastNameOld\` varchar(255) NULL COMMENT 'นามสกุลคู่สมรส(เดิม)'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`coupleCareer\` varchar(255) NULL COMMENT 'อาชีพคู่สมรส'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`coupleCitizenId\` varchar(13) NULL COMMENT 'เลขที่บัตรประชาชนคู่สมรส'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`coupleLive\` tinyint NULL COMMENT 'มีชีวิตคู่สมรส'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`relationship\` varchar(40) NULL COMMENT 'ความสัมพันธ์'`);
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`avatarName\` varchar(255) NULL COMMENT 'รูปถ่าย'`);
await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`avatarName\` varchar(255) NULL COMMENT 'รูปถ่าย'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP FOREIGN KEY \`FK_849255f4788774b559b7dca8eda\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` CHANGE \`profileFamilyCoupleId\` \`profileFamilyCoupleId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileFamilyCouple'`);
await queryRunner.query(`ALTER TABLE \`profile\` CHANGE \`dateRetire\` \`dateRetire\` datetime NULL COMMENT 'วันครบเกษียณอายุ'`);
await queryRunner.query(`ALTER TABLE \`profileHistory\` CHANGE \`dateRetire\` \`dateRetire\` datetime NULL COMMENT 'วันครบเกษียณอายุ'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD CONSTRAINT \`FK_849255f4788774b559b7dca8eda\` FOREIGN KEY (\`profileFamilyCoupleId\`) REFERENCES \`profileFamilyCouple\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP FOREIGN KEY \`FK_849255f4788774b559b7dca8eda\``);
await queryRunner.query(`ALTER TABLE \`profileHistory\` CHANGE \`dateRetire\` \`dateRetire\` datetime NULL COMMENT 'วันที่พักราชการ'`);
await queryRunner.query(`ALTER TABLE \`profile\` CHANGE \`dateRetire\` \`dateRetire\` datetime NULL COMMENT 'วันที่พักราชการ'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` CHANGE \`profileFamilyCoupleId\` \`profileFamilyCoupleId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileFamilyFather'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD CONSTRAINT \`FK_849255f4788774b559b7dca8eda\` FOREIGN KEY (\`profileFamilyCoupleId\`) REFERENCES \`profileFamilyCouple\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`avatarName\``);
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`avatarName\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`relationship\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`coupleLive\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`coupleCitizenId\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`coupleCareer\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`coupleLastNameOld\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`coupleLastName\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`coupleFirstName\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`couplePrefix\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` DROP COLUMN \`couple\``);
await queryRunner.query(`ALTER TABLE \`profileAvatar\` DROP COLUMN \`avatarName\``);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`fatherPrefix\` varchar(255) NULL COMMENT 'คำนำหน้าบิดา'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`fatherLive\` tinyint NULL COMMENT 'มีชีวิตบิดา'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`fatherLastName\` varchar(255) NULL COMMENT 'นามสกุลบิดา'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`fatherFirstName\` varchar(255) NULL COMMENT 'ชื่อบิดา'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`fatherCitizenId\` varchar(255) NULL COMMENT 'เลขที่บัตรประชาชนบิดา'`);
await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` ADD \`fatherCareer\` varchar(255) NULL COMMENT 'อาชีพบิดา'`);
}
}