-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVideoApiController.java
More file actions
34 lines (29 loc) · 1.11 KB
/
Copy pathVideoApiController.java
File metadata and controls
34 lines (29 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.birichani.code.restapi.api;
import com.birichani.code.restapi.model.Video;
import com.birichani.code.restapi.repository.VideoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.birichani.code.restapi.service.VideoService;
import java.util.List;
@RequestMapping("/videos")
@RestController
public class VideoApiController {
private final VideoRepository videoRepository;
private final VideoService videoService;
@Autowired
public VideoApiController(VideoRepository videoRepository, VideoService videoService) {
this.videoRepository = videoRepository;
this.videoService = videoService;
}
@GetMapping("/{videoTopic}")
public String getVideosByTopic(@PathVariable String videoTopic) {
return videoService.getVideosByTopic(videoTopic);
}
@GetMapping()
public List<Video> getAllVideos(){
return videoRepository.findAll();
}
}