Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] #6 로그인 없이 공통으로 조회할 수 있는 다양한 조건의 비디오 조회 기능을 구현했어요! #21

Merged
merged 21 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.3'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'



testImplementation 'org.springframework.boot:spring-boot-starter-test'
runtimeOnly 'com.mysql:mysql-connector-j'
runtimeOnly 'com.h2database:h2'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package team7.inplace.video.application;

import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import team7.inplace.influencer.entity.Influencer;
import team7.inplace.influencer.repository.InfluencerRepository;
Expand Down Expand Up @@ -32,6 +33,14 @@ public List<VideoInfo> findByInfluencer(List<String> influencers) {
return videoToInfo(savedVideos);
}

public List<VideoInfo> findAllDESC() {
BaeJunH0 marked this conversation as resolved.
Show resolved Hide resolved
// id를 기준으로 내림차순 정렬하여 비디오 정보 불러오기
List<Video> savedVideos = videoRepository.findAll(Sort.by(Sort.Direction.DESC, "id"));
BaeJunH0 marked this conversation as resolved.
Show resolved Hide resolved

// DTO 형식에 맞게 대입
return videoToInfo(savedVideos);
}

private List<VideoInfo> videoToInfo(List<Video> savedVideos) {
List<VideoInfo> videoInfos = new ArrayList<>();
for (Video savedVideo : savedVideos) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package team7.inplace.video.persistence;

import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
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> findAll(Sort sort);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package team7.inplace.video.presentation;

import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -10,20 +11,51 @@
import team7.inplace.video.presentation.dto.VideoResponse;
import team7.inplace.video.application.VideoService;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequiredArgsConstructor
public class VideoController {
private final VideoService videoService;

// 내 인플루언서가 방문한 그 곳 ( 토큰 0 )
// 토큰 필요 메서드
@GetMapping("/video")
@Operation(summary = "내 인플루언서가 방문한 그곳", description = "인플루언서를 기준으로 Video 정보를 조회합니다.")
public ResponseEntity<List<VideoResponse>> readByInfluencer(
@RequestParam(name = "influencer", required = false) List<String> influencers
) {
List<VideoInfo> videoInfos = videoService.findByInfluencer(influencers);
List<VideoResponse> videoResponses = videoInfos.stream().map(VideoResponse::new).toList();
List<VideoResponse> videoResponses = videoInfos.stream().map(VideoResponse::of).toList();
return new ResponseEntity<>(videoResponses, HttpStatus.OK);
BaeJunH0 marked this conversation as resolved.
Show resolved Hide resolved
}

// 토큰 불필요 메서드
// 내 주변 장소 반환 기능 ( PR 존재 ) weekly에 merge 시 개발
@GetMapping("/video")
BaeJunH0 marked this conversation as resolved.
Show resolved Hide resolved
@Operation(summary = "내 주변 그 곳", description = "내 위치를 기준으로 Video 정보를 조회합니다.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 개인적으로 인터페이스에서 Swagger에 대한 명세를 한 후 Implements해주는걸 좋아하는데 어떻게 생각하시나요?

Copy link
Contributor Author

@BaeJunH0 BaeJunH0 Sep 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

목요일 회의 시간에 어떻게 하는 지 알려주시겠어요? 딱 읽기만 해서는 감이 오질 않네요 ㅎㅎ...

public ResponseEntity<List<VideoResponse>> readBySurround(
@RequestParam(name = "longitude") String longtitude,
@RequestParam(name = "latitude") String latitude
) {
List<VideoResponse> videoResponses = new ArrayList<>();
return new ResponseEntity<>(videoResponses, HttpStatus.OK);
}

@GetMapping("/videos/new")
@Operation(summary = "새로 등록된 그 곳", description = "id를 기준으로 내림차순 정렬한 Video 정보를 조회합니다.")
public ResponseEntity<List<VideoResponse>> readByNew() {
List<VideoInfo> videoInfos = videoService.findAllDESC();
List<VideoResponse> videoResponses = videoInfos.stream().map(VideoResponse::of).toList();
return new ResponseEntity<>(videoResponses, HttpStatus.OK);
}

// 조회수 반환 기능 개발 시 개발
@GetMapping("/videos/cool")
@Operation(summary = "쿨한 그 곳", description = "조회수를 기준으로 내림차순 정렬한 Video 정보를 조회합니다.")
public ResponseEntity<List<VideoResponse>> readByCool() {
List<VideoResponse> videoResponses = new ArrayList<>();
return new ResponseEntity<>(videoResponses, HttpStatus.OK);
}

}
Loading