bitget asp 서버 추가
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,3 +4,5 @@
|
||||
/BitgetApi/obj
|
||||
/BitgetApi/bin
|
||||
/BitgetApi/Properties/licenses.licx
|
||||
/Bitget_Server/bin
|
||||
/Bitget_Server/obj
|
||||
|
||||
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.9.34902.65
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitgetApi", "BitgetApi\BitgetApi.csproj", "{09813A63-9EF4-4D6D-BA41-5F610909BDEC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bitget_Server", "Bitget_Server\Bitget_Server.csproj", "{725DC784-0243-4FDF-921E-91CF09580A03}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -15,6 +17,10 @@ Global
|
||||
{09813A63-9EF4-4D6D-BA41-5F610909BDEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{09813A63-9EF4-4D6D-BA41-5F610909BDEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{09813A63-9EF4-4D6D-BA41-5F610909BDEC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{725DC784-0243-4FDF-921E-91CF09580A03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{725DC784-0243-4FDF-921E-91CF09580A03}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{725DC784-0243-4FDF-921E-91CF09580A03}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{725DC784-0243-4FDF-921E-91CF09580A03}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -92,7 +92,6 @@
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\licenses.licx" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
||||
22
Bitget_Server/Bitget_Server.csproj
Normal file
22
Bitget_Server/Bitget_Server.csproj
Normal file
@@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.6">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
19
Bitget_Server/Common/CommonProperty.cs
Normal file
19
Bitget_Server/Common/CommonProperty.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bitget_Server.Common
|
||||
{
|
||||
public static class CommonProperty
|
||||
{
|
||||
public static string DbIp { get; set; } = "localhost";
|
||||
|
||||
public static string DbName { get; set; } = "Bitget";
|
||||
public static string DbId { get; set; } = "million";
|
||||
public static string DbPw { get; set; } = "million!";
|
||||
|
||||
public static string EfCoreConnectionStr { get; set; } = $"Server={DbIp};database={DbName};uid={DbId};pwd={DbPw};TrustServerCertificate=true;";
|
||||
}
|
||||
}
|
||||
24
Bitget_Server/Controller/PushAlarmController.cs
Normal file
24
Bitget_Server/Controller/PushAlarmController.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Bitget_Server.EFCore.Models;
|
||||
using Bitget_Server.EFCore;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Bitget_Server.Controller
|
||||
{
|
||||
|
||||
[ApiController, Route("api/push")]
|
||||
public class PushAlarmController : ControllerBase
|
||||
{
|
||||
private readonly BitgetContext context;
|
||||
|
||||
public PushAlarmController(BitgetContext _context)
|
||||
{
|
||||
context = _context;
|
||||
}
|
||||
|
||||
[HttpGet, Route("newalarm")]
|
||||
public List<PushAlarm> GetAlarm(int index)
|
||||
{
|
||||
return context.PushAlarms.Where(x => x.Id > index).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Bitget_Server/EFCore/BitgetContext.cs
Normal file
33
Bitget_Server/EFCore/BitgetContext.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Bitget_Server.Common;
|
||||
using Bitget_Server.EFCore.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bitget_Server.EFCore
|
||||
{
|
||||
public class BitgetContext : DbContext
|
||||
{
|
||||
|
||||
public DbSet<PushAlarm> PushAlarms { get; set; }
|
||||
|
||||
public BitgetContext(DbContextOptions<BitgetContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(CommonProperty.EfCoreConnectionStr);
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Bitget_Server/EFCore/Models/PushAlarm.cs
Normal file
24
Bitget_Server/EFCore/Models/PushAlarm.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bitget_Server.EFCore.Models
|
||||
{
|
||||
public class PushAlarm
|
||||
{
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public DateTime AlarmTime { get; set; }
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public string Contents { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
54
Bitget_Server/Migrations/20240602102008_init1.Designer.cs
generated
Normal file
54
Bitget_Server/Migrations/20240602102008_init1.Designer.cs
generated
Normal file
@@ -0,0 +1,54 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Bitget_Server.EFCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bitget_Server.Migrations
|
||||
{
|
||||
[DbContext(typeof(BitgetContext))]
|
||||
[Migration("20240602102008_init1")]
|
||||
partial class init1
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Bitget_Server.EFCore.Models.PushAlarm", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("AlarmTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Contents")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("PushAlarms");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Bitget_Server/Migrations/20240602102008_init1.cs
Normal file
37
Bitget_Server/Migrations/20240602102008_init1.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bitget_Server.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class init1 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PushAlarms",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AlarmTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Contents = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PushAlarms", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "PushAlarms");
|
||||
}
|
||||
}
|
||||
}
|
||||
51
Bitget_Server/Migrations/BitgetContextModelSnapshot.cs
Normal file
51
Bitget_Server/Migrations/BitgetContextModelSnapshot.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Bitget_Server.EFCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bitget_Server.Migrations
|
||||
{
|
||||
[DbContext(typeof(BitgetContext))]
|
||||
partial class BitgetContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Bitget_Server.EFCore.Models.PushAlarm", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("AlarmTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Contents")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("PushAlarms");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Bitget_Server/Program.cs
Normal file
27
Bitget_Server/Program.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Bitget_Server.EFCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Bitget_Server
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddDbContext<BitgetContext>();
|
||||
var app = builder.Build();
|
||||
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var services = scope.ServiceProvider;
|
||||
var context = services.GetRequiredService<BitgetContext>();
|
||||
context.Database.Migrate();
|
||||
}
|
||||
|
||||
|
||||
app.MapGet("/", () => "Hello World!");
|
||||
|
||||
app.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Bitget_Server/Properties/launchSettings.json
Normal file
29
Bitget_Server/Properties/launchSettings.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:46411",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:5045",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Bitget_Server/appsettings.Development.json
Normal file
8
Bitget_Server/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Bitget_Server/appsettings.json
Normal file
9
Bitget_Server/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user