using Nirvana.Data; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using YBDevice.Entity; namespace YBDevice.NApi.DBServices { /// /// 微信开放平台openticket配置 /// public partial class OpenWXConfigApp : Repository { /// /// 获取openticket /// /// /// public static async Task GetOpenTicketAsync(string componentAppId) { using (var dbClient = ReadDbContext.GetInstance()) { var component = await dbClient.Queryable().Where(x => x.ComponentAppId == componentAppId).FirstAsync(); return component?.OpenTicket; } } /// /// 获取公众号的刷新token /// /// 公众号appid /// 开放平台appid /// public async Task GetRefreshToken(string authorizerId, string componentAppId) { using (var dbClient = ReadDbContext.GetInstance()) { try { var data = await dbClient.Queryable().FirstAsync(x => x.authorizer_appid == authorizerId && x.componentappid == componentAppId); if (data != null) { return data.authorizer_refresh_token; } return ""; } catch (Exception ex) { var errmsg = $"authorizerid={authorizerId},componentAppid={componentAppId}"; new LoggerApp().InsertErrorLog(ex, errmsg, "获取公众号的刷新token"); return ""; } } } } }