Exemple #1
0
 /**
  * 根据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()));
 }
Exemple #2
0
  /**
   * 模块列表
   *
   * @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";
  }
Exemple #3
0
  /**
   * 增加模块
   *
   * @param request
   * @param response
   * @return 返回页面
   */
  @RequestMapping("/save")
  @ResponseBody
  public void save(
      @ModelAttribute ModelEntity model, HttpServletRequest request, HttpServletResponse response) {
    // 获取管理员id并赋值给模块的id
    model.setModelId(getManagerId(request));
    // 获取模块保存时间
    model.setModelDatetime(new Timestamp(System.currentTimeMillis()));
    if (!StringUtil.checkLength(model.getModelTitle(), 1, 20)) {
      this.outJson(
          response, getResString("err.length", this.getResString("modelTitle"), "2", "20"));
      return;
    }
    if (!StringUtil.checkLength(model.getModelCode(), 1, 20)) {
      this.outJson(response, getResString("err.length", this.getResString("modelCode"), "2", "20"));
      return;
    }

    // 判断图标是否为空,不为空去掉,图标地址中含有的“|”
    // 空值判断
    if (!StringUtil.isBlank(model.getModelIcon())) {
      model.setModelIcon(model.getModelIcon().replace("|", ""));
    }
    modelBiz.saveEntity(model);
    // 返回模块id到页面
    this.outJson(response, ModelCode.ROLE, true, String.valueOf(model.getModelId()));
  }
Exemple #4
0
 /**
  * 编辑模块
  *
  * @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;
 }
Exemple #5
0
 /**
  * 修改模块
  *
  * @return 返回页面
  */
 @RequestMapping("/update")
 @ResponseBody
 public void update(
     @ModelAttribute ModelEntity model, HttpServletRequest request, HttpServletResponse response) {
   if (!StringUtil.checkLength(model.getModelTitle(), 2, 20)
       || !StringUtil.checkLength(model.getModelCode(), 2, 20)) {
     return;
   }
   // 判断图标是否为空,不为空去掉,图标地址中含有的“|”
   // 空值判断
   if (!StringUtil.isBlank(model.getModelIcon())) {
     model.setModelIcon(model.getModelIcon().replace("|", ""));
   }
   modelBiz.updateEntity(model);
   this.outJson(response, ModelCode.ROLE, true, String.valueOf(model.getModelId()));
 }