-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTopicController.java
More file actions
54 lines (38 loc) · 1.45 KB
/
TopicController.java
File metadata and controls
54 lines (38 loc) · 1.45 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
package com.app.topic;
import java.util.Arrays;
import java.util.List;
import javax.websocket.server.PathParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.app.dto.Topic;
@RestController
@RequestMapping(value="/topics")
public class TopicController {
@Autowired
TopicService topicservice;
@RequestMapping(value="/gettopics")
public List<Topic> getAllTopics() {
return topicservice.getAllTopics();
}
@RequestMapping(value="/{id}")
public Topic getTopic(@PathVariable String id) {
return topicservice.getTopic(id);
}
@RequestMapping(method = RequestMethod.POST, value="/addtopic")
public void addTopic(@RequestBody Topic topic) {
topicservice.addTopic(topic);
}
@RequestMapping(method = RequestMethod.PUT, value="/{id}")
public void updateTopic( @RequestBody Topic topic, @PathVariable String id) {
System.out.println("enterd controler");
topicservice.upateTopic(topic, id);
}
@RequestMapping(method = RequestMethod.DELETE, value="/{id}")
public void deleteTopic(@PathVariable String id) {
topicservice.deleteTopic(id);
}
}