Skip to content

구현 : timelog

whoamixzerone edited this page Jul 29, 2022 · 4 revisions

timelog에 대한 상세 구현 문서입니다.

기능 목록

  1. 출근시간 등록
  2. 퇴근시간 등록
  3. 출퇴근시간 조회





출근시간 등록

URL

POST http://localhost:3000/api/timelog

Response

{
    "status": 200,
    "isSuccess": true,
    "message": "성공",
    "data" : {"id" : 1, "fromWork" : "2022-07-28T08:55:11.000Z"}
}

Validation Check

  • fromWork : 현재시간보다 이전시간 등록 불가능





퇴근시간 등록

URL

PATCH http://localhost:3000/api/timelog/1

Response

{
    "status": 200,
    "isSuccess": true,
    "message": "성공",
    "data" : {"id" : 1, "fromWork" : "2022-07-28T08:55:11.000Z", "toWork" : "2022-07-28T18:05:11.000Z", "workTime" : 9}
}

Validation Check

  • toWork: 현재시간보다 이전시간 등록 불가능




출퇴근시간 조회

URL

GET /api/timelog?period=daily
GET /api/timelog?period=weekly
GET /api/timelog?period=montly

Response

[daily]

{
    "status": 200,
    "isSuccess": true,
    "message": "성공",
    "data" : {"id" : 1, "fromWork" : "2022-07-28T08:40:59.0000Z", "toWork" : "2022-07-28T18:00:59.0000Z", "workTime" : 9}
}

[weekly]

{
    "status": 200,
    "isSuccess": true,
    "message": "성공",
    "data" : [{
        "id": 32,
        "fromWork": "2022-07-28T09:00:00.000Z",
        "toWork": "2022-07-28T18:05:53.000Z",
        "workTime": 9
    },
    {
        "id": 36,
        "fromWork": "2022-07-27T08:58:23.000Z",
        "toWork": "2022-07-27T18:01:23.000Z",
        "workTime": 9
    }
    ...
    ]
}

[montly]

{
    "status": 200,
    "isSuccess": true,
    "message": "성공",
    "data" : [{
        "id": 32,
        "fromWork": "2022-07-28T09:00:00.000Z",
        "toWork": "2022-07-28T18:05:53.000Z",
        "workTime": 9
    },
    {
        "id": 36,
        "fromWork": "2022-07-27T08:58:23.000Z",
        "toWork": "2022-07-27T18:01:23.000Z",
        "workTime": 9
    }
    ...
    ]
}

Validation Check

  • workTime: 달의 첫번째 일부터 마지막 일까지 계산해주는 로직