添加项目文件。

This commit is contained in:
Klein 2024-05-10 11:47:35 +08:00
parent 8f01f8c1da
commit e2bba55fd4
21 changed files with 362 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

49
adminSystem.sln Normal file
View File

@ -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

View File

@ -0,0 +1,26 @@
using adminsystem.Entity;
namespace adminsystem.Data;
using Microsoft.EntityFrameworkCore;
public class PostgreDbContext:DbContext
{
public PostgreDbContext()
{
}
public PostgreDbContext(DbContextOptions<PostgreDbContext> options):base(options)
{
}
public DbSet<Geodata> Geodatas { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\adminsystem.Entity\adminsystem.Entity.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0-preview.3.24172.4" />
<PackageReference Include="Npgsql" Version="8.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.0-preview.3" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations.Schema;
using NetTopologySuite.Geometries;
namespace adminsystem.Entity;
[Table("data2")]
public class Geodata
{
/// <summary>
/// geodata attributes
/// </summary>
public int id { get; set; }
public string geom { get; set; }
}

View File

@ -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; }
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NetTopologySuite" Version="2.5.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,6 @@
namespace adminsystem.Services;
public class Class1
{
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\adminsystem.Data\adminsystem.Data.csproj" />
<ProjectReference Include="..\adminsystem.Entity\adminsystem.Entity.csproj" />
<ProjectReference Include="..\adminsystem.Utils\adminsystem.Utils.csproj" />
</ItemGroup>
</Project>

View File

@ -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<T>(string configurationFilePath, string sectionName)
{
var json = File.ReadAllText(configurationFilePath);
dynamic jsonObj = JsonConvert.DeserializeObject(json);
var section = jsonObj[sectionName];
return section.ToObject<T>();
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0-preview.3.24172.9" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>

View File

@ -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<ActionResult<IEnumerable<Geodata>>> GetData()
{
var geodata = await _PostgreDbContext.Geodatas.ToListAsync();
if (geodata == null)
{
return NotFound();
}
return geodata;
}
}
}

View File

@ -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<PgDataBase>("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<PostgreDbContext>(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();
}
}
}

View File

@ -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"
}
}
}
}

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\adminsystem.Data\adminsystem.Data.csproj" />
<ProjectReference Include="..\adminsystem.Entity\adminsystem.Entity.csproj" />
<ProjectReference Include="..\adminsystem.Services\adminsystem.Services.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,5 @@
@adminsystem.Web_HostAddress = http://localhost:3000
###

View File

@ -0,0 +1,10 @@
{
"PostgreDb": {
"Host": "123.249.39.101",
"Port": "5432",
"Username": "postgres",
"Password": "dujunming520",
"Database": "postgres",
"Schema": "public"
}
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}