package ciai; import java.util.Map; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import ciai.model.Course; import ciai.model.Professor; @Controller @RequestMapping(value = "/professor") public class ProfessorController { AppSingleton aa = AppSingleton.getInstance(); Database dd = aa.getDatabase(); @RequestMapping(value = "/view/{id}", method = RequestMethod.GET) public @ResponseBody Professor getProfessor(@PathVariable int id) { return dd.getProfessor(id); } @RequestMapping(value = "/view/{id}/courses", method = RequestMethod.GET) public @ResponseBody Course[] getProfessorCourses(@PathVariable int id) { return dd.getCourses(); } @RequestMapping(value = "/edit/{id}", method = RequestMethod.POST) public @ResponseBody Boolean editStudent(@PathVariable int id, @RequestParam Map requestParams) throws Exception{ String email=requestParams.get("email"); String name=requestParams.get("name"); if(name.length() > 0 && email.length() > 0){ return dd.editProfessor(id,email,name); } return true; } }