@RequestMapping(value = "search.sdo") public @ResponseBody String search( HttpServletRequest request, HttpServletResponse response, UserEty userEty) throws Exception { int count = userDao.selectLimitCount(userEty); List<UserEty> list = userDao.selectByLimit(userEty); JSONObject retObj = JSONGrid.toJSon(list, count, new SimpleDateFormat("yyyy-MM-dd")); return retObj.toString(); }
@RequestMapping(value = "save.sdo", method = RequestMethod.POST) public @ResponseBody String save(UserEty userEty) { JSONObject obj = new JSONObject(); obj.put("success", true); if (userEty.getId() == null) { userDao.insert(userEty); } else { userDao.updateById(userEty); } obj.put("result", "success"); return obj.toString(); }
@RequestMapping(value = "delete.sdo", method = RequestMethod.POST) public @ResponseBody String delete(@RequestParam("id") int id) { JSONObject obj = new JSONObject(); obj.put("success", true); userDao.deleteById(id); obj.put("result", "success"); return obj.toString(); }
@RequestMapping(value = "getDetailInfo.sdo") public @ResponseBody String getDetailInfo(@RequestParam("id") int id) { JSONObject obj = new JSONObject(); obj.put("success", true); UserEty userEty = (UserEty) userDao.selectById(id); JsonConfig config = new JsonConfig(); config.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor("yyyy-MM-dd")); JSONObject dataObj = JSONObject.fromObject(userEty, config); obj.put("data", dataObj); return obj.toString(); }