Skip to content

[DPMBE-60] 이미지 업로드 성공을 요청받고 Picture Enevt를 생성한다 #70

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

Merged
merged 7 commits into from
Jun 7, 2023

Conversation

kdomo
Copy link
Member

@kdomo kdomo commented Jun 6, 2023

개요

작업사항

  • 프리사인 url을 통해 이미지 업로드 후 이미지를 성공적으로 올렸을 때 요청을 받기위한 api를 만들었습니당.
  • 추 후 이미지 생성 이벤트 발행 시 참여자들에게 FCM 푸시 알림을 보내주는 비지니스 로직에 따라 미리 이벤트 발행 해두었슴니다

변경로직

  • Picture 테이블의 uri컬럼을 url로 변경하였습니다.

@kdomo kdomo added the function 특정 기능 추가 label Jun 6, 2023
@kdomo kdomo self-assigned this Jun 6, 2023
@kdomo kdomo requested review from ImNM and BlackBean99 as code owners June 6, 2023 08:05
Comment on lines 13 to 14
val imageUrl = IMAGE_DOMAIN + "promise/$promiseId/$imageKey"
val picture = Picture(userId, promiseId, imageUrl, imageKey)
Copy link
Member Author

Choose a reason for hiding this comment

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

imageUrl을 생성해서 엔티티에 저장하고있는데, 로컬이나 dev환경에서는 이미지를 확인할 수 없는 문제가있는데 괜찮을까요?
나중에 조회쪽 로직에서 링크를 만들어서 주는게 더 좋을까용

Copy link
Member

@ImNM ImNM left a comment

Choose a reason for hiding this comment

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

구웃

Comment on lines 10 to 17
val pictureRepository: PictureRepository,
) {
fun save(userId: Long, promiseId: Long, imageKey: String) {
val imageUrl = IMAGE_DOMAIN + "promise/$promiseId/$imageKey"
val picture = Picture(userId, promiseId, imageUrl, imageKey)
pictureRepository.save(picture)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

        val imageUrl = IMAGE_DOMAIN + "promise/$promiseId/$imageKey"
        val picture = Picture(userId, promiseId, imageUrl, imageKey)

요단계는 도메인 서비스로 빠지는게 좋을것 같아요!

Copy link
Member Author

Choose a reason for hiding this comment

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

네넴 서비스에 있는게 맞겠네용

Comment on lines +29 to +34
) : BaseTimeEntity() {
@PostPersist
fun createPictureEvent() {
Events.raise(PictureRegisterEvent(userId, promiseId))
}
}
Copy link
Member

Choose a reason for hiding this comment

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

요거근데 이벤트에 id 값도 넣어져서 잘가나유?
picture id 를 안보내서 괜찮은건감

아밑에 리스너 달아놓으셨구나

Copy link
Member Author

Choose a reason for hiding this comment

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

도메인 이벤트 발행되었는지 테스트 코드도 추가해놓을게용

import org.springframework.transaction.event.TransactionPhase
import org.springframework.transaction.event.TransactionalEventListener

@Component
Copy link
Member

Choose a reason for hiding this comment

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

Handler 어노테이션 만들어놓긴했는데
제 지금 피알 이후나중에 함 바꿔주셔유

Comment on lines +20 to +24
@Operation(summary = "약속 관련 이미지 업로드 성공 요청")
@PostMapping("/promises/{promiseId}/images/success/{imageKey}")
fun successUploadImage(@PathVariable promiseId: Long, @PathVariable imageKey: String) {
successUseCase.successUploadImage(promiseId, imageKey)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

이미지 업로드 실패했을 경우는 따로 핸들링 안해도 되나요?

Copy link
Member Author

Choose a reason for hiding this comment

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

이미지 업로드 작업을 클라이언트쪽에서 하기때문에 (presignedurl을 통해)
따로 핸들링 할 필요는 없슴니닷!

ex) 클라이언트가 presignedUrl을 통해 이미지 업로드 과정에서 실패 -> Url 재발급 하여 다시 업로드 또는 에러처리

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

78.4% 78.4% Coverage
0.0% 0.0% Duplication

@kdomo kdomo merged commit bc1d77f into develop Jun 7, 2023
@kdomo kdomo deleted the feature/DPMBE-60 branch June 7, 2023 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
function 특정 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DPMBE-60] 이미지 업로드 성공을 요청받고 Picture Enevt를 생성한다
3 participants