平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserManager.cs 1.4 KiB

4 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. 
  2. //
  3. namespace SafeCampus.System;
  4. /// <summary>
  5. /// 当前登录用户信息
  6. /// </summary>
  7. public class UserManager
  8. {
  9. /// <summary>
  10. /// 当前用户Id
  11. /// </summary>
  12. public static long UserId
  13. {
  14. get
  15. {
  16. return (App.User?.FindFirst(ClaimConst.USER_ID)?.Value).ToLong();
  17. }
  18. }
  19. /// <summary>
  20. /// 当前用户账号
  21. /// </summary>
  22. public static string UserAccount
  23. {
  24. get
  25. {
  26. return App.User?.FindFirst(ClaimConst.ACCOUNT)?.Value;
  27. }
  28. }
  29. /// <summary>
  30. /// 当前用户昵称
  31. /// </summary>
  32. public static string Name
  33. {
  34. get
  35. {
  36. return App.User?.FindFirst(ClaimConst.NAME)?.Value;
  37. }
  38. }
  39. /// <summary>
  40. /// 是否超级管理员
  41. /// </summary>
  42. public static bool SuperAdmin
  43. {
  44. get
  45. {
  46. return (App.User?.FindFirst(ClaimConst.IS_SUPER_ADMIN)?.Value).ToBoolean();
  47. }
  48. }
  49. /// <summary>
  50. /// 机构ID
  51. /// </summary>
  52. public static long OrgId
  53. {
  54. get
  55. {
  56. return (App.User?.FindFirst(ClaimConst.ORG_ID)?.Value).ToLong();
  57. }
  58. }
  59. public static long? TenantId
  60. {
  61. get
  62. {
  63. //如果有租户ID则返回租户ID,否则返回null
  64. return (App.User?.FindFirst(ClaimConst.TENANT_ID)?.Value).ToLong();
  65. }
  66. }
  67. }