Police110SessionContext.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using Hotline.Caching.Interfaces;
  2. using Hotline.Configurations;
  3. using Hotline.Settings;
  4. using Newtonsoft.Json;
  5. using XF.Domain.Authentications;
  6. namespace Hotline.Authentications
  7. {
  8. public class Police110SessionContext : ISessionContext
  9. {
  10. public const string Key = "Police110SessionContext";
  11. public Police110SessionContext(ISystemSettingCacheManager systemSettingCacheManager)
  12. {
  13. var setting = systemSettingCacheManager.GetSetting(SettingConstants.CityBaseConfiguration)?.SettingValue[0];
  14. var cityBase = JsonConvert.DeserializeObject<CityBaseConfiguration>(setting);
  15. var config = cityBase.PublicSecurity;
  16. UserId = config.UserId;
  17. UserName = config.UserName;
  18. OrgId = config.OrgId;
  19. OrgName = config.OrgName;
  20. OrgLevel = 1;
  21. }
  22. /// <summary>
  23. /// Id of current tenant or null for host
  24. /// </summary>
  25. public string? UserId { get; init; }
  26. /// <summary>
  27. /// Id of current user or throw Exception for guest
  28. /// </summary>
  29. public string RequiredUserId => UserId ?? throw new ArgumentNullException();
  30. public string? UserName { get; init; }
  31. public string? Phone { get; init; }
  32. /// <summary>
  33. /// Roles
  34. /// </summary>
  35. public string[] Roles { get; init; }
  36. public string? OrgId { get; init; }
  37. public string RequiredOrgId => OrgId ?? throw new ArgumentNullException();
  38. public string? OrgName { get; init; }
  39. public int OrgLevel { get; init; }
  40. public string? OrgAreaCode { get; init; }
  41. public bool OrgIsCenter { get; init; }
  42. /// <summary>
  43. /// 部门行政区划名称
  44. /// </summary>
  45. public string? OrgAreaName { get; init; }
  46. public string? AreaId { get; init; }
  47. public string? ClientId { get; init; }
  48. /// <summary>
  49. /// 工号
  50. /// </summary>
  51. public string? StaffNo { get; init; }
  52. /// <summary>
  53. /// 第三方平台用户唯一标识
  54. /// 例如: 微信的OpenId
  55. /// </summary>
  56. public string? OpenId { get; init; }
  57. }
  58. }