@RequestMapping(value = "/provider/products/{id}", method = RequestMethod.GET, params = "edit") public String edit(Model uiModel, @PathVariable("id") Long id) { Provider user = (Provider) userContext.getCurrentUser(); Product product = productService.findOneByUser(user, id); uiModel.addAttribute("product", product); return USERPRODUCTSEDIT; }
@RequestMapping(value = "/provider/detail", method = RequestMethod.GET) public String findCurrentProvider(Model uiModel) { SiteUser user = userContext.getCurrentUser(); Provider provider = providerService.findOne(user.getId()); if (provider == null) { throw new UserNotFoundException(); } uiModel.addAttribute("user", provider); return "user/provider/detail"; }
@RequestMapping(value = "/provider/detail", method = RequestMethod.PUT) public String updateCurrentProvider( Model uiModel, @ModelAttribute("user") Provider provider, BindingResult bindingResult) { if (bindingResult.hasErrors()) { uiModel.addAttribute("user", provider); return "user/provider/detail"; } SiteUser user = userContext.getCurrentUser(); provider.setId(user.getId()); provider = providerService.updateProvider(provider); uiModel.addAttribute("user", provider); return "user/provider/detail"; }