package com.diary.controller;

import com.diary.model.Subject;
import com.diary.services.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;

/**
 * Created by JaroLP on 2016-11-06.
 */

@RestController
@RequestMapping("/subject")
@CrossOrigin
public class SubjectController {

    @Autowired
    SubjectService subjectService;

/*    @RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public List<Subject> findAll(){return subjectService.findAll();}*/

    @RequestMapping(method = RequestMethod.POST)
    @ResponseBody
    public Subject addNewSubject(@RequestBody Subject subject){
       return subjectService.addNewSubject(subject);
    }

    @RequestMapping(path = "/{subjectID}/teacher/{teacherID}", method = RequestMethod.PUT)
    public void addTeacherToSubject(@PathVariable("subjectID") String subjectID, @PathVariable("teacherID")String teacherID){
        subjectService.addSubjectToTeacher(Long.valueOf(subjectID),Long.valueOf(teacherID));
    }

    @RequestMapping(method = RequestMethod.PUT, path = "/{subjectID}/class/{classID}")
    public void addTeacherToClass(@PathVariable("classID") String classID, @PathVariable("subjectID") String subjectID){
        subjectService.addSubjectToClass(Long.valueOf(classID), Long.valueOf(subjectID));}

    @RequestMapping(path = "/{subjectID}/student/{studentID}/grade/{gradeID}", method = RequestMethod.PUT)
    public void addGradeToSubjectAndClass(@PathVariable("gradeID") String gradeID, @PathVariable("subjectID") String subjectID, @PathVariable("studentID") String studentID) {
        subjectService.addGradeToSubjectAndStudent(Long.valueOf(gradeID), Long.valueOf(subjectID), Long.valueOf(studentID));
    }

    @RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public void getSubjectByTeacher(@PathParam("teacherID") String teacherID){
        subjectService.getSubjectByTeacherId(teacherID);
    }

}

@@ -252,16 +252,39 @@
 thParam;
+%0Aimport java.util.List;
 %0A%0A/**%0A *
@@ -1903,20 +1903,29 @@
  public 
-void
+List%3CSubject%3E
  getSubj
@@ -1970,32 +1970,33 @@
 tring teacherID)
+ 
 %7B%0A        subjec
@@ -1981,32 +1981,39 @@
 erID) %7B%0A        
+return 
 subjectService.g

Fix dla kontrolera