基础服务api
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

62 lines
1.9 KiB

  1. using BPA.SAAS.Manage.Application.System.Dtos;
  2. using BPA.SAAS.Manage.Core;
  3. using FluentValidation.AspNetCore;
  4. using Furion;
  5. using Microsoft.AspNetCore.Builder;
  6. using Microsoft.AspNetCore.Hosting;
  7. using Microsoft.Extensions.DependencyInjection;
  8. using Microsoft.Extensions.Hosting;
  9. using Newtonsoft.Json;
  10. namespace BPA.SAAS.Manage.Web.Core
  11. {
  12. public class Startup : AppStartup
  13. {
  14. public void ConfigureServices(IServiceCollection services)
  15. {
  16. services.AddConsoleFormatter();
  17. services.AddJwt<JwtHandler>();
  18. CosConfig.cosInfoOptions = new CosInfoOptions(App.Configuration["cos_config:AppId"],
  19. App.Configuration["cos_config:Region"], App.Configuration["cos_config:Bucket"],
  20. App.Configuration["cos_config:SecretId"], App.Configuration["cos_config:SecretKey"]);
  21. services.AddControllersWithViews()
  22. .AddFluentValidation(fv =>
  23. {
  24. fv.RegisterValidatorsFromAssemblies(App.Assemblies);
  25. })
  26. .AddNewtonsoftJson(options =>
  27. {
  28. options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
  29. options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
  30. });
  31. services.AddCorsAccessor();
  32. services.AddSqlsugarSetup(App.Configuration);
  33. services.AddControllers()
  34. .AddInjectWithUnifyResult();
  35. }
  36. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  37. {
  38. if (env.IsDevelopment())
  39. {
  40. app.UseDeveloperExceptionPage();
  41. }
  42. app.UseHttpsRedirection();
  43. app.UseRouting();
  44. app.UseCorsAccessor();
  45. app.UseAuthentication();
  46. app.UseAuthorization();
  47. app.UseInject(string.Empty);
  48. app.UseEndpoints(endpoints =>
  49. {
  50. endpoints.MapControllers();
  51. });
  52. }
  53. }
  54. }