old_flsystem/应用/监听违规/Common.cs

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;
}
}
}