/** * 模块列表 * * @param request * @param request 请求 * @return 返回页面 */ @RequestMapping("/list") public String list(ModelMap mode, HttpServletRequest request) { List<BaseEntity> parentModelList = modelBiz.queryChildList(0); List<BaseEntity> modelList = new ArrayList<BaseEntity>(); int modelId = 0; if (!StringUtil.isBlank(request.getParameter("modelId"))) { modelId = Integer.valueOf(request.getParameter("modelId")); } List<BaseEntity> childModelList = null; // 根据模块id循环遍历出其所有的上层模块 while (modelId != 0) { ModelEntity model = (ModelEntity) modelBiz.getEntity(modelId); // 查找子模块id childModelList = modelBiz.queryChildList(model.getModelModelId()); if (childModelList.size() > 1) { for (BaseEntity i : childModelList) { modelList.add(i); } } else { modelList.add(model); } modelId = model.getModelModelId(); } if (modelList != null && modelList.size() != 0) { Collections.reverse(modelList); mode.addAttribute("modelList", modelList); } mode.addAttribute("parentModelList", parentModelList); return "/manager/model/model_list"; }
/** * 根据Id删除模块 * * @param modelId 模块Id * @return */ @RequestMapping("/{modelId}/delete") @ResponseBody public void delete(@PathVariable int modelId, HttpServletResponse response) { ModelEntity model = (ModelEntity) modelBiz.getEntity(modelId); modelBiz.deleteEntity(modelId); this.outJson(response, ModelCode.ROLE, true, String.valueOf(model.getModelModelId())); }
/** * 编辑模块 * * @return * @return 返回页面 */ @RequestMapping("/edit/{modelId}") @ResponseBody public ModelMap edit(ModelMap mode, @PathVariable int modelId) { List<BaseEntity> allModel = modelBiz.queryAll(); mode.clear(); // 根据id获取模块 ModelEntity model = (ModelEntity) modelBiz.getEntity(modelId); // 根据父模块id查寻模块 ModelEntity parentModel = (ModelEntity) modelBiz.getEntity(model.getModelModelId()); mode.addAttribute("allModel", allModel); mode.addAttribute("parentModel", parentModel); mode.addAttribute("model", model); return mode; }