-
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.
Merge pull request #5 from wndlthsk/develop
Develop
- Loading branch information
Showing
12 changed files
with
233 additions
and
51 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Dockerfile | ||
|
||
# jdk17 Image Start | ||
#FROM --platform=linux/amd64 ubuntu:latest | ||
FROM openjdk:17 | ||
|
||
# 인자 설정 - Jar_File | ||
ARG JAR_FILE=build/libs/*.jar | ||
|
||
# jar 파일 복제 | ||
COPY ${JAR_FILE} app.jar | ||
|
||
# 인자 설정 부분과 jar 파일 복제 부분 합쳐서 진행해도 무방 | ||
#COPY build/libs/*.jar app.jar | ||
|
||
# 실행 명령어 | ||
ENTRYPOINT ["java", "-jar", "app.jar"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package team7.inplace.cicd; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class TestController { | ||
@GetMapping("/cicd") | ||
public ResponseEntity test() { | ||
return ResponseEntity.ok("ci/cd 테스트"); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
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,10 +1,15 @@ | ||
package team7.inplace.video.persistence; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import team7.inplace.place.domain.Place; | ||
import team7.inplace.video.domain.Video; | ||
|
||
import java.util.List; | ||
|
||
public interface VideoRepository extends JpaRepository<Video, Long> { | ||
List<Video> findVideosByInfluencerIdIn(List<Long> influencerIds); | ||
|
||
List<Video> findAllByOrderByIdDesc(); | ||
|
||
Video findTopByPlaceOrderByIdDesc(Place place); | ||
} |
71 changes: 62 additions & 9 deletions
71
src/main/java/team7/inplace/video/presentation/VideoController.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,28 +1,81 @@ | ||
package team7.inplace.video.presentation; | ||
|
||
import java.util.List; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import team7.inplace.video.application.VideoService; | ||
import org.springframework.web.bind.annotation.*; | ||
import team7.inplace.video.application.dto.VideoInfo; | ||
import team7.inplace.video.presentation.dto.VideoResponse; | ||
import team7.inplace.video.application.VideoService; | ||
import team7.inplace.video.presentation.dto.VideoSearchParams; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/videos") | ||
public class VideoController { | ||
private final VideoService videoService; | ||
|
||
// 내 인플루언서가 방문한 그 곳 ( 토큰 0 ) | ||
@GetMapping("/video") | ||
public ResponseEntity<List<VideoResponse>> readByInfluencer( | ||
@RequestParam(name = "influencer", required = false) List<String> influencers | ||
// 토큰 필요 메서드 | ||
@GetMapping() | ||
@Operation( | ||
summary = "내 인플루언서가 방문한 or 내 주변 그곳 ", | ||
description = "토큰의 유무에 따라 다른 동작을 수행합니다." | ||
) | ||
public ResponseEntity<List<VideoResponse>> readVideos( | ||
HttpServletRequest request, | ||
@RequestParam(name = "influencer", required = false) List<String> influencers, | ||
@ModelAttribute VideoSearchParams searchParams, | ||
@RequestParam(defaultValue = "0", required = false) int page, | ||
@RequestParam(defaultValue = "10", required = false) int size | ||
) { | ||
// Authorization 헤더 추출 | ||
String authHeader = request.getHeader("Authorization"); | ||
// 토큰 존재 여부 검사 | ||
if(authHeader != null && authHeader.startsWith("Bearer ")) { | ||
// 토큰 유효성 검사 | ||
|
||
// 토큰이 있는 경우 | ||
return readByInfluencer(influencers); | ||
} | ||
|
||
// 토큰이 없는 경우 | ||
return readBySurround(searchParams, page, size); | ||
} | ||
|
||
private ResponseEntity<List<VideoResponse>> readByInfluencer(List<String> influencers){ | ||
List<VideoInfo> videoInfos = videoService.findByInfluencer(influencers); | ||
List<VideoResponse> videoResponses = videoInfos.stream().map(VideoResponse::from).toList(); | ||
return new ResponseEntity<>(videoResponses, HttpStatus.OK); | ||
} | ||
|
||
private ResponseEntity<List<VideoResponse>> readBySurround(VideoSearchParams searchParams, int page, int size) { | ||
Pageable pageable = PageRequest.of(page, size); | ||
List<VideoInfo> videoInfos = videoService.findBySurround(searchParams, pageable); | ||
List<VideoResponse> videoResponses = videoInfos.stream().map(VideoResponse::from).toList(); | ||
return new ResponseEntity<>(videoResponses, HttpStatus.OK); | ||
} | ||
|
||
@GetMapping("/new") | ||
@Operation(summary = "새로 등록된 그 곳", description = "id를 기준으로 내림차순 정렬한 Video 정보를 조회합니다.") | ||
public ResponseEntity<List<VideoResponse>> readByNew() { | ||
List<VideoInfo> videoInfos = videoService.findAllDesc(); | ||
List<VideoResponse> videoResponses = videoInfos.stream().map(VideoResponse::from).toList(); | ||
return new ResponseEntity<>(videoResponses, HttpStatus.OK); | ||
} | ||
|
||
// 조회수 반환 기능 개발 시 개발 | ||
@GetMapping("/cool") | ||
@Operation(summary = "쿨한 그 곳", description = "조회수를 기준으로 내림차순 정렬한 Video 정보를 조회합니다.") | ||
public ResponseEntity<List<VideoResponse>> readByCool() { | ||
List<VideoResponse> videoResponses = new ArrayList<>(); | ||
return new ResponseEntity<>(videoResponses, HttpStatus.OK); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/team7/inplace/video/presentation/dto/VideoSearchParams.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,7 @@ | ||
package team7.inplace.video.presentation.dto; | ||
|
||
public record VideoSearchParams( | ||
String longitude, | ||
String latitude | ||
) { | ||
} |
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,3 +1,3 @@ | ||
spring: | ||
config: | ||
import: classpath:application-security.yaml, classpath:application-youtube.yaml | ||
import: classpath:application-security.yaml, classpath:application-youtube.yaml, optional:file:.env[.properties] |
3 changes: 1 addition & 2 deletions
3
...7/inplace/VideoTest/domain/VideoTest.java → ...team7/inplace/video/domain/VideoTest.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.