AnnouncementController.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Cksoft.Data;
  2. using Cksoft.Data.Repository;
  3. using DllEapDal;
  4. using DllEapEntity;
  5. using DllEapEntity.Dtos;
  6. using Microsoft.AspNetCore.Authorization;
  7. using Microsoft.AspNetCore.Mvc;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Text;
  11. namespace DllEapBll.OFILM
  12. {
  13. [Route("eap/api/[controller]/[action]")]
  14. [ApiController]
  15. [Authorize]
  16. public class AnnouncementController: ControllerBase
  17. {
  18. [HttpPost]
  19. public LayuiModel<string> Add(Announcement announcement)
  20. {
  21. using (IDatabase CurrDb = DbFactory.Base("eap"))
  22. {
  23. AnnouncementDal announcementDal = new AnnouncementDal(CurrDb);
  24. string i = "";
  25. if (announcement.id > 0)
  26. {
  27. i = announcementDal.Update(announcement);
  28. }
  29. else
  30. {
  31. i = announcementDal.Add(announcement);
  32. }
  33. LayuiModel<string> LayuiModel = new LayuiModel<string>();
  34. if (i == "新增成功" || i == "修改成功")
  35. {
  36. LayuiModel.code = 1;
  37. }
  38. else LayuiModel.code = 0;
  39. LayuiModel.msg = i;
  40. return LayuiModel;
  41. }
  42. }
  43. [HttpGet]
  44. public LayuiModel<Announcement> Get()
  45. {
  46. using (IDatabase CurrDb = DbFactory.Base("eapslave"))
  47. {
  48. AnnouncementDal announcementDal = new AnnouncementDal(CurrDb);
  49. var data = announcementDal.Get();
  50. LayuiModel<Announcement> LayuiModel = new LayuiModel<Announcement>();
  51. if (data == null)
  52. {
  53. LayuiModel.code = 1;
  54. LayuiModel.msg = "暂无数据";
  55. }
  56. else
  57. {
  58. LayuiModel.code = 1;
  59. LayuiModel.data = data;
  60. LayuiModel.count = 1;
  61. }
  62. return LayuiModel;
  63. }
  64. }
  65. }
  66. }