From 56382c97b29c18bd30aaa2782908e005aa8cbb52 Mon Sep 17 00:00:00 2001 From: gray Date: Mon, 1 Aug 2022 14:39:13 +0800 Subject: [PATCH] fix attendance update issues --- src/controllers/attendance.controller.ts | 8 ++++---- src/dtos/dingTlak/attendance.ts | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/controllers/attendance.controller.ts b/src/controllers/attendance.controller.ts index b1c9e4c..faccc76 100644 --- a/src/controllers/attendance.controller.ts +++ b/src/controllers/attendance.controller.ts @@ -51,16 +51,16 @@ export class AttendanceController { @Put('/update/custom') async updateCustomAttendance(@Body() updateDto: IAttendanceCustomUpdateDto) { - const date = moment().format('YYYY-MM'); - const { userId, index, datas } = updateDto; - let attendances = await FileData.readCustomAttendances(date); + const { userId, index, datas, date } = updateDto; + const _date = moment(date).format('YYYY-MM'); + let attendances = await FileData.readCustomAttendances(_date); attendances = attendances.map((x: IUserAttendances) => { if (x.id === userId) { x.attendances[index] = datas; } return x; }); - const result = await FileData.writeCustomAttendances(date, attendances); + const result = await FileData.writeCustomAttendances(_date, attendances); return result; } } diff --git a/src/dtos/dingTlak/attendance.ts b/src/dtos/dingTlak/attendance.ts index 2958260..f193c74 100644 --- a/src/dtos/dingTlak/attendance.ts +++ b/src/dtos/dingTlak/attendance.ts @@ -8,4 +8,5 @@ export interface IAttendanceCustomUpdateDto { userId: string; index: number; datas: any[]; + date: string; }