CurrentSysUserInfo.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using YBEE.EQM.Core;
  2. namespace YBEE.EQM.Application;
  3. /// <summary>
  4. /// 当前用户
  5. /// </summary>
  6. public class CurrentSysUserInfo
  7. {
  8. /// <summary>
  9. /// 用户ID
  10. /// </summary>
  11. public static int SysUserId
  12. {
  13. get
  14. {
  15. if (int.TryParse(App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value, out int uid))
  16. {
  17. return uid;
  18. }
  19. return 0;
  20. }
  21. }
  22. /// <summary>
  23. /// 机构ID
  24. /// </summary>
  25. public static short SysOrgId
  26. {
  27. get
  28. {
  29. if (short.TryParse(App.User.FindFirst(ClaimConst.CLAINM_ORGID)?.Value, out short oid))
  30. {
  31. return oid;
  32. }
  33. return 0;
  34. }
  35. }
  36. /// <summary>
  37. /// 机构名称
  38. /// </summary>
  39. public static string SysOrgName => App.User.FindFirst(ClaimConst.CLAINM_ORGNAME)?.Value;
  40. /// <summary>
  41. /// 账号
  42. /// </summary>
  43. public static string Account => App.User.FindFirst(ClaimConst.CLAINM_ACCOUNT)?.Value;
  44. /// <summary>
  45. /// 名称
  46. /// </summary>
  47. public static string Name => App.User.FindFirst(ClaimConst.CLAINM_NAME)?.Value;
  48. /// <summary>
  49. /// 是否超级管理员
  50. /// </summary>
  51. public static bool IsSuperAdmin
  52. {
  53. get
  54. {
  55. if (bool.TryParse(App.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value ?? "False", out bool isSuperAdmin))
  56. {
  57. return isSuperAdmin;
  58. }
  59. return false;
  60. }
  61. }
  62. }