| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package com.example.osservice.Controller;
- import com.example.osservice.Service.SubjectService;
- import com.example.osservice.VO.Response;
- import com.example.osservice.VO.Subject;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.util.List;
- @RestController
- @RequestMapping("/api/subject")
- public class SubjectController {
- @Autowired
- private SubjectService subjectService;
- @PostMapping("/")
- public Response<Subject> createSubject(@RequestBody long userId, @RequestBody String name, @RequestBody String description){
- return subjectService.createSubject();
- }
- @PutMapping("/{subjectId}")
- public Response<Boolean> updateSubject(@PathVariable long subjectId,@RequestBody long userId, @RequestBody String name, @RequestBody String description){
- return subjectService.updateSubject();
- }
- @DeleteMapping("/{subjectId}")
- public Response<Boolean> deleteSubject(@PathVariable long subjectId){
- return subjectService.deleteSubject();
- }
- @GetMapping("/{subjectId}")
- public Response<Subject> getSubject(@PathVariable long subjectId){
- return subjectService.getSubject();
- }
- @GetMapping("/list/{userId}")
- public Response<List<Subject>> getSubjectsByUserId(@PathVariable long userId){
- return subjectService.getSubjectsByUserId();
- }
- @GetMapping("/list")
- public Response<List<Subject>> getAllSubjects(){
- return subjectService.getAllSubjects();
- }
- }
|