feat: implemented return of user info and eula accept logic
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user