เพิ่มวันที่แก้ไข

This commit is contained in:
kittapath 2024-08-30 21:02:14 +07:00
parent 218886b3f4
commit ad4efc2b47
28 changed files with 205 additions and 40 deletions

View file

@ -80,6 +80,8 @@ export class EmployeePosLevelController extends Controller {
EmpPosLevel.createdFullName = request.user.name;
EmpPosLevel.lastUpdateUserId = request.user.sub;
EmpPosLevel.lastUpdateFullName = request.user.name;
EmpPosLevel.createdAt = new Date();
EmpPosLevel.lastUpdatedAt = new Date();
await this.employeePosLevelRepository.save(EmpPosLevel);
return new HttpSuccess(EmpPosLevel.id);
}
@ -125,6 +127,7 @@ export class EmployeePosLevelController extends Controller {
}
EmpPosLevel.lastUpdateUserId = request.user.sub;
EmpPosLevel.lastUpdateFullName = request.user.name;
EmpPosLevel.lastUpdatedAt = new Date();
this.employeePosLevelRepository.merge(EmpPosLevel, requestBody);
await this.employeePosLevelRepository.save(EmpPosLevel);
return new HttpSuccess(EmpPosLevel.id);
@ -139,11 +142,14 @@ export class EmployeePosLevelController extends Controller {
*/
@Delete("{id}")
async deleteType(@Path() id: string) {
let result :any
let result: any;
try {
result = await this.employeePosLevelRepository.delete({ id: id });
} catch {
throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับชั้นงานนี้อยู่");
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับชั้นงานนี้อยู่",
);
}
if (result.affected == undefined || result.affected <= 0) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");