package com.ifish.daoImpl;

import java.math.BigInteger;

import org.springframework.stereotype.Repository;

import com.ifish.dao.CameraUserDao;
import com.ifish.entity.CameraUser;
import com.ifish.entity.CameraUserId;
import com.ifish.hibernate.HibernateBaseDao;

/** 
 * @ClassName: CameraUserDaoImpl
 * @Description: TODO 
 * @author ggw 
 *  
 */

@Repository
public class CameraUserDaoImpl extends HibernateBaseDao<CameraUser, CameraUserId> implements CameraUserDao {

	@Override
	protected Class<CameraUser> getEntityClass() {
		return CameraUser.class;
	}

	/**
	 * 查询用户的摄像头数量
	 * @param userId
	 * @return
	 */
	@Override
	public int getCameraNumById(Integer userId) {
		String sql = "select count(*) from tbl_camera_user where user_id=?";
		int deviceNum = ((BigInteger)this.getSession().createSQLQuery(sql).setInteger(0, userId).uniqueResult()).intValue();
		return deviceNum;
	}

}
