コード例 #1
0
 /**
  * 分页获取地区
  *
  * @return
  */
 @RequestMapping(value = "/list.htm", method = RequestMethod.POST)
 public ModelAndView listPagination(HttpServletRequest request) {
   ModelAndView modelAndView = new ModelAndView();
   modelAndView.setViewName("/area/areaData");
   // 分页处理
   Map<String, Object> params = new HashMap<String, Object>();
   Pagination p = PaginationUtil.parse(request);
   params.put("start", (p.getCurPage() - 1) * p.getPageSize() + 1);
   // mysql
   params.put("end", p.getPageSize());
   // oracle
   // params.put("end", p.getCurPage()*p.getPageSize());
   // 排序
   String sort = request.getParameter("sort"); // 状态
   String order = request.getParameter("order"); // 创建 时间
   params.put("sort", sort);
   params.put("order", order); //
   // 总数量
   int total = areaService.getAllEntityCount(params);
   p = PaginationUtil.parse(request, total);
   // 分页记录集
   List<Area> areas = areaService.getAllEntity(params);
   modelAndView.addObject("pagination", p);
   modelAndView.addObject("datas", areas);
   return modelAndView;
 }
コード例 #2
0
 /**
  * 修改页面
  *
  * @return
  */
 @RequestMapping(value = "/update.htm", method = RequestMethod.GET)
 public ModelAndView update(@RequestParam String areaId) {
   ModelAndView modelAndView = new ModelAndView();
   Area area = areaService.findEntityBykey(areaId);
   modelAndView.setViewName("/area/areaAddOrUpdate");
   modelAndView.addObject("area", area);
   return modelAndView;
 }
コード例 #3
0
 /**
  * 得到地区列表页面
  *
  * @return
  */
 @RequestMapping(value = "/index.htm", method = RequestMethod.GET)
 public ModelAndView index() {
   String id = StringUtil.getUUID();
   System.out.println("gen id====" + id);
   areaService.insertAndDeleteArea(id);
   ModelAndView modelAndView = new ModelAndView();
   modelAndView.setViewName("/area/areaList");
   return modelAndView;
 }
コード例 #4
0
 /**
  * 添加或修改 地区
  *
  * @param id
  * @return
  */
 @RequestMapping(value = "/{id}.json", method = RequestMethod.POST)
 @ResponseBody
 public JSONResult addOrUpdate(@PathVariable String id, Area area) {
   JSONResult result = new JSONResult();
   try {
     area.setName(StringUtil.urlDecode(area.getName()));
     area.setCode(StringUtil.urlDecode(area.getCode()));
     area.setParentId(StringUtil.urlDecode(area.getParentId()));
     area.setRemark(StringUtil.decode(area.getRemark()));
     if (areaService.exists(id)) { // 数据库中已经存在
       areaService.updateEntity(area);
     } else {
       areaService.addEntity(area);
     }
     result.setResult(true);
     result.setData(area);
   } catch (Exception e) {
     result.setResult(false);
     result.setErrorDesc("出现异常:" + e.getMessage());
   }
   return result;
 }
コード例 #5
0
 /**
  * 查询相应的地区
  *
  * @param id
  * @return
  */
 @RequestMapping(value = "/{id}.json", method = RequestMethod.GET)
 @ResponseBody
 public JSONResult get(@PathVariable String id) {
   JSONResult result = new JSONResult();
   try {
     Area area = areaService.findEntityBykey(id);
     result.setResult(true);
     result.setData(area);
   } catch (Exception e) {
     result.setResult(false);
     result.setErrorDesc("出现异常:" + e.getMessage());
   }
   return result;
 }
コード例 #6
0
 /**
  * 删除 地区
  *
  * @param id
  * @return
  */
 @RequestMapping(value = "/{id}.json", method = RequestMethod.DELETE)
 @ResponseBody
 public JSONResult delete(@PathVariable String id) {
   JSONResult result = new JSONResult();
   try {
     areaService.deleteEntityByKey(id);
     result.setResult(true);
     result.setData(null);
   } catch (Exception e) {
     result.setResult(false);
     result.setErrorDesc("出现异常:" + e.getMessage());
   }
   return result;
 }
コード例 #7
0
 /**
  * 查询所有地区
  *
  * @return
  */
 @RequestMapping(value = "/list.json", method = RequestMethod.GET)
 @ResponseBody
 public JSONResult list() {
   JSONResult result = new JSONResult();
   try {
     List<Area> areas = areaService.getAllEntity();
     result.setResult(true);
     result.setData(areas);
   } catch (Exception e) {
     result.setResult(false);
     result.setErrorDesc("出现异常:" + e.getMessage());
   }
   return result;
 }