-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…VideoRefactoring1 [Refactor] #37 비디오에 대한 5주차 코드 리뷰 내용을 반영해보아요
- Loading branch information
Showing
8 changed files
with
124 additions
and
129 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/main/java/team7/inplace/global/exception/code/VideoErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package team7.inplace.global.exception.code; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
public enum VideoErrorCode implements ErrorCode{ | ||
NO_SUCH_VIDEO(HttpStatus.NOT_FOUND, "V001", "Can't find such video info"); | ||
|
||
private final HttpStatus httpStatus; | ||
private final String errorCode; | ||
private final String message; | ||
|
||
@Override | ||
public HttpStatus httpStatus() { | ||
return httpStatus; | ||
} | ||
|
||
@Override | ||
public String code() { | ||
return errorCode; | ||
} | ||
|
||
@Override | ||
public String message() { | ||
return message; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
src/main/java/team7/inplace/video/persistence/VideoRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
package team7.inplace.video.persistence; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import team7.inplace.place.domain.Place; | ||
import team7.inplace.video.domain.Video; | ||
|
||
public interface VideoRepository extends JpaRepository<Video, Long> { | ||
|
||
List<Video> findVideosByInfluencerIdIn(List<Long> influencerIds); | ||
Page<Video> findVideosByInfluencerIdIn(List<Long> influencerIds, Pageable pageable); | ||
|
||
List<Video> findAllByOrderByIdDesc(); | ||
Page<Video> findAllByOrderByIdDesc(Pageable pageable); | ||
|
||
Video findTopByPlaceOrderByIdDesc(Place place); | ||
Optional<Video> findTopByPlaceOrderByIdDesc(Place place); | ||
|
||
List<Video> findByPlaceIdIn(List<Long> placeIds); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 21 additions & 16 deletions
37
src/main/java/team7/inplace/video/presentation/VideoControllerApiSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
package team7.inplace.video.presentation; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ModelAttribute; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import team7.inplace.video.presentation.dto.VideoResponse; | ||
import team7.inplace.video.presentation.dto.VideoSearchParams; | ||
|
||
import java.util.List; | ||
|
||
|
||
public interface VideoControllerApiSpec { | ||
@Operation( | ||
summary = "내 인플루언서가 방문한 or 내 주변 그곳 ", | ||
description = "토큰의 유무에 따라 다른 동작을 수행합니다." | ||
summary = "내 주변 그곳 ", | ||
description = "Parameter로 입력받은 위치의 주변 장소들을 조회합니다." | ||
) | ||
public ResponseEntity<List<VideoResponse>> readVideos( | ||
HttpServletRequest request, | ||
@RequestParam(name = "influencer", required = false) List<String> influencers, | ||
ResponseEntity<Page<VideoResponse>> readVideos( | ||
@ModelAttribute VideoSearchParams searchParams, | ||
@RequestParam(defaultValue = "0", required = false) int page, | ||
@RequestParam(defaultValue = "10", required = false) int size | ||
@PageableDefault(page = 0, size = 10) Pageable pageable | ||
); | ||
|
||
@Operation(summary = "새로 등록된 그 곳", description = "id를 기준으로 내림차순 정렬한 Video 정보를 조회합니다.") | ||
public ResponseEntity<List<VideoResponse>> readByNew(); | ||
@Operation( | ||
summary = "새로 등록된 그 곳", | ||
description = "id를 기준으로 내림차순 정렬한 Video 정보를 조회합니다." | ||
) | ||
ResponseEntity<Page<VideoResponse>> readByNew( | ||
@PageableDefault(page = 0, size = 10) Pageable pageable | ||
); | ||
|
||
@Operation(summary = "쿨한 그 곳", description = "조회수를 기준으로 내림차순 정렬한 Video 정보를 조회합니다.") | ||
public ResponseEntity<List<VideoResponse>> readByCool(); | ||
@Operation( | ||
summary = "쿨한 그 곳", | ||
description = "조회수를 기준으로 내림차순 정렬한 Video 정보를 조회합니다." | ||
) | ||
ResponseEntity<Page<VideoResponse>> readByCool( | ||
@PageableDefault(page = 0, size = 10) Pageable pageable | ||
); | ||
} |
2 changes: 1 addition & 1 deletion
2
src/test/java/team7/inplace/video/application/VideoServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.