package sn.unitech.stock.metier;
import java.util.List;
import java.util.Map;
import sn.unitech.stock.dao.SysUsersDao;
import sn.unitech.stock.dao.iface.ISysUsersDao;
import sn.unitech.stock.entity.SysUsers;
import sn.unitech.stock.entity.SysUsersId;
import sn.unitech.stock.metier.iface.IConnexionM;
@SuppressWarnings("unchecked")
public class ConnexionM implements IConnexionM{
public ISysUsersDao iuser=new SysUsersDao ();
public boolean connexion(SysUsers user,String password){
//user=(SysUsers) iuser.find(SysUsers.class, new SysUsersId(user.getId().getIdUser(),user.getId().getIdAdherent()), null);
if(user==null)return false;
// System.out.println("password :"+util.getPasswd()+" "+ToolsMetier.getToolsMetier().encodePassword(password));
if(new String(user.getPasswd()).equals(password)){
return true;
}
else{
return false;
}
}
public SysUsers findUser(SysUsers user){
return (SysUsers) iuser.find(SysUsers.class, new SysUsersId(user.getId().getIdUser(),user.getId().getIdAdherent()), null);
}
@Override
public List getAuthorizedMenu(String jpql,Map param) {
return iuser.getResultList(jpql, null, param);
}
}