Files
flower-story/Server/Data/Model/PhotoItem.cs
T
2023-07-13 12:10:30 +08:00

103 lines
2.2 KiB
C#

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace Blahblah.FlowerStory.Server.Data.Model;
/// <summary>
/// 照片对象
/// </summary>
[Table("photos")]
public class PhotoItem
{
/// <summary>
/// 自增 id,主键
/// </summary>
[Column("pid")]
[Key]
[Required]
public int Id { get; set; }
/// <summary>
/// 关联人 id
/// </summary>
[Column("uid")]
[ForeignKey(nameof(Owner))]
[Required]
public required int OwnerId { get; set; }
/// <summary>
/// 关联人
/// </summary>
[JsonIgnore]
public UserItem? Owner { get; set; }
/// <summary>
/// 关联花草 id
/// </summary>
[Column("fid")]
[ForeignKey(nameof(Flower))]
public int? FlowerId { get; set; }
/// <summary>
/// 关联的花草
/// </summary>
[JsonIgnore]
public FlowerItem? Flower { get; set; }
/// <summary>
/// 关联的事件 id
/// </summary>
[Column("rid")]
[ForeignKey(nameof(Record))]
public int? RecordId { get; set; }
/// <summary>
/// 关联的事件
/// </summary>
[JsonIgnore]
public RecordItem? Record { get; set; }
/// <summary>
/// 图片类型
/// </summary>
[Column("filetype")]
[Required]
public required string FileType { get; set; }
/// <summary>
/// 文件名
/// </summary>
[Column("filename")]
[Required]
public required string FileName { get; set; }
/// <summary>
/// 文件路径
/// </summary>
[Column("path")]
[Required]
public required string Path { get; set; }
/// <summary>
/// 上传时间
/// </summary>
[Column("dateupload")]
[Required]
[JsonPropertyName("dateUpload")]
public required long DateUploadUnixTime { get; set; }
/// <summary>
/// 上传时间
/// </summary>
[NotMapped]
[JsonIgnore]
public DateTimeOffset DateUpload => DateTimeOffset.FromUnixTimeMilliseconds(DateUploadUnixTime);
/// <summary>
/// 前端显示的 URL
/// </summary>
[NotMapped]
public string? Url { get; set; }
}