package com.chinacreator.process.dao;

import java.sql.SQLException;

import org.apache.commons.lang.math.NumberUtils;
import org.springframework.stereotype.Component;

import com.chinacreator.process.util.DataSource;
import com.frameworkset.common.poolman.SQLExecutor;

@Component
public class BlackWhiteDao {

	public boolean isWhite(String userid) throws SQLException{
		String sql = "select count(1) from td_activity_white where userid = ?";
		return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G,sql,userid))>0;
	}
	
	public boolean isWhite(String userid,String cpid,String spid) throws SQLException{
		String sql = "select count(1) from td_activity_white where userid = ? and cpid = ? and spid = ?";
		return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G,sql,userid))>0;
	}
	
	public static void main(String[] args) throws SQLException {
		BlackWhiteDao dao = new BlackWhiteDao();
		dao.isWhite("18574414678");
	}
}
