@ResponseBody @RequestMapping(value = "modify", method = RequestMethod.POST) public JSONObject modify(User user) { Boolean falg = userService.modify(user); JSONObject result = new JSONObject(); result.put("flag", falg); return result; }
@ResponseBody @RequestMapping(value = "deleteUser", method = RequestMethod.GET) public JSONObject deleteUser(int userId) { User user = new User(); user.setId(userId); boolean result = userService.delete(user); JSONObject data = new JSONObject(); data.put("result", result); return data; }
@ResponseBody @RequestMapping(value = "usersInPage", method = RequestMethod.GET) public JSONObject GetUserList(int pageNum) { System.out.println("pageNUm:" + pageNum); List<User> users = userService.getAll(); System.out.println(users); JSONArray userArray = JSONArray.fromObject(users); JSONObject data = new JSONObject(); data.put("array", userArray); return data; }
@ResponseBody @RequestMapping( value = "login", method = RequestMethod.POST, headers = {"content-type=application/json", "content-type=application/xml"}) public JSONObject login(@RequestBody User user) { User userInfo = userService.login(user); JSONObject result = new JSONObject(); if (userInfo != null) { result.put("code", 200); result.put("userData", JSONObject.fromObject(user)); } else { result.put("code", 404); } return result; }
@ResponseBody @RequestMapping(value = "get", method = RequestMethod.GET) public JSONObject get(User user) { User result = (User) userService.get(user); return JSONObject.fromObject(result); }