123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using Hotline.Caching.Interfaces;
- using Hotline.Configurations;
- using Hotline.Settings;
- using Microsoft.Extensions.Options;
- using Newtonsoft.Json;
- using XF.Domain.Authentications;
- namespace Hotline.Authentications
- {
- public class ProvinceSessionContext : ISessionContext
- {
- public const string Key = "ProvinceSessionContext";
- public ProvinceSessionContext(ISystemSettingCacheManager systemSettingCacheManager)
- {
- var setting = systemSettingCacheManager.GetSetting(SettingConstants.CityBaseConfiguration)?.SettingValue[0];
- var cityBase = JsonConvert.DeserializeObject<CityBaseConfiguration>(setting);
- var config = cityBase.CityProvince;
- UserId = config.UserId;
- UserName = config.UserName;
- OrgId = config.OrgId;
- OrgName = config.OrgName;
- OrgLevel = 1;
- }
- //取消写入
- /// <summary>
- /// Id of current tenant or null for host
- /// </summary>
- public string? UserId { get; init; }
- /// <summary>
- /// Id of current user or throw Exception for guest
- /// </summary>
- /// <exception cref="AuthenticationException"></exception>
- public string RequiredUserId => UserId ?? throw new ArgumentNullException();
- //取消写入
- public string? UserName { get; init; }
- public string? Phone { get; init; }
- /// <summary>
- /// Roles
- /// </summary>
- public string[] Roles { get; init; }
- public string? OrgId { get; init; }
- public string RequiredOrgId => OrgId ?? throw new ArgumentNullException();
- public string? OrgName { get; init; }
- public int OrgLevel { get; init; }
- public string? OrgAreaCode { get; init; }
- public bool OrgIsCenter { get; init; }
- /// <summary>
- /// 部门行政区划名称
- /// </summary>
- public string? OrgAreaName { get; init; }
- public string? AreaId { get; init; }
- public string? ClientId { get; init; }
- /// <summary>
- /// 工号
- /// </summary>
- public string? StaffNo { get; init; }
- /// <summary>
- /// 第三方平台用户唯一标识
- /// 例如: 微信的OpenId
- /// </summary>
- public string? OpenId { get; init; }
- public void ChangeSession(string id)
- {
- throw new NotImplementedException();
- }
- public async Task ChangeSessionAsync(string userId, CancellationToken cancellation)
- {
- throw new NotImplementedException();
- }
- }
- }
|