@RequestMapping(value = "/memo", method = RequestMethod.POST) public ResponseEntity<Map<String, Object>> addMemo( @RequestBody Memo memo, HttpServletRequest request) { Map<String, Object> map = new HashMap<String, Object>(); HttpStatus status = null; User currentUser = (User) request.getSession().getAttribute("USER"); memo.setDate(new Date()); memo.setUserid(currentUser.getUserid()); if (memoDao.insertMemo(memo)) { map.put("MESSAGE", "MEMO HAS BEEN CREATED."); status = HttpStatus.CREATED; } else { map.put("MESSAGE", "MEMO HAS NOT BEEN CREATED."); status = HttpStatus.NOT_FOUND; } return new ResponseEntity<Map<String, Object>>(map, status); }
/// Elit Code @RequestMapping(value = "/memo", method = RequestMethod.GET) public ResponseEntity<Map<String, Object>> getMemo( @RequestParam("domain") String domain, @RequestParam("url") String url, HttpServletRequest request) { Map<String, Object> map = new HashMap<String, Object>(); HttpStatus status = null; try { User currentUser = (User) request.getSession(true).getAttribute("USER"); map.put( "MESSAGE", memoDao.getMemoByUrl(domain, url.replace(" ", "%20"), currentUser.getUserid())); status = HttpStatus.OK; } catch (Exception e) { e.printStackTrace(); map.put("isLogin", "false"); status = HttpStatus.INTERNAL_SERVER_ERROR; } return new ResponseEntity<Map<String, Object>>(map, status); }
@RequestMapping( value = "/signup", method = RequestMethod.POST, headers = "Accept=application/json") public ResponseEntity<Map<String, Object>> userSignup( @RequestBody User user, HttpServletResponse respone) { Map<String, Object> map = new HashMap<String, Object>(); if (userDao.saveUser(user) == true) { map.put("MESSAGE", "USER HAS BEEN SIGN UP"); map.put("STATUS", HttpStatus.ACCEPTED.value()); map.put("DATA", userDao.getUserByEmail(user.getEmail())); return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK); } else { map.put("MESSAGE", "USER SIGN UP FIALED"); map.put("STATUS", HttpStatus.NOT_ACCEPTABLE.value()); return new ResponseEntity<Map<String, Object>>(map, HttpStatus.NOT_ACCEPTABLE); } }