xf 1 year ago
parent
commit
16e014482c

+ 48 - 29
src/FileStorage.Host/Program.cs

@@ -1,30 +1,49 @@
-using FileHandlers;
 using FileStorage.Host;
-
-var builder = WebApplication.CreateBuilder(args);
-
-// Add services to the container.
-
-builder.Services.AddControllers();
-// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
-builder.Services.AddEndpointsApiExplorer();
-builder.Services.AddSwaggerGen();
-
-builder.ConfigureServices().ConfigurePipelines().Run();
-
-
-
-//var app = builder.Build();
-
-//// Configure the HTTP request pipeline.
-//if (app.Environment.IsDevelopment())
-//{
-//    app.UseSwagger();
-//    app.UseSwaggerUI();
-//}
-
-//app.UseAuthorization();
-
-//app.MapControllers();
-
-//app.Run();
+using Serilog;
+
+Log.Logger = new LoggerConfiguration()
+    .WriteTo.Console()
+    .CreateBootstrapLogger();
+
+Log.Information("FileStorage service is Starting up");
+
+try
+{
+    var builder = WebApplication.CreateBuilder(args);
+
+    builder.Host
+        .ConfigureAppConfiguration((hostBuilderContext, configBuilder) =>
+        {
+            var path = Path.Combine(Directory.GetCurrentDirectory(), "config");
+            configBuilder.SetBasePath(path)
+#if DEBUG
+                .AddJsonFile("appsettings.shared.Development.json", true, true)
+#else
+                .AddJsonFile("appsettings.shared.json", true, true)
+#endif
+                .AddJsonFile("appsettings.json", false, true)
+                .AddJsonFile($"appsettings.{hostBuilderContext.HostingEnvironment.EnvironmentName}.json", true, true)
+                .AddEnvironmentVariables()
+                .AddCommandLine(args)
+                ;
+        })
+        .UseSerilog((ctx, lc) => lc
+            //.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}")
+            .Enrich.FromLogContext()
+            .ReadFrom.Configuration(ctx.Configuration))
+        ;
+
+    builder
+        .ConfigureServices()
+        .ConfigurePipelines()
+        .Run();
+}
+catch (Exception ex)
+{
+    Log.Fatal(ex, "Unhandled exception");
+}
+finally
+{
+    Log.Information("Shut down complete");
+    Log.CloseAndFlush();
+}

+ 1 - 17
src/FileStorage.Host/Properties/launchSettings.json

@@ -1,28 +1,12 @@
 {
   "$schema": "https://json.schemastore.org/launchsettings.json",
-  "iisSettings": {
-    "windowsAuthentication": false,
-    "anonymousAuthentication": true,
-    "iisExpress": {
-      "applicationUrl": "http://localhost:42489",
-      "sslPort": 0
-    }
-  },
   "profiles": {
     "http": {
       "commandName": "Project",
       "dotnetRunMessages": true,
       "launchBrowser": true,
       "launchUrl": "swagger",
-      "applicationUrl": "http://localhost:5238",
-      "environmentVariables": {
-        "ASPNETCORE_ENVIRONMENT": "Development"
-      }
-    },
-    "IIS Express": {
-      "commandName": "IISExpress",
-      "launchBrowser": true,
-      "launchUrl": "swagger",
+      "applicationUrl": "http://localhost:50102",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }

+ 1 - 1
src/FileStorage.Host/StartupExtensions.cs

@@ -65,7 +65,7 @@ internal static class StartupExtensions
         //});
         
         //sqlsugar
-        services.AddSqlSugar(configuration, "FileStorage");
+        services.AddSqlSugar(configuration);
         ////cache
         //services.AddCache(d =>
         //    {

+ 0 - 33
src/FileStorage.Host/appsettings.Development.json

@@ -1,33 +0,0 @@
-{
-  "Logging": {
-    "LogLevel": {
-      "Default": "Information",
-      "Microsoft.AspNetCore": "Warning"
-    }
-  },
-  "AllowedHosts": "123123",
-  "ConnectionStrings": {
-    "CallCenter": "server=110.188.24.182:5432;Database=fileDb;Uid=dev;Pwd=fengwo11!!;SslMode=none;",
-    "Redis": "110.188.24.182"
-  },
-  "FileUploadOptions": {
-    "SaveFileMode": "Local", //上传文件的保存方式,可选Database,local,oss
-    "Settings": {
-      "local": [
-        {
-          "GroupName": "default",
-          "GroupLocation": ""
-        }
-      ],
-      "oss": [
-        {
-          "GroupName": "default",
-          "GroupLocation": "",
-          "ServerUrl": "",
-          "Key": "",
-          "Secret": ""
-        }
-      ]
-    }
-  }
-}

+ 0 - 33
src/FileStorage.Host/appsettings.json

@@ -1,33 +0,0 @@
-{
-  "Logging": {
-    "LogLevel": {
-      "Default": "Information",
-      "Microsoft.AspNetCore": "Warning"
-    }
-  },
-  "AllowedHosts": "*",
-  "ConnectionStrings": {
-    "CallCenter": "server=110.188.24.182:5432;Database=fileDb;Uid=dev;Pwd=fengwo11!!;SslMode=none;",
-    "Redis": "110.188.24.182"
-  },
-  "FileUploadOptions": {
-    "SaveFileMode": "Local", //上传文件的保存方式,可选Database,local,oss
-    "Settings": {
-      "local": [
-        {
-          "GroupName": "default",
-          "GroupLocation": ""
-        }
-      ],
-      "oss": [
-        {
-          "GroupName": "default",
-          "GroupLocation": "",
-          "ServerUrl": "",
-          "Key": "",
-          "Secret": ""
-        }
-      ]
-    }
-  }
-}

+ 8 - 2
src/FileStorage.Host/config/appsettings.Development.json

@@ -1,7 +1,7 @@
 {
   "AllowedHosts": "*",
   "ConnectionStrings": {
-    "Hotline": "PORT=5432;DATABASE=file;HOST=110.188.24.182;PASSWORD=fengwo11!!;USER ID=dev;",
+    "Hotline": "PORT=5432;DATABASE=filestorage;HOST=110.188.24.182;PASSWORD=fengwo11!!;USER ID=dev;",
     "Redis": "110.188.24.182",
     "MongoDB": "mongodb://192.168.100.121:27017"
   },
@@ -16,7 +16,13 @@
   "StorageConfiguration": {
     "Impt": "",
     "Local": {
-      "Path": "",
+      "Path": ""
+    },
+    "Aliyun": {
+
+    },
+    "Ctyun": {
+
     }
   }
 }

+ 1 - 1
src/FileStorage.Repository.SqlSugar/Extensions/SqlSugarStartupExtensions.cs

@@ -16,7 +16,7 @@ namespace FileStorage.Repository.SqlSugar.Extensions
 {
     public static class SqlSugarStartupExtensions
     {
-        public static void AddSqlSugar(this IServiceCollection services, IConfiguration configuration, string dbName = "Hotline")
+        public static void AddSqlSugar(this IServiceCollection services, IConfiguration configuration, string dbName = "filestorage")
         {
             //多租户 new SqlSugarScope(List<ConnectionConfig>,db=>{});
 

+ 3 - 0
src/FileStorage/IFileStorage.cs

@@ -19,5 +19,8 @@
         DateTime UploadTime { get; set; }
 
         string GetID();
+
+
+        //string Upload(//...);
     }
 }