-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVideoApiController.java
More file actions
47 lines (39 loc) · 1.28 KB
/
VideoApiController.java
File metadata and controls
47 lines (39 loc) · 1.28 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
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.birichani.code.restapi.api;
import com.birichani.code.restapi.constant.ErrorMessage;
import com.birichani.code.restapi.constant.InfoMessage;
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.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
@RequestMapping("/videos")
@RestController
public class VideoApiController {
private final VideoRepository videoRepository;
@Autowired
public VideoApiController(VideoRepository videoRepository) {
this.videoRepository = videoRepository;
}
@GetMapping("/{videoTopic}")
public String video (@PathVariable String videoTopic) {
String message;
switch (videoTopic) {
case "python":
message = InfoMessage.PYTHON_RESPONSE_MESSAGE;
break;
case "java":
message = InfoMessage.JAVA_RESPONSE_MESSAGE;
break;
default:
message = ErrorMessage.VIDEO_TOPIC_SELECTION_MESSAGE;
}
return message;
}
@GetMapping()
public List<Video> getAllvideos(){
return videoRepository.findAll();
}
}