|
| 1 | +package io.newgen.springbootstarter.course; |
| 2 | + |
| 3 | +import java.util.List; |
| 4 | + |
| 5 | +import org.springframework.beans.factory.annotation.Autowired; |
| 6 | +import org.springframework.web.bind.annotation.PathVariable; |
| 7 | +import org.springframework.web.bind.annotation.RequestBody; |
| 8 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 9 | +import org.springframework.web.bind.annotation.RequestMethod; |
| 10 | +import org.springframework.web.bind.annotation.RestController; |
| 11 | + |
| 12 | +@RestController |
| 13 | +public class CourseController { |
| 14 | + |
| 15 | + @Autowired |
| 16 | + private CourseService courseService; |
| 17 | + |
| 18 | + @RequestMapping("/topics/{topicId}/courses") |
| 19 | + public List<Course> getAllCourses(@PathVariable String topicId){ |
| 20 | + return courseService.getAllCourses(topicId); |
| 21 | + } |
| 22 | + |
| 23 | + @RequestMapping("/topics/{topicId}/course/{id}") |
| 24 | + public Course getCourse(@PathVariable String topicId, @PathVariable String id){ |
| 25 | + return courseService.getCourse(topicId, id); |
| 26 | + |
| 27 | + } |
| 28 | + |
| 29 | + @RequestMapping(method = RequestMethod.POST, value="/topics/{topicId}/course") |
| 30 | + public void addCourse(@RequestBody Course course, @PathVariable String topicId){ |
| 31 | + courseService.addCourse(course, topicId); |
| 32 | + |
| 33 | + } |
| 34 | + |
| 35 | + /*@RequestMapping(method = RequestMethod.PUT, value="/topic/{topicId}/course") |
| 36 | + public void updateTopic(@RequestBody Course course, @PathVariable String topicId){ |
| 37 | + courseService.updateCourse(course, topicId); |
| 38 | + } |
| 39 | + */ |
| 40 | + |
| 41 | + |
| 42 | +/* @RequestMapping(method = RequestMethod.DELETE, value="/course") |
| 43 | + public void deleteTopic(@RequestBody Course course){ |
| 44 | + courseService.deleteCourse(course); |
| 45 | + }*/ |
| 46 | + |
| 47 | +} |
0 commit comments