UserService.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using Central.Control.WebApi.Cache;
  2. using Central.Control.WebApi.DbEntity;
  3. using Central.Control.WebApi.Service.Interface;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Web;
  8. namespace Central.Control.WebApi.Service
  9. {
  10. /// <summary>
  11. ///
  12. /// </summary>
  13. public class UserService: IUserService
  14. {
  15. private readonly ICacheHelper _cacheHelper;
  16. /// <summary>
  17. ///
  18. /// </summary>
  19. /// <param name="cacheHelper"></param>
  20. public UserService(
  21. ICacheHelper cacheHelper)
  22. {
  23. _cacheHelper = cacheHelper;
  24. }
  25. /// <summary>
  26. /// 获取当前登录session
  27. /// </summary>
  28. /// <returns></returns>
  29. public SYS_LoginSession GetLoginSession()
  30. {
  31. string token = string.Empty;
  32. token = HttpContext.Current.Request.Headers.GetValues("token")?.FirstOrDefault();
  33. return _cacheHelper.Get<SYS_LoginSession>(token);
  34. }
  35. }
  36. }