1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package com.chinacreator.videoalliance.order.dao;
- import java.sql.SQLException;
- import org.apache.commons.lang.math.NumberUtils;
- import org.springframework.cache.annotation.Cacheable;
- import org.springframework.stereotype.Component;
- import com.chinacreator.common.support.cache.annotation.CacheName;
- import com.chinacreator.videoalliance.common.util.DataSource;
- import com.frameworkset.common.poolman.SQLExecutor;
- /**
- * 黑白名单
- * @author 范秋海
- */
- @Component
- @CacheName("BlackWhite")
- public class BlackWhiteDao {
-
- /**
- * 检查用户是否为黑名单用户
- * @param userid
- * @param cpid 为0时,表示所有CP有效
- * @return
- * @throws SQLException
- */
- @Cacheable(value="BlackWhite", key="#userid.concat(#cpid) + 'Black'")
- public boolean isBlackUser(String userid, String cpid) throws SQLException {
- String sql = "select count(userid) from TB_BLACKWHITE_LIST where userid=? and (cpid='0' or cpid=?) and type=1 AND (STATUS is null or STATUS = 0) ";
- return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql, userid, cpid), 0) > 0;
- }
-
- /**
- * 检查用户是否为白名单用户
- * @param userid
- * @param cpid 为0时,表示所有CP有效
- * @return
- * @throws SQLException
- */
- @Cacheable(value="BlackWhite", key="#userid.concat(#cpid) + 'White'")
- public boolean isWhiteUser(String userid, String cpid) throws SQLException {
- String sql = "select count(userid) from TB_BLACKWHITE_LIST where userid=? and (cpid='0' or cpid=?) and type=0 AND (STATUS is null or STATUS = 0)";
- return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql, userid, cpid), 0) > 0;
- }
-
- /**
- * 检查用户是否为黑名单用户
- * @param userid
- * @param cpid 为0时,表示所有CP有效
- * @param spid 为null时,表示所有SP有效
- * @return
- * @throws SQLException
- */
- @Cacheable(value="BlackWhite", key="#userid.concat(#spid) + 'Black'")
- public boolean isBlackUserBySpid(String userid,String cpid, String spid) throws SQLException {
- String sql = "select count(userid) from TB_BLACKWHITE_LIST where userid=? and (cpid='0' or cpid=?) AND (SPID IS NULL OR SPID = '0' OR SPID = ?) and type=1 AND (STATUS is null or STATUS = 0) ";
- return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql, userid, cpid, spid), 0) > 0;
- }
-
- /**
- * 检查用户是否为白名单用户
- * @param userid
- * @param cpid 为0时,表示所有CP有效
- * @param spid 为null时,表示所有SP有效
- * @return
- * @throws SQLException
- */
- @Cacheable(value="BlackWhite", key="#userid.concat(#spid) + 'White'")
- public boolean isWhiteUserBySpid(String userid, String cpid, String spid) throws SQLException {
- String sql = "select count(userid) from TB_BLACKWHITE_LIST where userid=? and (cpid='0' or cpid=?) AND (SPID IS NULL OR SPID = '0' OR SPID = ?) and type=0 AND (STATUS is null or STATUS = 0)";
- return NumberUtils.toInt(SQLExecutor.queryFieldWithDBName(DataSource.NET3G, sql, userid, cpid, spid), 0) > 0;
- }
- }
|