Advertisement
Guest User

Untitled

a guest
Mar 12th, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. package defaultpackage.topic;
  2.  
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.web.bind.annotation.*;
  5.  
  6. import java.util.Arrays;
  7. import java.util.List;
  8.  
  9. /**
  10. * Created by zales on 02.03.2017.
  11. */
  12. @RestController
  13. public class TopicController {
  14.  
  15. @Autowired
  16. private TopicService topicService;
  17.  
  18. @RequestMapping("/topics")
  19. public List<Topic> getAllTopics(){
  20. return topicService.getAllTopics();
  21. }
  22.  
  23. @RequestMapping("/topics/{id}")
  24. public Topic getTopic(@PathVariable String id){
  25. return topicService.getTopic(id);
  26. }
  27.  
  28. @RequestMapping(method = RequestMethod.POST, value = "/topics")
  29. public void addTopic(@RequestBody Topic topic){
  30. topicService.addTopic(topic);
  31. }
  32.  
  33. @RequestMapping(method = RequestMethod.PUT, value = "/topics/{id}")
  34. public void updateTopic(@RequestBody Topic topic, @PathVariable String id){
  35. topicService.updateTopic(id, topic);
  36. }
  37. @RequestMapping(method = RequestMethod.DELETE, value = "/topics/{id}")
  38. public void deleteTopic(@PathVariable String id){
  39. topicService.deleteTopic(id);
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement