ServiceCollectionExtensions.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using Fw.Utility.UnifyResponse;
  2. using Hotline.CallCenter.Tels;
  3. using Hotline.XingTang.Dto;
  4. using Microsoft.AspNetCore.Builder;
  5. using Microsoft.AspNetCore.Http;
  6. using Microsoft.Extensions.DependencyInjection;
  7. using NPOI.SS.Formula.Functions;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using static System.Runtime.InteropServices.JavaScript.JSType;
  14. namespace Hotline.XingTang;
  15. public static class ServiceCollectionExtensions
  16. {
  17. public static IServiceCollection AddXingTangSDK(this IServiceCollection services)
  18. {
  19. services.AddScoped<ICallTelClient, CallTelClient>();
  20. services.AddScoped<INotifyService, NotifyService>();
  21. return services;
  22. }
  23. public static void UseXingTangApiEndpoints(this WebApplication app)
  24. {
  25. // 注册 POST 接口
  26. app.MapPost("/api/v1/XingTang/notify/status", async (INotifyService service, HttpContext context) =>
  27. {
  28. var input = await context.Request.ReadFromJsonAsync<NotifyInDto>();
  29. await service.NotifyStatus(input!);
  30. return Results.Ok(new ApiResponse(0, "ok", ""));
  31. });
  32. }
  33. }