コード例 #1
0
  @PostAuthorize(
      "hasRole('ROLE_ADMIN') || returnObject == null || returnObject.userId == principal.id")
  public Component createComponent(ComponentDTO dto) {
    Component component = new Component();
    component.setUserId(SecurityHelper.getCurrentUserId());

    ComponentMapper.copyDTOtoDomain(dto, component);

    return componentRepository.save(component);
  }
コード例 #2
0
 @PreAuthorize("hasRole('ROLE_ADMIN') || #existing.userId == principal.id")
 public Component updateComponent(Component existing, ComponentDTO dto) {
   ComponentMapper.copyDTOtoDomain(dto, existing);
   return componentRepository.save(existing);
 }