Skip to content

Commit

Permalink
feat: 동영상 수정 시 썸네일 수정 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
SJ70 committed Aug 14, 2024
1 parent ee9c214 commit 20e128d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public ResponseEntity<VideoFindDto> findById(@PathVariable UUID videoId) {
}

@Operation(summary = "내 동영상 정보 수정")
@PatchMapping("/{videoId}")
public ResponseEntity<VideoFindDto> update(@PathVariable UUID videoId, @RequestBody @Valid VideoUpdateDto updateDto) {
@PatchMapping(path = "/{videoId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<VideoFindDto> update(@PathVariable UUID videoId, @ModelAttribute @Valid VideoUpdateDto updateDto) {
UUID memberId = UUID.fromString(SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString());
Video video = videoService.findByIdAndUploaderId(videoId, memberId);
videoService.update(video, updateDto);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/j9/bestmoments/service/VideoService.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public Video findPublicById(UUID id) {

@Transactional
public Video update(Video video, VideoUpdateDto updateDto) {
if (updateDto.thumbnail() != null) {
String thumbnailName = FileNameGenerator.generateThumbnailImageFileName(video);
String thumbnailUrl = storageService.uploadFile(updateDto.thumbnail(), thumbnailName);
video.setThumbnailUrl(thumbnailUrl);
}
video.setTitle(updateDto.title());
video.setDescription(updateDto.description());
video.setVideoStatus(updateDto.videoStatus());
Expand Down

0 comments on commit 20e128d

Please sign in to comment.