Добавлено управление сессиями
This commit is contained in:
@@ -24,5 +24,5 @@ public class ApplicationUser : IdentityUser<Guid>
|
||||
public DateTime RefreshTokenExpiryUtc { get; set; }
|
||||
|
||||
/// <summary>Плейлисты, созданные пользователем.</summary>
|
||||
public ICollection<SharedPlaylistEntity> OwnedPlaylists { get; set; } = new List<SharedPlaylistEntity>();
|
||||
public ICollection<SharedPlaylist> OwnedPlaylists { get; set; } = new List<SharedPlaylist>();
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace PlaylistShared.Api.Entities;
|
||||
|
||||
/// <summary>Сущность шеринг-плейлиста (таблица в БД).</summary>
|
||||
public class SharedPlaylistEntity
|
||||
/// <summary>Сущность шеринг-плейлиста.</summary>
|
||||
public class SharedPlaylist
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid CreatorUserId { get; set; }
|
||||
@@ -22,5 +22,5 @@ public class SharedPlaylistEntity
|
||||
|
||||
// Навигационные свойства
|
||||
public ApplicationUser Creator { get; set; } = null!;
|
||||
public ICollection<TrackAdditionLogEntity> TrackAdditionLogs { get; set; } = new List<TrackAdditionLogEntity>();
|
||||
public ICollection<TrackAdditionLog> TrackAdditionLogs { get; set; } = new List<TrackAdditionLog>();
|
||||
}
|
||||
16
PlaylistShared.Api/Entities/TrackAdditionLog.cs
Normal file
16
PlaylistShared.Api/Entities/TrackAdditionLog.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace PlaylistShared.Api.Entities;
|
||||
|
||||
/// <summary>Лог добавления трека.</summary>
|
||||
public class TrackAdditionLog
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid SharedPlaylistId { get; set; }
|
||||
public string TrackId { get; set; } = null!;
|
||||
public Guid? AddedByUserId { get; set; }
|
||||
public DateTime AddedAtUtc { get; set; }
|
||||
public string SessionId { get; set; } = null!;
|
||||
|
||||
public SharedPlaylist SharedPlaylist { get; set; } = null!;
|
||||
public ApplicationUser? AddedByUser { get; set; }
|
||||
public UserSession Session { get; set; } = null!;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace PlaylistShared.Api.Entities;
|
||||
|
||||
/// <summary>Лог добавления трека (таблица в БД).</summary>
|
||||
public class TrackAdditionLogEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid SharedPlaylistId { get; set; }
|
||||
public string TrackId { get; set; } = null!;
|
||||
public Guid AddedByUserId { get; set; }
|
||||
public DateTime AddedAtUtc { get; set; }
|
||||
|
||||
// Навигационные свойства
|
||||
public SharedPlaylistEntity SharedPlaylist { get; set; } = null!;
|
||||
public ApplicationUser AddedByUser { get; set; } = null!;
|
||||
}
|
||||
15
PlaylistShared.Api/Entities/TrackRemovalLog.cs
Normal file
15
PlaylistShared.Api/Entities/TrackRemovalLog.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using PlaylistShared.Api.Entities;
|
||||
|
||||
public class TrackRemovalLog
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid SharedPlaylistId { get; set; }
|
||||
public string TrackId { get; set; } = null!;
|
||||
public Guid? RemovedByUserId { get; set; }
|
||||
public DateTime RemovedAtUtc { get; set; }
|
||||
public string SessionId { get; set; } = null!;
|
||||
|
||||
public SharedPlaylist SharedPlaylist { get; set; } = null!;
|
||||
public ApplicationUser? RemovedByUser { get; set; }
|
||||
public UserSession Session { get; set; } = null!;
|
||||
}
|
||||
15
PlaylistShared.Api/Entities/UserSession.cs
Normal file
15
PlaylistShared.Api/Entities/UserSession.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace PlaylistShared.Api.Entities;
|
||||
|
||||
public class UserSession
|
||||
{
|
||||
public string SessionId { get; set; } = null!; // HttpContext.Session.Id
|
||||
public string? ClientIpAddress { get; set; }
|
||||
public string? UserAgent { get; set; }
|
||||
public DateTime FirstSeenUtc { get; set; }
|
||||
public DateTime LastSeenUtc { get; set; }
|
||||
public Guid? AssociatedUserId { get; set; } // если позже залогинился
|
||||
|
||||
public ApplicationUser? User { get; set; }
|
||||
public ICollection<TrackAdditionLog> TrackAdditionLogs { get; set; } = new List<TrackAdditionLog>();
|
||||
public ICollection<TrackRemovalLog> TrackRemovalLogs { get; set; } = new List<TrackRemovalLog>();
|
||||
}
|
||||
Reference in New Issue
Block a user