예제 #1
0
 @ResponseBody
 @RequestMapping(value = "/getgroups", method = RequestMethod.GET)
 public List<Group> getGroups(@AuthenticationPrincipal ElearningUserDetails principal) {
   if (AccountUtils.isStudent(principal)) {
     return groupService.getActiveGroups(Long.valueOf(principal.getAccountId()));
   } else {
     return groupService.getOwnedGroups(Long.valueOf(principal.getAccountId()));
   }
 }
예제 #2
0
 @ResponseBody
 @RequestMapping(value = "/create", method = RequestMethod.POST)
 public List<Group> create(
     @RequestParam("title") String title,
     @AuthenticationPrincipal ElearningUserDetails principal) {
   groupService.createGroup(principal.getUsername(), title);
   System.out.println("console=" + AccountUtils.isStudent(principal));
   if (AccountUtils.isStudent(principal)) {
     return groupService.getActiveGroups(Long.valueOf(principal.getAccountId()));
   } else {
     return groupService.getOwnedGroups(Long.valueOf(principal.getAccountId()));
   }
 }
예제 #3
0
 @ResponseBody
 @RequestMapping(value = "/addstudent", method = RequestMethod.POST)
 public String addStudent(
     @RequestParam("username") String username, @RequestParam("id") Long groupId) {
   groupService.addUserToGroup(username, groupId);
   return OK;
 }
예제 #4
0
 @ResponseBody
 @RequestMapping(value = "/removestudent", method = RequestMethod.POST)
 public String removeStudent(
     @RequestParam("username") String username, @RequestParam("id") Long courseId) {
   groupService.removeUserFromGroup(username, courseId);
   return OK;
 }
예제 #5
0
 @ResponseBody
 @RequestMapping(value = "/group", method = RequestMethod.GET)
 public Group group(
     @RequestParam("id") Long groupId,
     Model model,
     @AuthenticationPrincipal ElearningUserDetails principal) {
   return groupService.getGroup(groupId);
 }
예제 #6
0
 @ResponseBody
 @RequestMapping(value = "/sendmessage", method = RequestMethod.POST)
 public String sendMessage(
     @AuthenticationPrincipal ElearningUserDetails principal,
     @RequestParam("id") Long groupId,
     @RequestParam("content") String content) {
   groupService.createGroupMessage(principal.getUsername(), groupId, content);
   return OK;
 }
예제 #7
0
 @ResponseBody
 @RequestMapping(value = "/update", method = RequestMethod.POST)
 public String update(@RequestParam("id") Long groupId, @RequestParam("name") String newName) {
   groupService.updateGroupName(groupId, newName);
   return OK;
 }
예제 #8
0
 @ResponseBody
 @RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)
 public String delete(@PathVariable("id") Long id) {
   groupService.deleteGroup(id);
   return OK;
 }