diff --git a/.idea/.idea.adminSystem/.idea/.gitignore b/.idea/.idea.adminSystem/.idea/.gitignore new file mode 100644 index 0000000..5f249b0 --- /dev/null +++ b/.idea/.idea.adminSystem/.idea/.gitignore @@ -0,0 +1,13 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# Rider 忽略的文件 +/.idea.adminSystem.iml +/projectSettingsUpdater.xml +/modules.xml +/contentModel.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.adminSystem/.idea/encodings.xml b/.idea/.idea.adminSystem/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.adminSystem/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.adminSystem/.idea/indexLayout.xml b/.idea/.idea.adminSystem/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.adminSystem/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/adminSystem.sln b/adminSystem.sln new file mode 100644 index 0000000..c80ce13 --- /dev/null +++ b/adminSystem.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "adminsystem.Data", "adminsystem.Data\adminsystem.Data.csproj", "{57D08EEE-9053-48EE-9630-89D4D13DB51E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "adminsystem.Entity", "adminsystem.Entity\adminsystem.Entity.csproj", "{DA74F76C-2CA2-4E28-A6C1-5A486AC27C4B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "adminsystem.Utils", "adminsystem.Utils\adminsystem.Utils.csproj", "{08F475BC-2FEB-400B-8529-0E044347C5B7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "adminsystem.Services", "adminsystem.Services\adminsystem.Services.csproj", "{FE857BFF-0707-4966-A934-41CCBA2E59A7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "adminsystem.Web", "adminsystem.Web\adminsystem.Web.csproj", "{07FADD95-4385-4CC3-9CB9-FFC896449790}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {57D08EEE-9053-48EE-9630-89D4D13DB51E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {57D08EEE-9053-48EE-9630-89D4D13DB51E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {57D08EEE-9053-48EE-9630-89D4D13DB51E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {57D08EEE-9053-48EE-9630-89D4D13DB51E}.Release|Any CPU.Build.0 = Release|Any CPU + {DA74F76C-2CA2-4E28-A6C1-5A486AC27C4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DA74F76C-2CA2-4E28-A6C1-5A486AC27C4B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DA74F76C-2CA2-4E28-A6C1-5A486AC27C4B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DA74F76C-2CA2-4E28-A6C1-5A486AC27C4B}.Release|Any CPU.Build.0 = Release|Any CPU + {08F475BC-2FEB-400B-8529-0E044347C5B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08F475BC-2FEB-400B-8529-0E044347C5B7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08F475BC-2FEB-400B-8529-0E044347C5B7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08F475BC-2FEB-400B-8529-0E044347C5B7}.Release|Any CPU.Build.0 = Release|Any CPU + {FE857BFF-0707-4966-A934-41CCBA2E59A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE857BFF-0707-4966-A934-41CCBA2E59A7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE857BFF-0707-4966-A934-41CCBA2E59A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE857BFF-0707-4966-A934-41CCBA2E59A7}.Release|Any CPU.Build.0 = Release|Any CPU + {07FADD95-4385-4CC3-9CB9-FFC896449790}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {07FADD95-4385-4CC3-9CB9-FFC896449790}.Debug|Any CPU.Build.0 = Debug|Any CPU + {07FADD95-4385-4CC3-9CB9-FFC896449790}.Release|Any CPU.ActiveCfg = Release|Any CPU + {07FADD95-4385-4CC3-9CB9-FFC896449790}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BA7F0CD2-6314-4163-9834-752894F0DA3F} + EndGlobalSection +EndGlobal diff --git a/adminsystem.Data/PostgreDbContext.cs b/adminsystem.Data/PostgreDbContext.cs new file mode 100644 index 0000000..5060d5d --- /dev/null +++ b/adminsystem.Data/PostgreDbContext.cs @@ -0,0 +1,26 @@ +using adminsystem.Entity; + +namespace adminsystem.Data; +using Microsoft.EntityFrameworkCore; +public class PostgreDbContext:DbContext +{ + public PostgreDbContext() + { + + } + public PostgreDbContext(DbContextOptions options):base(options) + { + + } + public DbSet Geodatas { get; set; } + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + base.OnConfiguring(optionsBuilder); + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + } + +} \ No newline at end of file diff --git a/adminsystem.Data/adminsystem.Data.csproj b/adminsystem.Data/adminsystem.Data.csproj new file mode 100644 index 0000000..9485742 --- /dev/null +++ b/adminsystem.Data/adminsystem.Data.csproj @@ -0,0 +1,19 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + + + diff --git a/adminsystem.Entity/Geodata.cs b/adminsystem.Entity/Geodata.cs new file mode 100644 index 0000000..aa94f16 --- /dev/null +++ b/adminsystem.Entity/Geodata.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations.Schema; +using NetTopologySuite.Geometries; + +namespace adminsystem.Entity; + +[Table("data2")] +public class Geodata +{ + /// + /// geodata attributes + /// + public int id { get; set; } + public string geom { get; set; } +} \ No newline at end of file diff --git a/adminsystem.Entity/PgDataBase.cs b/adminsystem.Entity/PgDataBase.cs new file mode 100644 index 0000000..a24e5d8 --- /dev/null +++ b/adminsystem.Entity/PgDataBase.cs @@ -0,0 +1,11 @@ +namespace adminsystem.Entity; + +public class PgDataBase +{ + public string Host { get; set; } + public string Port { get; set; } + public string Password { get; set; } + public string Username{ get; set; } + public string Database { get; set; } + public string Schema { get; set; } +} \ No newline at end of file diff --git a/adminsystem.Entity/adminsystem.Entity.csproj b/adminsystem.Entity/adminsystem.Entity.csproj new file mode 100644 index 0000000..b632fa0 --- /dev/null +++ b/adminsystem.Entity/adminsystem.Entity.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/adminsystem.Services/Class1.cs b/adminsystem.Services/Class1.cs new file mode 100644 index 0000000..501db2c --- /dev/null +++ b/adminsystem.Services/Class1.cs @@ -0,0 +1,6 @@ +namespace adminsystem.Services; + +public class Class1 +{ + +} diff --git a/adminsystem.Services/adminsystem.Services.csproj b/adminsystem.Services/adminsystem.Services.csproj new file mode 100644 index 0000000..53fbdd1 --- /dev/null +++ b/adminsystem.Services/adminsystem.Services.csproj @@ -0,0 +1,15 @@ + + + + net8.0 + enable + enable + + + + + + + + + diff --git a/adminsystem.Utils/JsonUtils.cs b/adminsystem.Utils/JsonUtils.cs new file mode 100644 index 0000000..630cf61 --- /dev/null +++ b/adminsystem.Utils/JsonUtils.cs @@ -0,0 +1,14 @@ +namespace adminsystem.Utils; +using Newtonsoft.Json; +using System.IO; +using Microsoft.Extensions.Configuration; +public static class JsonUtils +{ + public static T GetConfiguration(string configurationFilePath, string sectionName) + { + var json = File.ReadAllText(configurationFilePath); + dynamic jsonObj = JsonConvert.DeserializeObject(json); + var section = jsonObj[sectionName]; + return section.ToObject(); + } +} \ No newline at end of file diff --git a/adminsystem.Utils/adminsystem.Utils.csproj b/adminsystem.Utils/adminsystem.Utils.csproj new file mode 100644 index 0000000..8b7192a --- /dev/null +++ b/adminsystem.Utils/adminsystem.Utils.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + + + + + + + + diff --git a/adminsystem.Web/Controllers/Test.cs b/adminsystem.Web/Controllers/Test.cs new file mode 100644 index 0000000..6bdda6b --- /dev/null +++ b/adminsystem.Web/Controllers/Test.cs @@ -0,0 +1,38 @@ +using adminsystem.Data; +using adminsystem.Entity; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace adminsystem.Web.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class Test : ControllerBase + { + private PostgreDbContext _PostgreDbContext; + [HttpGet] + public string getstring() + { + return "helloworld"; + } + + public Test(PostgreDbContext postgreDbContext) + { + _PostgreDbContext = postgreDbContext; + } + + [HttpGet] + public async Task>> GetData() + { + var geodata = await _PostgreDbContext.Geodatas.ToListAsync(); + if (geodata == null) + { + return NotFound(); + } + + return geodata; + + } + } +} diff --git a/adminsystem.Web/Program.cs b/adminsystem.Web/Program.cs new file mode 100644 index 0000000..2f81f74 --- /dev/null +++ b/adminsystem.Web/Program.cs @@ -0,0 +1,31 @@ + +using adminsystem.Data; +using adminsystem.Entity; +using adminsystem.Utils; +using Microsoft.EntityFrameworkCore; +namespace adminsystem.Web { + public class Program { + public static void Main(string[] args) { + var builder = WebApplication.CreateBuilder(args); + var config = JsonUtils.GetConfiguration("application.json", "PostgreDb"); + var connectionString = $"Host={config.Host};Port={config.Port};Database={config.Database};Username={config.Username};Password={config.Password};"; + // 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.Services.AddDbContext(options => + options.UseNpgsql(connectionString)); + var app = builder.Build(); + // Configure the HTTP request pipeline. + if (app.Environment.IsDevelopment()) + { + app.UseSwagger(); + app.UseSwaggerUI(); + } + app.UseAuthorization(); + app.MapControllers(); + app.Run(); + } + } +} diff --git a/adminsystem.Web/Properties/launchSettings.json b/adminsystem.Web/Properties/launchSettings.json new file mode 100644 index 0000000..e3962e0 --- /dev/null +++ b/adminsystem.Web/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:48321", + "sslPort": 0 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:3000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/adminsystem.Web/adminsystem.Web.csproj b/adminsystem.Web/adminsystem.Web.csproj new file mode 100644 index 0000000..6122038 --- /dev/null +++ b/adminsystem.Web/adminsystem.Web.csproj @@ -0,0 +1,24 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + + + + + + + + diff --git a/adminsystem.Web/adminsystem.Web.http b/adminsystem.Web/adminsystem.Web.http new file mode 100644 index 0000000..b070562 --- /dev/null +++ b/adminsystem.Web/adminsystem.Web.http @@ -0,0 +1,5 @@ +@adminsystem.Web_HostAddress = http://localhost:3000 + + + +### diff --git a/adminsystem.Web/application.json b/adminsystem.Web/application.json new file mode 100644 index 0000000..ba79523 --- /dev/null +++ b/adminsystem.Web/application.json @@ -0,0 +1,10 @@ +{ + "PostgreDb": { + "Host": "123.249.39.101", + "Port": "5432", + "Username": "postgres", + "Password": "dujunming520", + "Database": "postgres", + "Schema": "public" + } +} \ No newline at end of file diff --git a/adminsystem.Web/appsettings.Development.json b/adminsystem.Web/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/adminsystem.Web/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/adminsystem.Web/appsettings.json b/adminsystem.Web/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/adminsystem.Web/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}