Пример #1
0
 private void setLike(long id, String user, HttpServletResponse res, boolean isLike) {
   Video v = videos.findOne(id);
   int code = HttpServletResponse.SC_OK;
   if (v == null) {
     code = HttpServletResponse.SC_NOT_FOUND;
   } else {
     if (isLike ? v.addLikedUser(user) : v.removeLikedUser(user)) {
       videos.save(v);
     } else {
       code = HttpServletResponse.SC_BAD_REQUEST;
     }
   }
   res.setStatus(code);
 }
Пример #2
0
 @RequestMapping(method = RequestMethod.POST)
 public @ResponseBody Video addVideo(@RequestBody Video v) {
   return videos.save(v);
 }