package pl.dmcs.mati.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pl.dmcs.mati.domain.AppUserRole;
import pl.dmcs.mati.repository.AppUserRepository;
import pl.dmcs.mati.repository.AppUserRoleRepository;

import java.util.List;

@Service("appUserRoleService")
public class AppUserRoleServiceImpl implements AppUserRoleService {

    private AppUserRoleRepository appUserRoleRepository;

    @Autowired
    public AppUserRoleServiceImpl(AppUserRoleRepository appUserRoleRepository) {
        this.appUserRoleRepository = appUserRoleRepository;
    }

    @Transactional
    public void addAppUserRole(AppUserRole appUserRole) {
        appUserRoleRepository.save(appUserRole);
    }

    @Transactional
    public List<AppUserRole> listAppUserRole() { return appUserRoleRepository.findAll(); }

    @Transactional
    public AppUserRole getAppUserRole(long id) { return appUserRoleRepository.getOne(id); }
}
