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 }); Object.assign(data, { ...body, ...meta });
await this.avatarRepository.save(data); 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.avatar = avatar;
data.avatarName = fileName;
await this.avatarRepository.save(data); await this.avatarRepository.save(data);
profile.avatar = avatar; profile.avatar = avatar;
profile.avatarName = fileName;
await this.profileRepository.save(profile); await this.profileRepository.save(profile);
return new HttpSuccess(avatar); return new HttpSuccess({ avatar: avatar, avatarName: fileName });
} }
@Delete("{avatarId}") @Delete("{avatarId}")

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,7 +4,6 @@ import { ProfileFamilyMother } from "./ProfileFamilyMother";
@Entity("profileFamilyMotherHistory") @Entity("profileFamilyMotherHistory")
export class ProfileFamilyMotherHistory extends EntityBase { export class ProfileFamilyMotherHistory extends EntityBase {
@Column({ @Column({
nullable: true, nullable: true,
default: null, default: null,
@ -55,7 +54,7 @@ export class ProfileFamilyMotherHistory extends EntityBase {
}) })
profileFamilyMotherId: string; profileFamilyMotherId: string;
@ManyToOne(() => ProfileFamilyMother, (v) => v.profileFamilyMother) @ManyToOne(() => ProfileFamilyMother, (v) => v.histories)
@JoinColumn({ name: "profileFamilyMotherId" }) @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 'อาชีพบิดา'`);
}
}