package com.palmnest.dao.estateserve.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.palmnest.dao.estateserve.VirtUserDao;
import com.palmnest.dao.hibernate.GenericDaoHibernate;
import com.palmnest.model.VirtUserInfo;
import com.palmnest.model.estateserve.AppUser;

@Repository("virtUserDao")
public class VirtUserDaoImpl extends GenericDaoHibernate<VirtUserInfo, Integer> implements VirtUserDao {

	public VirtUserDaoImpl() {
		super(VirtUserInfo.class);
	}

	@Override
	public String delVirtUserByVirtId(int virtId) throws Exception {
		int count = this.getSession().createQuery("DELETE from VirtUserInfo  where virId =? ").setInteger(0, virtId).executeUpdate();
		if (count > 0) {
			return "200";
		} else {
			return "100";
		}
	}

	@Override
	public List<VirtUserInfo> getVirUserByVirId(int virId) throws Exception {
		String sql = "from VirtUserInfo where virId=? ";
		List<VirtUserInfo> userList = getSession().createQuery(sql).setInteger(0, virId).list();
		return userList;
	}

	@Override
	public List<VirtUserInfo> getVirIdByUserId(int userId) throws Exception {
		String sql = "from VirtUserInfo where userId=? ";
		List<VirtUserInfo> userList = getSession().createQuery(sql).setInteger(0, userId).list();
		return userList;
	}

}
