// 保存和刷新 @RequestMapping(value = "/saveUserstatue", method = RequestMethod.POST) @ResponseBody public Object save(T_USERSTATUEINFO t_userstatueinfo) { Map map = new HashMap(); try { if (t_userstatueinfo.getId() == null) { t_userstatueinfoService.save(t_userstatueinfo); map.put("state", "0"); } else { t_userstatueinfoService.update(t_userstatueinfo); map.put("state", "1"); } } catch (Exception e) { e.printStackTrace(); } finally { } return map; }
// 获取列表信息 @RequestMapping("/jsonUserstatue") public Object jsonList(HttpServletRequest request, HttpServletResponse response) { // 分页 int pageSize = request.getParameter("limit") == null ? 10 : Integer.parseInt(request.getParameter("limit")); Map filter = getFilterMap(request); int currentResult = Integer.parseInt(request.getParameter("offset")); response.setContentType("application/json;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); PrintWriter pw = null; PageInfo pageInfo = new PageInfo(); pageInfo.setShowCount(pageSize); pageInfo.setCurrentResult(currentResult); pageInfo.setFilter(filter); pageInfo.setSortField("ID"); pageInfo.setOrder("asc"); pageInfo.setFilter(filter); Long ID = null; if (request.getParameter("search_ID") != null && request.getParameter("search_ID") != "") { ID = Long.valueOf(request.getParameter("search_ID")); } filter.remove("ID"); List<T_USERSTATUEINFO> t_userstatueinfos = t_userstatueinfoService.selectListPage(pageInfo, ID); Json json = new Json(); if (t_userstatueinfos.size() == 0) { Json json_a = new Json(); json.add("total", 0); json.add("rows", json_a); try { pw = response.getWriter(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } pw.write(json.toString()); pw.flush(); return null; } json.add("total", pageInfo.getTotalResult()); for (T_USERSTATUEINFO t_userstatueinfo : t_userstatueinfos) { Json json_a = new Json(); json_a.add("state", ""); json_a.add("ID", String.valueOf(t_userstatueinfo.getId())); json_a.add( "STATUENAME", t_userstatueinfo.getStatueName() == null ? "" : t_userstatueinfo.getStatueName()); json_a.add( "STATUE", String.valueOf(t_userstatueinfo.getStatue()) == null ? "" : String.valueOf(t_userstatueinfo.getStatue())); json.add("rows", json_a); } try { pw = response.getWriter(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } pw.write(json.toString()); pw.flush(); return null; }