mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-05-22 00:30:14 +08:00
Initial commit
This commit is contained in:
18
Models/DataBase/Album.cs
Normal file
18
Models/DataBase/Album.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Foxel.Models.DataBase;
|
||||
|
||||
public class Album : BaseModel
|
||||
{
|
||||
[Required]
|
||||
[StringLength(100)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[StringLength(500)]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public int UserId { get; set; }
|
||||
[Required]
|
||||
public User User { get; set; }
|
||||
|
||||
public ICollection<Picture>? Pictures { get; set; }
|
||||
}
|
||||
12
Models/DataBase/AlbumPicture.cs
Normal file
12
Models/DataBase/AlbumPicture.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Foxel.Models.DataBase;
|
||||
|
||||
public class AlbumPicture
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int AlbumId { get; set; }
|
||||
public int PictureId { get; set; }
|
||||
|
||||
// 导航属性
|
||||
public Album? Album { get; set; }
|
||||
public Picture? Picture { get; set; }
|
||||
}
|
||||
12
Models/DataBase/BaseModel.cs
Normal file
12
Models/DataBase/BaseModel.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Foxel.Models.DataBase;
|
||||
|
||||
public abstract class BaseModel
|
||||
{
|
||||
[Key] public int Id { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
17
Models/DataBase/Config.cs
Normal file
17
Models/DataBase/Config.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Foxel.Models.DataBase;
|
||||
|
||||
public class Config : BaseModel
|
||||
{
|
||||
[Required]
|
||||
[StringLength(50)]
|
||||
public string Key { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[StringLength(255)]
|
||||
public string Value { get; set; } = string.Empty;
|
||||
|
||||
[StringLength(255)]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
}
|
||||
18
Models/DataBase/Favorite.cs
Normal file
18
Models/DataBase/Favorite.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Foxel.Models.DataBase;
|
||||
|
||||
public class Favorite
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
public User User { get; set; }
|
||||
|
||||
public int PictureId { get; set; }
|
||||
[ForeignKey("PictureId")]
|
||||
public Picture Picture { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
69
Models/DataBase/Picture.cs
Normal file
69
Models/DataBase/Picture.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json;
|
||||
using Vector = Pgvector.Vector;
|
||||
|
||||
namespace Foxel.Models.DataBase;
|
||||
|
||||
public enum StorageType
|
||||
{
|
||||
Local = 0,
|
||||
Telegram = 1,
|
||||
}
|
||||
|
||||
public class Picture : BaseModel
|
||||
{
|
||||
[StringLength(255)] public string Name { get; set; } = string.Empty;
|
||||
|
||||
[StringLength(1024)] public string Path { get; set; } = string.Empty;
|
||||
|
||||
[StringLength(1024)] public string? ThumbnailPath { get; set; } = string.Empty;
|
||||
|
||||
[StringLength(2000)] public string Description { get; set; } = string.Empty;
|
||||
[Column(TypeName = "vector(1024)")] public Vector? Embedding { get; set; }
|
||||
|
||||
public DateTime? TakenAt { get; set; }
|
||||
|
||||
[Column(TypeName = "jsonb")] public string? ExifInfoJson { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public ExifInfo? ExifInfo
|
||||
{
|
||||
get => ExifInfoJson != null ? JsonSerializer.Deserialize<ExifInfo>(ExifInfoJson) : null;
|
||||
set => ExifInfoJson = value != null ? JsonSerializer.Serialize(value) : null;
|
||||
}
|
||||
|
||||
public StorageType StorageType { get; set; } = StorageType.Local;
|
||||
|
||||
public ICollection<Tag>? Tags { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
|
||||
public User? User { get; set; }
|
||||
|
||||
public int? AlbumId { get; set; }
|
||||
public Album? Album { get; set; }
|
||||
|
||||
public ICollection<Favorite>? Favorites { get; set; }
|
||||
|
||||
public bool ContentWarning { get; set; } = false;
|
||||
public PermissionType Permission { get; set; } = PermissionType.Public;
|
||||
|
||||
public ProcessingStatus ProcessingStatus { get; set; } = ProcessingStatus.Pending;
|
||||
public string? ProcessingError { get; set; }
|
||||
public int ProcessingProgress { get; set; } = 0;
|
||||
}
|
||||
|
||||
public enum PermissionType
|
||||
{
|
||||
Public = 0,
|
||||
Friends = 1,
|
||||
Private = 2
|
||||
}
|
||||
|
||||
public enum ProcessingStatus
|
||||
{
|
||||
Pending, // 等待处理
|
||||
Processing, // 处理中
|
||||
Completed, // 处理完成
|
||||
Failed // 处理失败
|
||||
}
|
||||
15
Models/DataBase/Role.cs
Normal file
15
Models/DataBase/Role.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Foxel.Models.DataBase;
|
||||
|
||||
public class Role : BaseModel
|
||||
{
|
||||
[Required]
|
||||
[StringLength(50)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[StringLength(200)]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public ICollection<User>? Users { get; set; }
|
||||
}
|
||||
14
Models/DataBase/Tag.cs
Normal file
14
Models/DataBase/Tag.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Foxel.Models.DataBase;
|
||||
|
||||
public class Tag : BaseModel
|
||||
{
|
||||
[Required] [StringLength(50)] public string Name { get; set; } = string.Empty;
|
||||
|
||||
[StringLength(200)] public string Description { get; set; } = string.Empty;
|
||||
|
||||
public ICollection<Picture>? Pictures { get; set; }
|
||||
|
||||
public ICollection<User>? Users { get; set; }
|
||||
}
|
||||
26
Models/DataBase/User.cs
Normal file
26
Models/DataBase/User.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Foxel.Models.DataBase;
|
||||
|
||||
public class User : BaseModel
|
||||
{
|
||||
[Required] [StringLength(50)] public required string UserName { get; set; }
|
||||
|
||||
[Required]
|
||||
[EmailAddress]
|
||||
[StringLength(100)]
|
||||
public required string Email { get; set; }
|
||||
|
||||
[Required] [StringLength(255)] public required string PasswordHash { get; set; }
|
||||
|
||||
[StringLength(255)] public string? GithubId { get; set; }
|
||||
public int? RoleId { get; set; }
|
||||
|
||||
public Role? Role { get; set; }
|
||||
|
||||
public ICollection<Favorite>? Favorites { get; set; }
|
||||
|
||||
public ICollection<Tag>? Tags { get; set; }
|
||||
|
||||
public ICollection<Album>? Albums { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user