package com.bayer.burp.repository;

import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RestResource;
import org.springframework.security.access.prepost.PreAuthorize;

import com.bayer.burp.domain.User;

@PreAuthorize("hasRole('ROLE_USER')")
public interface UserRepository extends PagingAndSortingRepository<User, Long> {

	@PreAuthorize("hasRole('ROLE_ADMIN')")
	@Override
	User save(User user);

	@PreAuthorize("hasRole('ROLE_ADMIN')")
	@Override
	void delete(User user);
	
	@RestResource(exported = false)
	User findByName(String name);

}
