Пример #1
0
  @RequestMapping(value = "/deleteInfo/{id}", method = RequestMethod.POST)
  @ResponseBody
  public Result deleteModule(@PathVariable Integer id) {
    Result result = new Result();
    if (id != null && id > 1) {
      Permission permission = new Permission();
      permission.setModuleId(Long.valueOf(id));
      if (permissionService.get(permission).size() > 0) {
        result.setMsg("该模块配置了权限,不可以删除");
        result.setSuccessful(false);
        return result;
      }

      Module module1 = new Module();
      module1.setParentId(Long.valueOf(id));
      if (moduleService.find(module1).size() > 0) {
        result.setMsg("该模块有子模块,不可以删除");
        result.setSuccessful(false);
        return result;
      } else {
        try {
          moduleService.delete(Long.valueOf(id));
          result.setMsg("操作成功");
          result.setSuccessful(true);
        } catch (ServiceException s) {
          result.setMsg(s.getMessage());
          result.setSuccessful(false);
          return result;
        }
      }
    }
    return result;
  }
Пример #2
0
  @RequestMapping(value = "/saveInfo", method = RequestMethod.POST)
  @ResponseBody
  public Result deleteModule(@ModelAttribute Module module) {
    Result result = new Result();

    if (module.getId() != null && module.getId() > 1) {

      Module modules = new Module();
      if (module.getName() != null && !(module.getId() == null)) {
        modules.setName(module.getName());
        modules.setSn(module.getSn());
        modules.setUrl(module.getUrl());
        if (moduleService.find(modules).size() > 1) {
          result.setMsg("已存在多个,不可修改");
          result.setSuccessful(false);
          return result;
        } else {
          try {
            moduleService.update(module);
            result.setMsg("操作成功");
            result.setSuccessful(true);
          } catch (ExistedException e) {
            result.setMsg(e.getMessage());
            result.setSuccessful(false);
            return result;
          }
        }
      }
    } else {
      Module modules = new Module();
      modules.setName(module.getName());
      modules.setSn(module.getSn());
      modules.setUrl(module.getUrl());
      if (moduleService.find(modules).size() > 0) {
        result.setMsg("已存在,不可添加");
        result.setSuccessful(false);
        return result;
      } else {
        try {
          if (module.getName() != null && module.getSn() != null && module.getUrl() != null) {
            moduleService.save(module);
          }
          result.setMsg("操作成功");
          result.setSuccessful(true);
        } catch (ExistedException e) {
          result.setMsg(e.getMessage());
          result.setSuccessful(false);
          return result;
        }
      }
    }
    return result;
  }