Exemplo n.º 1
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()));
  }
Exemplo n.º 2
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()));
 }