選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

LuCrudController.cs 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using Luticate2.Utils.Dbo;
  2. using Luticate2.Utils.Dbo.Basic;
  3. using Luticate2.Utils.Dbo.OrderBy;
  4. using Luticate2.Utils.Interfaces;
  5. using Microsoft.AspNetCore.Mvc;
  6. namespace Luticate2.Utils.Controllers
  7. {
  8. public abstract class LuCrudController<TBusiness, TDboCreate, TDboRead, TDboUpdate> : LuController
  9. where TDboCreate : class
  10. where TDboRead : class
  11. where TDboUpdate : class
  12. where TBusiness : ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate>
  13. {
  14. protected readonly TBusiness Busines;
  15. protected LuCrudController(TBusiness busines)
  16. {
  17. Busines = busines;
  18. }
  19. [HttpGet]
  20. [Route("[controller]/{id}")]
  21. public LuApiWrapperDbo<TDboRead> GetSingleById(string id)
  22. {
  23. return Handle(Busines.GetSingleById(id));
  24. }
  25. [HttpGet]
  26. [Route("[controller]")]
  27. public LuApiWrapperDbo<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, int page = 0, int perPage = int.MaxValue)
  28. {
  29. return Handle(Busines.GetMultiple(orderBy, page, perPage));
  30. }
  31. [HttpPost]
  32. [Route("[controller]")]
  33. public LuApiWrapperDbo<TDboRead> Add([FromBody]TDboCreate data)
  34. {
  35. return Handle(Busines.AddDbo(data));
  36. }
  37. [HttpPost]
  38. [Route("[controller]/{id}")]
  39. public LuApiWrapperDbo<TDboRead> Edit(string id, [FromBody]TDboUpdate data)
  40. {
  41. return Handle(Busines.EditSingleByIdDbo(id, data));
  42. }
  43. [HttpDelete]
  44. [Route("[controller]/{id}")]
  45. public LuApiWrapperDbo<TDboRead> Delete(string id)
  46. {
  47. return Handle(Busines.DeleteSingleByIdDbo(id));
  48. }
  49. }
  50. }