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

[FEAT] 기록하기(Album) API 구현 #135

Merged
merged 11 commits into from
Mar 1, 2024
Merged

Conversation

jun02160
Copy link
Member

📌 관련 이슈

closed #133

✨ 어떤 이유로 변경된 내용인지

Album 엔티티 설계

회의 때 논의한대로 DB 작업을 진행했고, Parentchild과의 양방향 연관관계를 가지도록 매핑했습니다.
*논의사항에서 변경된 내용은 작성자 필드명을 username이 아닌 writer로 지정한 점입니다!

API 개발

SP3에 반영된 '기록하기' 페이지에 대한 API를 개발했습니다.
-> 기록하기의 각 '사진+글'을 Album(앨범) 으로 지칭하고 명세서와 로직을 구성했습니다.

  1. 앨범 등록하기
  2. 앨범 사진 업로드를 위한 PreSigned Url 조회하기
  3. 앨범 삭제하기
  4. 앨범 목록 조회하기

위 4개의 API를 추가했고, 이미지 파일 업로드는 S3 PreSigned Url을 이용해 구현했습니다.

  • PostMan을 이용해 테스트 진행하고 모두 저장해두었으니 확인해보실 수 있습니다 :)
  • API 명세서도 추가해두었습니다!

🙏 검토 혹은 리뷰어에게 남기고 싶은 말

🧡엄빠 화이팅🧡

@jun02160 jun02160 added 🔥 Pull Request PR 날림 예준🍒 ✨Feat 새로운 기능 추가 🪄API 서버 API 통신 ☁️Database DB 관련 labels Feb 28, 2024
@jun02160 jun02160 self-assigned this Feb 28, 2024
Copy link
Member

@ddongseop ddongseop left a comment

Choose a reason for hiding this comment

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

깔끔, 편안 하네요
완전 수고하셨습니다 ~~ 🥹🥹

}

// PreSigned Url 이용 (클라이언트에서 해당 URL로 업로드)
@PatchMapping("/image")
Copy link
Member

Choose a reason for hiding this comment

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

이 부분 PATCH인것 확인후에 명세서에 반영해뒀습니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

헉 감사합니다 !!

public ApiResponse createAlbum(@Valid @RequestBody final CreateAlbumRequestDto request, final Principal principal, HttpServletResponse response) {
String imgUrl = s3Service.getS3ImgUrl(ALBUM_PREFIX.getValue(), request.getImgFileName());
Long albumId = albumService.createAlbum(request, imgUrl, getUserFromPrincial(principal));
response.setHeader("Location", "/album/" + albumId);
Copy link
Member

Choose a reason for hiding this comment

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

Q) 혹시 header를 지정함으로써 해서 얻는 효과가 무엇일까요!

Copy link
Member Author

Choose a reason for hiding this comment

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

HTTP 통신 규약에 따르면 201 Created로 응답하는 경우에 생성된 리소스의 값을 응답에 포함시키는 게 원칙이라고 하더라구요! 그래서 응답 헤더(Location)에 생성된 리소스의 식별자를 요청 url에 붙여서 반환하도록 HttpServleResponse를 인자로 받아 넣어 주었습니다!!
이 부분은 다른 API에도 추후 적용해보면 좋을 것 같네요 :)

*HTTP 201 Created에 관한 규약 아래 내용 참고해 주세요!!
https://developer.mozilla.org/ko/docs/Web/HTTP/Status/201

@jun02160 jun02160 merged commit 6887693 into develop Mar 1, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
예준🍒 🪄API 서버 API 통신 ☁️Database DB 관련 ✨Feat 새로운 기능 추가 🔥 Pull Request PR 날림
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] 기록하기 API 구현
2 participants