Skip to content

Commit

Permalink
[api-server-v1] fix: @RequestBody 정리, @transactional 어노테이션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
gdtknight committed Oct 5, 2023
1 parent a9b78a4 commit 01f0a5f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ApiResponse.Result<BlockResponseDTO> modifyVideoBlock(
@AuthenticationPrincipal CustomUserDetails loginUser,
@PathVariable UUID pageId,
@PathVariable UUID blockId,
@RequestBody VideoBlockDTO videoBlockRequestDTO) {
VideoBlockDTO videoBlockRequestDTO) {

log.info("[TextBlockController] Login User : {}", loginUser);
log.info("[TextBlockController] Current Page Id : {}", pageId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
Expand All @@ -23,6 +24,7 @@ public class VideoBlockService {
private final SharePageRepository sharePageRepository;
private final S3StorageService s3StorageService;

@Transactional
public BlockResponseDTO createVideoBlock(UUID pageId, VideoBlockDTO videoBlockDTO) {

SharePage parentPage =
Expand All @@ -44,6 +46,7 @@ public BlockResponseDTO createVideoBlock(UUID pageId, VideoBlockDTO videoBlockDT
return BlockResponseDTO.fromEntity(videoBlock);
}

@Transactional
public BlockResponseDTO modifyVideoBlock(UUID blockId, VideoBlockDTO videoBlockDTO) {
VideoBlock videoBlock =
videoBlockRepository
Expand All @@ -54,6 +57,11 @@ public BlockResponseDTO modifyVideoBlock(UUID blockId, VideoBlockDTO videoBlockD

if (videoBlockDTO.description() != null) videoBlock.setDescription(videoBlockDTO.description());

if (videoBlockDTO.videoLink() != null) {
s3StorageService.delete(videoBlock.getVideoLink());
videoBlock.setVideoLink(videoBlockDTO.videoLink());
}

if (videoBlockDTO.attachedVideo() != null) {
s3StorageService.delete(videoBlock.getVideoLink());
videoBlock.setVideoLink(s3StorageService.store(videoBlockDTO.attachedVideo()));
Expand All @@ -66,6 +74,7 @@ public BlockResponseDTO modifyVideoBlock(UUID blockId, VideoBlockDTO videoBlockD
return BlockResponseDTO.fromEntity(videoBlock);
}

@Transactional
public void deleteVideoBlock(UUID pageId, UUID blockId) {
SharePage sharePage =
sharePageRepository
Expand Down

0 comments on commit 01f0a5f

Please sign in to comment.