ZzptSessionContext.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 ZzptSessionContext : ISessionContext
  9. {
  10. public const string Key = "ZzptSessionContext";
  11. public ZzptSessionContext(ISystemSettingCacheManager systemSettingCacheManager)
  12. {
  13. var setting = systemSettingCacheManager.GetSetting(SettingConstants.CityBaseConfiguration)?.SettingValue[0];
  14. var cityBase = JsonConvert.DeserializeObject<CityBaseConfiguration>(setting);
  15. var config = cityBase.ComprehensiveTreatment;
  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. public void ChangeSession(string id)
  58. {
  59. throw new NotImplementedException();
  60. }
  61. public async Task ChangeSessionAsync(string userId, CancellationToken cancellation)
  62. {
  63. throw new NotImplementedException();
  64. }
  65. }
  66. }