鼎鼎知识库
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

总部运营后台后端处理.md 4.1KB

před 3 roky
před 3 roky
před 3 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # 模块和项目解除绑定
  2. 模块和项目的绑定和解绑原理,已经在【总部运营后台运作原理】中说明,这里主要讲后端如何处理。
  3. > 目前的问题是:在总部运营后台,解除项目和模块的绑定关系之后,在总部管理后台和开放平台的数据库都作了相应的处理。但,在项目数据库,并没有处理。这样导致与项目解除绑定的模块,仍然可以在项目库数据库中存在,在`APP`上被看到。
  4. 解决思路是:当在总部运营后台,解除项目和模块关系的那一刻,在现在的处理逻辑上再加上:把项目数据库的模块和线路标记为物理删除。在办公楼版中,需要把`macs`、`breakers`、`breakerdatas`中的相关模块或线路设置为物理删除。然后在显示的时候,把标记为逻辑删除的模块和线路排除。
  5. 具体步骤大致是:
  6. 1. 总部运营后台根据`ProjectId`获取办公楼版的上下文。
  7. 2. 再获取办公楼版的某个仓储
  8. 类似如下:
  9. ```
  10. public class TestRequestHandler : IRequestHandler<TestRequest, DDResponseWrapper<TestRequestDto>>
  11. {
  12. private readonly DDOfficeDbHelper _officeHelper;//获取办公楼版上下文的帮助类
  13. private ICompanyRepository _companyRepo;//办公楼版的某个仓储
  14. public TestRequestHandler(DDOfficeDbHelper officeHelper)
  15. {
  16. _officeHelper = officeHelper;
  17. }
  18. public async Task<DDResponseWrapper<TestRequestDto>> Handle(TestRequest request, CancellationToken cancellationToken)
  19. {
  20. var result = new DDResponseWrapper<TestRequestDto>();
  21. var dto = new TestRequestDto();
  22. var ef = await _officeHelper.GetOfficeContextByProjectIdAsync("4");//根据ProjectId获取办公楼版的上下文
  23. _companyRepo = new CompanyRepository(ef);//实例化办公楼版的某个仓储
  24. var company = _companyRepo.GetAll().FirstOrDefault();
  25. dto.Message = company.Name;
  26. result.data = dto;
  27. return await Task.FromResult(result);
  28. }
  29. }
  30. public class TestRequest : IRequest<DDResponseWrapper<TestRequestDto>>
  31. {
  32. }
  33. public class TestRequestDto
  34. {
  35. public string Message { get; set; }
  36. }
  37. ```
  38. 基础设施层的版本如下:
  39. ```
  40. DD.Libs 1.0.93
  41. DD.Infra1.0.74
  42. ```
  43. 办公楼版有哪些仓储呢?
  44. ```
  45. services.AddScoped<ICompanyRepository, CompanyRepository>();
  46. services.AddScoped<ICompanyUserRepository, CompanyUserRepository>();
  47. services.AddScoped<IElectricBoxRepository, ElectricBoxRepository>();
  48. services.AddScoped<IMacRepository, MacRepository>();
  49. services.AddScoped<IBreakerRepository, BreakerRepository>();
  50. services.AddScoped<ILocationRepository, LocationRepository>();
  51. services.AddScoped<IOperationRepository, OperationRepository>();
  52. services.AddScoped<IDateJobRepository, DateJobRepository>();
  53. services.AddScoped<IJobRepository, JobRepository>();
  54. services.AddScoped<IJobBreakerRepository, JobBreakerRepository>();
  55. services.AddScoped<IProjectSettingRepository, ProjectSettingRepository>();
  56. services.AddScoped<IPowerRepository, PowerRepository>();
  57. services.AddScoped<IRealWarningRepository, RealWarningRepository>();
  58. services.AddScoped<IRealWarningDataRepository, RealWarningDataRepository>();
  59. services.AddScoped<IWarningHistoryRepository, WarningHistoryRepository>();
  60. services.AddScoped<IWarningHistoryDataRepository, WarningHistoryDataRepository>();
  61. services.AddScoped<IBreakerDataRepository, BreakerDataRepository>();
  62. services.AddScoped<INotiRepository, NotiRepository>();
  63. services.AddScoped<ITestPowerRepository, TestPowerRepository>();
  64. services.AddScoped<IBreakerWarningPolicyRepository, BreakerWarningPolicyRepository>();
  65. services.AddScoped<IMockBreakerDataRepository, MockBreakerDataRepository>();
  66. services.AddScoped<IElectricFeeRepository, ElectricFeeRepository>();
  67. ```
  68. 逻辑删除调用哪个方法?在`Mac`, `Breaker`, `BreakerData`领域实体中都定义了`LogicDel`方法。当`IsLogicDel=1`表示逻辑删除,当`IsLogicDel=0`表示正常显示。
  69. ```
  70. /// <summary>
  71. /// 逻辑删除
  72. /// </summary>
  73. public void LogicDel()
  74. {
  75. IsLogicDel = CommonConstants.LogicDelYes;
  76. }
  77. ```