45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using Api.Framework;
|
|
using Api.Framework.Tools;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using 监听违规.Entitys;
|
|
|
|
namespace 监听违规
|
|
{
|
|
public class Common
|
|
{
|
|
private static List<UserLists_db> WhiteUserListsCache = null;
|
|
|
|
public static void FlushWhiteUserListsCache(bool flush = false)
|
|
{
|
|
if (flush || WhiteUserListsCache == null)
|
|
{
|
|
var db = ApiClient.GetSession();
|
|
WhiteUserListsCache = db.Queryable<UserLists_db>().Where(f => f.user_type == UserType.白名单).ToList();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 判断是否是白名单
|
|
/// </summary>
|
|
/// <param name="username"></param>
|
|
/// <returns></returns>
|
|
public static bool IsWhite(string username)
|
|
{
|
|
try
|
|
{
|
|
if (WhiteUserListsCache == null) FlushWhiteUserListsCache();
|
|
var user = WhiteUserListsCache.FirstOrDefault(f => f.wxid == username);
|
|
return user != null;
|
|
}
|
|
catch (Exception ex)
|
|
{ }
|
|
return false;
|
|
}
|
|
|
|
}
|
|
}
|