fix null details

This commit is contained in:
AdisakKanthawilang 2024-02-22 13:53:58 +07:00
parent cfe3033faa
commit e2168292ea
2 changed files with 7 additions and 4 deletions

View file

@ -18,7 +18,7 @@ import { Salarys, CreateSalary, UpdateSalary } from "../entities/Salarys";
import { PosType } from "../entities/PosType";
import { PosLevel } from "../entities/PosLevel";
import { AppDataSource } from "../database/data-source";
import { In, IsNull, Not } from "typeorm";
import { DeepPartial, In, IsNull, Not } from "typeorm";
import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error";
import HttpStatusCode from "../interfaces/http-status";
@ -178,11 +178,14 @@ export class Salary extends Controller {
if (!chk_posLevelId) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ระดับของตำแหน่ง ไม่ถูกต้อง");
}
const mergeData: DeepPartial<Salarys> = {
...requestBody,
details: requestBody.details === null ? undefined : requestBody.details,
};
chk_Salary.lastUpdateUserId = request.user.sub;
chk_Salary.lastUpdateFullName = request.user.name;
chk_Salary.lastUpdatedAt = new Date();
this.salaryRepository.merge(chk_Salary, requestBody);
this.salaryRepository.merge(chk_Salary, mergeData);
await this.salaryRepository.save(chk_Salary);
return new HttpSuccess(id);
// } catch (error: any) {

View file

@ -133,7 +133,7 @@ export class UpdateSalary {
endDate?: Date;
@Column()
details?: string;
details?: string | null;
@Column()
isSpecial: boolean;