OSDN Git Service

ca091228bed7e1886f1ea37fcb37bc0e28271f95
[ngware/todo_java.git] / src / main / java / com / example / rest / TodoRestController.java
1 package com.example.rest;\r
2 \r
3 import java.util.List;\r
4 \r
5 import org.springframework.beans.factory.annotation.Autowired;\r
6 import org.springframework.http.MediaType;\r
7 import org.springframework.web.bind.annotation.RequestMapping;\r
8 import org.springframework.web.bind.annotation.RequestMethod;\r
9 import org.springframework.web.bind.annotation.RequestParam;\r
10 import org.springframework.web.bind.annotation.ResponseBody;\r
11 import org.springframework.web.bind.annotation.RestController;\r
12 \r
13 import com.example.domain.TodoHeaderInfo;\r
14 import com.example.domain.TodoListInfo;\r
15 import com.example.service.TodoService;\r
16 \r
17 \r
18 @RestController\r
19 @RequestMapping("/api")\r
20 public class TodoRestController {\r
21         \r
22         @Autowired\r
23         TodoService todoHeaderService;\r
24         \r
25         @RequestMapping(value = "/findHeaders", method = RequestMethod.GET)\r
26         @ResponseBody\r
27         public List<TodoHeaderInfo> findHeaders() {\r
28                 return todoHeaderService.findTodoHeaders();\r
29         }\r
30         \r
31         @RequestMapping(value = "/findLists", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE , produces = MediaType.APPLICATION_JSON_VALUE)\r
32         @ResponseBody\r
33         public List<TodoListInfo> findLists(@RequestParam(name = "headerId") String headerId) {\r
34                 return todoHeaderService.findTodoLists(headerId);\r
35         }\r
36         \r
37         @RequestMapping(value = "/getLists", method = RequestMethod.GET)\r
38         @ResponseBody\r
39         public List<TodoListInfo> getLists(@RequestParam(name = "headerId") String headerId) {\r
40                 return todoHeaderService.findTodoLists(headerId);\r
41         }\r
42 }\r