แก้ไขวันที่เกษียณ

This commit is contained in:
Kittapath 2024-06-06 18:04:11 +07:00
parent 87550b158b
commit 613dd34ad7
3 changed files with 52 additions and 3 deletions

View file

@ -3009,4 +3009,29 @@ export class ProfileController extends Controller {
}); });
return new HttpSuccess(formattedData); return new HttpSuccess(formattedData);
} }
/**
* API
*
* @summary (ADMIN)
*
* @param {string} id Id
*/
@Put("salary/{id}")
async updateLeaveUser(
@Path() id: string,
@Body()
requestBody: { isLeave: boolean; leaveReason: string; dateLeave: Date },
) {
const profile = await this.profileRepo.findOne({
where: { id: id },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
profile.isLeave = requestBody.isLeave;
profile.leaveReason = requestBody.leaveReason;
profile.dateLeave = requestBody.dateLeave;
await this.profileRepo.save(profile);
return new HttpSuccess();
}
} }

View file

@ -166,6 +166,14 @@ export class Profile extends EntityBase {
}) })
leaveReason: string; leaveReason: string;
@Column({
nullable: true,
type: "datetime",
comment: "วันพ้นราชการ",
default: null,
})
dateLeave: Date;
@Column({ @Column({
nullable: true, nullable: true,
type: "datetime", type: "datetime",
@ -466,15 +474,15 @@ export class Profile extends EntityBase {
@Column({ @Column({
nullable: true, nullable: true,
length: 40, length: 40,
comment: "ไอดีรอบลงเวลาล่าสุด" comment: "ไอดีรอบลงเวลาล่าสุด",
}) })
dutyTimeId : string; dutyTimeId: string;
@Column({ @Column({
nullable: true, nullable: true,
type: "datetime", type: "datetime",
comment: "รอบลงเวลาล่าสุด", comment: "รอบลงเวลาล่าสุด",
default: null default: null,
}) })
dutyTimeEffectiveDate: Date; dutyTimeEffectiveDate: Date;
} }

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableProfileAddDateLeave1717671751714 implements MigrationInterface {
name = 'UpdateTableProfileAddDateLeave1717671751714'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`dateLeave\` datetime NULL COMMENT 'วันพ้นราชการ'`);
await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`dateLeave\` datetime NULL COMMENT 'วันพ้นราชการ'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`dateLeave\``);
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`dateLeave\``);
}
}