feat: implemented return of user info and eula accept logic

This commit is contained in:
2025-07-10 23:58:12 +03:00
parent 252adf0fc7
commit 4a7810f571
15 changed files with 209 additions and 48 deletions

View File

@@ -1,19 +1,17 @@
namespace JOBot.Backend.DAL.Context;
using JOBot.Backend.DAL.Models;
using Models;
using Microsoft.EntityFrameworkCore;
public class AppDbContext : DbContext
public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{
public DbSet<User> Users { get; set; }
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<User>()
.HasAlternateKey(b => b.TelegramId);
.HasAlternateKey(b => b.UserId);
}
}

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using JOBot.Proto;
using Microsoft.EntityFrameworkCore;
namespace JOBot.Backend.DAL.Models;
@@ -9,10 +10,30 @@ public class User
public Guid Id { get; set; }
[Key]
public required long TelegramId { get; set; }
[MaxLength(50)]
public required long UserId { get; set; }
[MaxLength(255)]
public string? Username { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public string? HeadHunterResumeUrl { get; set; }
[MaxLength(255)] public string? AccessToken { get; set; } = null;
[MaxLength(255)] public string? RefreshToken { get; set; } = null;
public bool Eula { get; set; } = false;
[MaxLength(255)] public string? CvUrl { get; set; } = null;
}
//TODO: Негоже это маппинги в DAL ложить
public static class UserMap
{
public static GetUserResponse MapToResponse(this User user)
{
return new GetUserResponse
{
UserId = user.UserId,
Username = user.Username,
Eula = user.Eula,
IsLogged = user.RefreshToken != null,
CVUrl = user.CvUrl
};
}
}