Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

LuAuthCrudController.cs 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.ComponentModel.DataAnnotations;
  2. using Luticate2.Utils.Dbo.Basic;
  3. using Luticate2.Utils.Dbo.PaginatedRequest;
  4. using Luticate2.Utils.Interfaces;
  5. using Luticate2.Utils.Utils;
  6. using Microsoft.AspNetCore.Mvc;
  7. using Microsoft.Extensions.Options;
  8. namespace Luticate2.Auth.Controllers
  9. {
  10. public abstract class LuAuthCrudController<TBusiness, TDboCreate, TDboRead, TDboUpdate, TId> : LuAuthController
  11. where TDboCreate : class
  12. where TDboRead : class
  13. where TDboUpdate : class
  14. where TBusiness : ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId>
  15. {
  16. protected readonly TBusiness Busines;
  17. protected LuAuthCrudController(TBusiness busines, IOptions<LuUtilsOptionsDbo> luUtilsOptionsDbo) : base(luUtilsOptionsDbo)
  18. {
  19. Busines = busines;
  20. }
  21. [HttpGet("[controller]/{id}")]
  22. public virtual LuApiWrapperDbo<TDboRead> GetSingleById([Required]TId id)
  23. {
  24. return Handle(Busines.GetSingleById(id));
  25. }
  26. [HttpGet("[controller]")]
  27. public virtual LuApiWrapperDbo<LuPaginatedDbo<TDboRead>> GetMultiple([Required]LuPaginatedRequestDbo request)
  28. {
  29. return Handle(Busines.GetMultiple(request));
  30. }
  31. [HttpPost("[controller]")]
  32. public virtual LuApiWrapperDbo<TDboRead> AddDbo([FromBody][Required]TDboCreate data)
  33. {
  34. return Handle(Busines.AddDbo(data));
  35. }
  36. [HttpPost("[controller]/{id}")]
  37. public virtual LuApiWrapperDbo<TDboRead> EditSingleByIdDbo([Required]TId id, [FromBody][Required]TDboUpdate data)
  38. {
  39. return Handle(Busines.EditSingleByIdDbo(id, data));
  40. }
  41. [HttpDelete("[controller]/{id}")]
  42. public virtual LuApiWrapperDbo<TDboRead> Delete([Required]TId id)
  43. {
  44. return Handle(Busines.DeleteSingleByIdDbo(id));
  45. }
  46. }
  47. }