Skip to content

Commit

Permalink
Feat:썸네일 날짜별 조회 API
Browse files Browse the repository at this point in the history
  • Loading branch information
dudrhy12 committed Oct 8, 2024
1 parent 25ec43a commit cf92ff1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ public BaseResponseDto<ThumbnailResponseDto> getThumbnail(@PathVariable Long use
return BaseResponseDto.ofSuccess(GET_THUMBNAIL_SUCCESS, thumbnail);
}

@ResponseBody
@GetMapping(value="date/{userId}")
@Operation(summary = "썸네일 날짜별 조회")
public BaseResponseDto<ThumbnailResponseDto> getThumbnailByDate(@PathVariable Long userId, @RequestParam int year, @RequestParam int month, @RequestParam int day) {
final User user = jwtService.getAndValidateCurrentUser(userId);
ThumbnailResponseDto thumbnail = thumbnailUserBySocialLoginService.getThumbnailByDate(user.getUserId(), year, month, day);
return BaseResponseDto.ofSuccess(GET_THUMBNAIL_SUCCESS, thumbnail);
}

@ResponseBody
@PutMapping(value = "{userId}/{thumbnailId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@Operation(summary = "썸네일 수정")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ public interface ThumbnailRepository extends JpaRepository<Thumbnail, Long> {
List<Thumbnail> findThumbnailsByUserUserId(@Param("userId") long userId);

Thumbnail findByUserUserIdAndThumbnailId(long userId, long thumbnailId);

Thumbnail findByUserUserIdAndEventYearAndEventMonthAndEventDate(long uerId, int year, int month, int day);
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ public List<ThumbnailResponseDto> getThumbnail(long userId){
return thumbnails.stream()
.map(ThumbnailResponseDto::from)
.collect(Collectors.toList());
}

@Transactional
public ThumbnailResponseDto getThumbnailByDate(Long userId, int year, int month, int day) {
Thumbnail thumbnail = thumbnailRepository.findByUserUserIdAndEventYearAndEventMonthAndEventDate(userId, year, month, day);
return ThumbnailResponseDto.from(thumbnail);
}

@Transactional
Expand Down Expand Up @@ -94,4 +99,5 @@ public ThumbnailResponseDto updateThumbnail(MultipartFile thumbnailUrl, long use
updatedthumbnail.update(updatedFileName);
return new ThumbnailResponseDto(updatedthumbnail.getThumbnailId(), updatedthumbnail.getEventYear(), updatedthumbnail.getEventMonth(), updatedthumbnail.getEventDate(), updatedthumbnail.getThumbnailUrl());
}

}

0 comments on commit cf92ff1

Please sign in to comment.