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.

LuController.cs 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using Luticate2.Utils.Dbo;
  5. using Luticate2.Utils.Dbo.Basic;
  6. using Luticate2.Utils.Dbo.Result;
  7. using Microsoft.AspNetCore.Mvc;
  8. using Microsoft.AspNetCore.SignalR.Infrastructure;
  9. namespace Luticate2.Utils.Controllers
  10. {
  11. public abstract class LuController : Controller
  12. {
  13. protected IConnectionManager ConnectionManager { get; set; }
  14. protected IDictionary<object, object> LuItems => HttpContext.GetLuItems();
  15. protected LuApiWrapperDbo<T> Handle<T>(LuResult<T> result)
  16. {
  17. if (result)
  18. {
  19. return new LuApiWrapperDbo<T>
  20. {
  21. code = 200,
  22. data = result.Data,
  23. message = null,
  24. Version = LuUtilsExtensions.Options.Version
  25. };
  26. }
  27. throw new LuResultException(result.To<object>());
  28. }
  29. protected LuApiWrapperDbo<LuBoxedValueDbo<T>> HandleBoxed<T>(LuResult<T> result)
  30. {
  31. return Handle(result.To(arg => new LuBoxedValueDbo<T>
  32. {
  33. Value = arg
  34. }));
  35. }
  36. }
  37. }