Step3-kakao-tech-campus / Team3_BE

[카테캠 1기] 번개 지향 볼링 모집 커뮤니티 "번개볼링"의 백엔드 서버입니다.
2 stars 4 forks source link

ApplicantResponse.GetApplicantsDto 수정 #21

Closed jagaldol closed 1 year ago

jagaldol commented 1 year ago

Description

점검하며 발견했는데 Dto 양식이 틀려있습니다.

API 명세서의 response 형태

{
    "status": 200,
    "response": {
        "nextCursorRequest": {
      "key": 1,
      "size": 20
    },
        "participantNumber": 4,
        "currentNumber": 1,
        "applicants": [
            {
                "id": 1,
                "user": {
                    "userId": "2",
                    "userName": "볼링조아",
                    "profileImage": "",
                    "createdAt": "2023-09-05 10:49",
                    "status": false
                }
            },
            {
                "id": 2,
                "user": {
                    "userId": "3",
                    "userName": "스페어처리반",
                    "profileImage": "",
                    "createdAt": "2023-09-05 10:50",
                    "status": false
                }
            },
            {
                "id": 3,
                "user": {
                    "userId": "4",
                    "userName": "가터처리반",
                    "profileImage": "",
                    "createdAt": "2023-09-05 10:52",
                    "status": false
                }
            },
            {
                "id": 4,
                "user": {
                    "userId": "7",
                    "userName": "스페어치고싶엉",
                    "profileImage": "",
                    "createdAt": "2023-09-05 11:00",
                    "status": false
                }
            }
        ]
    },
    "errorMessage": null
}

실제 구현되어 있는 API의 response 형태

{
    "status": 200,
    "response": {
        "nextCursorRequest": {
            "key": 1,
            "size": 20
        },
        "applicantNumber": 0,
        "applicants": [
            {
                "id": 1,
                "userName": "김볼링",
                "profileImage": null,
                "rating": 1.0
            }
        ]
    },
    "errorMessage": null
}

대체 뭘 보고 만들어서 이렇게 돼있는지는 모르겠는데, 일단 구현된 응답형태로 바꿀 수가 없는 이유가 하나 존재합니다.

이 외에 생성 시간은 기획 단계에서 필요없게 변경되어 createdAt은 안넘겨도 무방할 거 같습니다.

applicantsNumber도 이상합니다.

@Query("SELECT count(a) FROM Applicant a WHERE a.post.id = :postId AND a.status = true")
int countByPostId(@Param("postId") Long postId);

코드 확인하니까 이렇게 되어 있는데 applicantsNumber의 경우 명세서에 신청자 수로 되어있지만, 실제로는 수락된 수를 전달하고 있습니다.

최종 요구되는 API response 형태

{
  "status": 200,
  "response": {
    "nextCursorRequest": {
      "key": 1,
      "size": 20
    },
    "participantNumber": 4,
    "currentNumber": 1,
    "applicants": [
      {
        "id": 1,
        "user": {
          "id": "2",
          "name": "볼링조아",
          "profileImage": ""
        },
        "status": false
      },
      {
        "id": 2,
        "user": {
          "id": "3",
          "name": "스페어처리반",
          "profileImage": ""
        },
        "status": false
      },
      {
        "id": 3,
        "user": {
          "id": "4",
          "name": "가터처리반",
          "profileImage": ""
        },
        "status": false
      },
      {
        "id": 4,
        "user": {
          "id": "7",
          "name": "스페어치고싶엉",
          "profileImage": ""
        },
        "status": false
      }
    ]
  },
  "errorMessage": null
}

이렇게 명세서에는 수정해놨고 코드 작업하여 수정해야합니다.

api 만들때 명세서 잘 확인해서, 명세서대로 정확하게 만들어주세요

References