update_table_ProfileAvatar_add_isactive
This commit is contained in:
parent
9d240969a3
commit
73c91bd9b1
3 changed files with 30 additions and 0 deletions
|
|
@ -32,6 +32,7 @@ export class ProfileAvatarController extends Controller {
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||||
}
|
}
|
||||||
|
result.isActive = true;
|
||||||
profile.avatar = result.avatar;
|
profile.avatar = result.avatar;
|
||||||
profile.avatarName = result.avatarName;
|
profile.avatarName = result.avatarName;
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
@ -59,6 +60,7 @@ export class ProfileAvatarController extends Controller {
|
||||||
await this.avatarRepository.save(data);
|
await this.avatarRepository.save(data);
|
||||||
let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`;
|
let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}`;
|
||||||
let fileName = `profile-${data.id}`;
|
let fileName = `profile-${data.id}`;
|
||||||
|
data.isActive = true;
|
||||||
data.avatar = avatar;
|
data.avatar = avatar;
|
||||||
data.avatarName = fileName;
|
data.avatarName = fileName;
|
||||||
await this.avatarRepository.save(data);
|
await this.avatarRepository.save(data);
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,12 @@ export class ProfileAvatar extends EntityBase {
|
||||||
})
|
})
|
||||||
avatar: string;
|
avatar: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "สถานะการใช้งาน",
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
isActive: boolean;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "รูปถ่าย",
|
comment: "รูปถ่าย",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTableProfileAvatarAddIsactive1715828430262 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableProfileAvatarAddIsactive1715828430262'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileSalaryEmployee\` DROP COLUMN \`commandNo\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileAvatar\` ADD \`isActive\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 0`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileDiscipline\` DROP FOREIGN KEY \`FK_0031dcb981836876de8524eaff1\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`profileId\` \`profileId\` varchar(40) NULL COMMENT 'ไอดีโปรไฟล์'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileDiscipline\` ADD CONSTRAINT \`FK_0031dcb981836876de8524eaff1\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileDiscipline\` DROP FOREIGN KEY \`FK_0031dcb981836876de8524eaff1\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`profileId\` \`profileId\` varchar(40) NOT NULL COMMENT 'ไอดีโปรไฟล์'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileDiscipline\` ADD CONSTRAINT \`FK_0031dcb981836876de8524eaff1\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileAvatar\` DROP COLUMN \`isActive\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileSalaryEmployee\` ADD \`commandNo\` text NOT NULL COMMENT 'เลขที่คำสั่ง'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue