@RequestMapping("access-save")
public String save(@ModelAttribute Access access,
@RequestParam("permId") Long permId,
RedirectAttributes redirectAttributes) {
// copy
Access dest = null;
Long id = access.getId();
if (id != null) {
dest = accessManager.get(id);
beanMapper.copy(access, dest);
} else {
dest = access;
}
// foreign
Perm perm = permManager.get(permId);
dest.setPerm(perm);
if (id == null) {
dest.setScopeId(ScopeHolder.getScopeId());
}
// save
accessManager.save(dest);