package com.pas.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pas.dao.UserDao;
import com.pas.model.AuthExternal;
import com.pas.model.User;
import com.pas.service.UserService;

@Service
public class UserServiceImpl implements UserService {
	@Autowired
	UserDao userDao;	

	@Transactional
	public void add(User user) {
		userDao.add(user);
	}
	
	@Transactional
	public void edit(User user) {
		userDao.edit(user);
	}
	
	@Transactional
	public void delete(int userId) {
		userDao.delete(userId);
	}
	
	@Transactional
	public User getUser(int userId) {
		return (User) userDao.getUser(userId);
	}
	
	@Transactional
	public List<User> getAllUser() {
		return (List<User>) userDao.getAllUser();
	}
	
	@Transactional
	public void createExternalConnector(AuthExternal auth) {
		userDao.createExternalConnector(auth);
	}
	
	@Transactional
    public User getUserByExternalConnector(String service, String username) {
    	return (User) userDao.getUserByExternalConnector(service, username);
    }

	@Transactional
	public User getUserByUserName(String username) {
		return (User) userDao.getUserByUserName(username);
	}
    
	@Transactional
    public List<AuthExternal> getExternalConnector(String service, String username) {
    	return (List<AuthExternal>) userDao.getExternalConnector(service, username);
    }
    
	@Transactional
    public List<User> findByAuthorization(String username, String pwd) {
    	return (List<User>) userDao.findByAuthorization(username, pwd);
    }
}