feat: added DAL
This commit is contained in:
parent
5164448dd5
commit
881ae85ef7
11
JOBot.Backend/DAL/Context/AppDbContext.cs
Normal file
11
JOBot.Backend/DAL/Context/AppDbContext.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace JOBot.Backend.DAL.Context;
|
||||
|
||||
using JOBot.Backend.DAL.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
class AppDbContext : DbContext
|
||||
{
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
|
||||
}
|
9
JOBot.Backend/DAL/Models/User.cs
Normal file
9
JOBot.Backend/DAL/Models/User.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace JOBot.Backend.DAL.Models;
|
||||
|
||||
public class User
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public long TelegramId { get; set; }
|
||||
public string? Username { get; set; }
|
||||
public DateTime CreatedAt { get; set; } = DateTime.Now;
|
||||
}
|
@ -21,7 +21,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Protobuf Include="..\Contracts\Proto\*" GrpcServices="Server"></Protobuf>
|
||||
<Protobuf Include="..\Proto\*" GrpcServices="Server"></Protobuf>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
@ -1,6 +1,13 @@
|
||||
using JOBot.Backend.DAL.Context;
|
||||
using JOBot.Backend.Services.gRPC;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddGrpc();
|
||||
builder.Services.AddDbContext<AppDbContext>(options =>
|
||||
options.UseNpgsql(builder.Configuration.GetConnectionString("PostgreSQL")));
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
namespace JOBot.Backend.Services.gRPC;
|
||||
|
||||
using Grpc.Core;
|
||||
using JOBot.Proto;
|
||||
|
||||
@ -8,6 +10,7 @@ class UserService : User.UserBase
|
||||
ServerCallContext context)
|
||||
|
||||
{
|
||||
|
||||
return Task.FromResult(new RegisterResponse
|
||||
{
|
||||
UserId = request.UserId
|
||||
|
@ -5,5 +5,8 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"PostgreSQL": "Host=localhost;Port=5432;Database=jobot;Username=postgres;Password=LocalDbPass"
|
||||
}
|
||||
}
|
@ -45,4 +45,7 @@ Global
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {2E6F4A6D-013E-457A-893F-964E6F350AE7}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
12
compose.yml
Normal file
12
compose.yml
Normal file
@ -0,0 +1,12 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15
|
||||
environment:
|
||||
POSTGRES_PASSWORD: LocalDbPass
|
||||
POSTGRES_DB: jobot
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- ./postgres_data:/var/lib/postgresql/data
|
Loading…
x
Reference in New Issue
Block a user