forked from rehmanmuradali/springboot-java8
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTopicController.java
More file actions
90 lines (70 loc) · 1.83 KB
/
Copy pathTopicController.java
File metadata and controls
90 lines (70 loc) · 1.83 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package hello.controller;
import hello.model.Topic;
import hello.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
public class TopicController {
@Autowired
private TopicService topicService;
/**
* Get all Topic
* @return
*/
@GetMapping("/topic")
public List<Topic> getAllTopics() {
return topicService.getAllTopics();
}
/**
* get Topic with ID
* @param id
* @return
*/
@GetMapping("/topic/{id}")
public Topic getTopicWithID(@PathVariable String id) {
return topicService.getTopicWithId(id);
}
/**
* Add a new topic in list
* @param topic
*/
@PostMapping("/topic")
public void addTopic(@RequestBody Topic topic) {
topicService.addTopic(topic);
}
/**
* Update Topic in List with id
* @param id
* @param topic
*/
@PutMapping("/topic/{id}")
public void updateTopic(@PathVariable String id, @RequestBody Topic topic) {
topicService.updateTopic(id, topic);
}
/**
* Delete a topic with ID
* @param id
*/
@DeleteMapping("/topic/{id}")
public void deleteTopic(@PathVariable String id) {
topicService.deleteTopic(id);
}
/**
* Get all topics with Id length greater then minimum length
* @param minLength
* @return
*/
@GetMapping("/topic/minimum/length/{minLength}")
public List<Topic> filterMinimumLengthForId(@PathVariable Integer minLength) {
return topicService.filterMinimumLengthForId(minLength);
}
/**
* Sort with Id
* @return
*/
@GetMapping("/topic/sort")
public List<Topic> sortTopicsWithID() {
return topicService.sortTopicsWithID();
}
}