AidopTenantBaselineController.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. namespace Admin.NET.Plugin.AiDOP.Infrastructure;
  2. /// <summary>
  3. /// 超管重跑租户基线。方法本身幂等,重复调用只补缺、不覆盖已有配置。
  4. /// 租户号必须由调用方显式传入,不取当前登录上下文,避免超管切了租户之后补错对象。
  5. /// </summary>
  6. [ApiDescriptionSettings(Order = 327, Description = "租户基线")]
  7. [Route("api/aidop/tenant-baseline")]
  8. public class AidopTenantBaselineController : IDynamicApiController, ITransient
  9. {
  10. private readonly AidopTenantInitService _init;
  11. private readonly UserManager _user;
  12. public AidopTenantBaselineController(AidopTenantInitService init, UserManager user)
  13. {
  14. _init = init;
  15. _user = user;
  16. }
  17. [DisplayName("超管:重跑租户基线")]
  18. [HttpPost("reinit")]
  19. public Task<AidopTenantBaselineResult> Reinit([FromBody] TenantBaselineReinitInput input)
  20. {
  21. if (!_user.SuperAdmin)
  22. throw Oops.Oh(ErrorCodeEnum.SA001);
  23. if (input == null || input.TenantId <= 0)
  24. throw Oops.Oh("必须指定租户");
  25. return _init.InitTenantBaselineAsync(input.TenantId);
  26. }
  27. }
  28. public sealed class TenantBaselineReinitInput
  29. {
  30. public long TenantId { get; set; }
  31. }