SubjectController.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.example.osservice.Controller;
  2. import com.example.osservice.Service.SubjectService;
  3. import com.example.osservice.VO.Response;
  4. import com.example.osservice.VO.Subject;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.web.bind.annotation.*;
  7. import java.util.List;
  8. @RestController
  9. @RequestMapping("/api/subject")
  10. public class SubjectController {
  11. @Autowired
  12. private SubjectService subjectService;
  13. @PostMapping("/")
  14. public Response<Subject> createSubject(@RequestBody long userId, @RequestBody String name, @RequestBody String description){
  15. return subjectService.createSubject();
  16. }
  17. @PutMapping("/{subjectId}")
  18. public Response<Boolean> updateSubject(@PathVariable long subjectId,@RequestBody long userId, @RequestBody String name, @RequestBody String description){
  19. return subjectService.updateSubject();
  20. }
  21. @DeleteMapping("/{subjectId}")
  22. public Response<Boolean> deleteSubject(@PathVariable long subjectId){
  23. return subjectService.deleteSubject();
  24. }
  25. @GetMapping("/{subjectId}")
  26. public Response<Subject> getSubject(@PathVariable long subjectId){
  27. return subjectService.getSubject();
  28. }
  29. @GetMapping("/list/{userId}")
  30. public Response<List<Subject>> getSubjectsByUserId(@PathVariable long userId){
  31. return subjectService.getSubjectsByUserId();
  32. }
  33. @GetMapping("/list")
  34. public Response<List<Subject>> getAllSubjects(){
  35. return subjectService.getAllSubjects();
  36. }
  37. }