コード例 #1
0
  @RequestMapping(value = "/init-update/{id}")
  public String initUpdate(@PathVariable long id, Model model) {
    model.addAttribute("resources", resourcesService.getById(id));
    model.addAttribute("modules", resourcesService.getModules());

    return "resources/update";
  }
コード例 #2
0
  @RequestMapping(value = "/list", method = RequestMethod.GET)
  public String list(Model model) {
    model.addAttribute("listResources", resourcesService.getAll());
    model.addAttribute("resources", new Resources());
    model.addAttribute("modules", resourcesService.getModules());

    return "resources/list";
  }
コード例 #3
0
  @RequestMapping(value = "/save", method = RequestMethod.POST)
  public String save(@Valid @ModelAttribute("resources") Resources resources, BindingResult result)
      throws BindException {
    if (result.hasErrors()) {
      throw new BindException(result);
    }

    String username = SecurityContextHolder.getContext().getAuthentication().getName();

    if (resources.getId() == null) resourcesService.save(resources, username);
    else resourcesService.update(resources, username);

    return "redirect:/resource/list";
  }
コード例 #4
0
  @RequestMapping(value = "/enable/{id}")
  @ResponseBody
  public Map<String, Object> enableStatus(@PathVariable("id") long id) {
    Map<String, Object> map = new HashMap<String, Object>();
    Resources r = resourcesService.getById(id);

    if (r == null) throw new BusinessException("无法删除,没有这个资源");

    String username = SecurityContextHolder.getContext().getAuthentication().getName();

    if (resourcesService.enableOrNot(r, username)) {
      map.put("flag", true);
    } else {
      map.put("flag", false);
    }

    return map;
  }