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