Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

보호소 정보 수정 API 추가 #151

Merged
merged 9 commits into from
Oct 17, 2023
Merged

보호소 정보 수정 API 추가 #151

merged 9 commits into from
Oct 17, 2023

Conversation

jminkkk
Copy link
Contributor

@jminkkk jminkkk commented Oct 17, 2023

작업 내용

  • 보호소 정보 수정 API를 구현하였습니다.
  • 서비스단 테스트 코드를 작성하였습니다.

기타

  • 수정 요청 시 기존 보호소 정보 전체를 덮어 씁니다.

Close #143

@github-actions
Copy link

Overall Project 70.69% -0.88% 🍏
Files changed 79.25% 🍏

File Coverage
Shelter.java 88.89% 🍏
ShelterUpdateDto.java 84.62% -15.38% 🍏
ShelterService.java 83.33% -8.33% 🍏
ShelterAddressUpdateDto.java 81.01% -18.99% 🍏
ShelterUpdateSuccessDto.java 76.92% -23.08% 🍏
ShelterController.java 73.08% -26.92%

Copy link
Contributor

@xGreenNarae xGreenNarae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 정도로 해두고 UI/UX 설계가 나오면 맞춰서 바꿔가면 되겠네요 👍

@@ -23,6 +25,12 @@ public Response<ShelterProfilePage> getShelter(@PathVariable @Min(0) final Integ
return Response.success(shelterService.getShelterProfile(shelterId, page));
}

@PutMapping("/{shelterId}")
public Response<ShelterUpdateSuccessDto> updateShelter(@PathVariable @Min(0) final Integer shelterId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정 권한을 검사하는 부분이 빠진 것 같아요.

이런곳에서 실수가 발생하지 않게 URL Prefix 기반으로 한 곳에서 관리할 수 있는 기능을 추가해봐도 괜찮다는 생각 중인데,, 아니면 익숙한 Spring Security로 교체해도 좋을 것 같구요.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헉 그러네요 수정하겠습니다...!

Shelter shelter = shelterRepository.findById(shelterId).orElseThrow(
() -> new NotFound404("해당하는 보호소가 존재하지 않습니다.")
);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

마찬가지로 Service 로직 어딘가에서 요청한 계정이 Dto에 담긴 Shelter Id에 대한 수정권한이 있는지 확인해줄 필요가 있을 듯 ? ?


assertThat(shelterUpdateSuccessDto.getShelterId()).isEqualTo(shelter.getId());
assertThat(shelter.getName()).isEqualTo(shelterUpdateDto.name());
assertThat(shelter.getAddress().getCity()).isEqualTo(shelterUpdateDto.shelterAddressUpdateDto().city());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다른 이유가 있었던게 아니라면, assertAll 사용할만한 부분인듯요 !

@github-actions
Copy link

Overall Project 70.83% -0.9% 🍏
Files changed 80% 🍏

File Coverage
Shelter.java 88.89% 🍏
ShelterService.java 86.11% -6.94% 🍏
ShelterUpdateDto.java 84.62% -15.38% 🍏
ShelterAddressUpdateDto.java 81.01% -18.99% 🍏
ShelterUpdateSuccessDto.java 76.92% -23.08% 🍏
ShelterController.java 70.37% -29.63%

Shelter shelter = shelterRepository.findById(shelterId).orElseThrow(
() -> new NotFound404("해당하는 보호소가 존재하지 않습니다.")
);

if (!shelter.getAccount().getEmail().equals(account.getEmail())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞는데.. 여기서는 ID(PK)가 아닌 Email로 비교를 하셨네요 ??
아무 문제 없지만, Email은 아무튼 Entity간에 연결지점이자 식별자가 아니라 필드일뿐이니까,,

나중에 무슨무슨 이유로 Email이 변경될 수 있게하자! 라고 기능이 바뀐다면, 이 코드를 찾아와야 하지 않을까 라는 생각들을 해본건데..
그럴일은 없다고 생각하는 걸로도 충분하다고 생각합니다 ㅎ.ㅎ 🤡

@github-actions
Copy link

Test Coverage Report

Overall Project 70.96% -0.9% 😍
Files changed 80% 😍

File Coverage
Shelter.java 88.89% 😍
ShelterService.java 86.11% -6.94% 😍
ShelterUpdateDto.java 84.62% -15.38% 😍
ShelterAddressUpdateDto.java 81.01% -18.99% 😍
ShelterUpdateSuccessDto.java 76.92% -23.08% 😍
ShelterController.java 70.37% -29.63% 😞

@jminkkk jminkkk merged commit a9b8c31 into develop Oct 17, 2023
2 checks passed
@jminkkk jminkkk deleted the feat/#143 branch October 17, 2023 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BE] Shelter 정보 수정 API 추가
2 participants