package org.well.well.manager;


import org.well.well.core.hibernate.HibernateEntityDao;
import org.well.well.domain.SysUser;
import org.well.well.domain.UserClient;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserClientManager extends HibernateEntityDao<UserClient> {
    public  String getClientByUser(SysUser sysUser){
        Criteria criteria = getSession().createCriteria(UserClient.class);
        criteria.add(Restrictions.eq("userId", sysUser.getId()));
        List<UserClient> userClientList = criteria.list();
        if (userClientList != null && userClientList.size() > 0)
            return userClientList.get(0).getClientId();
        return "";
    }
}
