complete controllers
This commit is contained in:
@ -36,4 +36,9 @@ public class FlowerDatabase : DbContext
|
||||
/// 会话令牌集
|
||||
/// </summary>
|
||||
public DbSet<TokenItem> Tokens { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 照片集
|
||||
/// </summary>
|
||||
public DbSet<PhotoItem> Photos { get; set; }
|
||||
}
|
||||
|
@ -19,12 +19,19 @@ public class FlowerItem
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所有人 uid
|
||||
/// 所有人 id
|
||||
/// </summary>
|
||||
[Column("uid")]
|
||||
[ForeignKey(nameof(Owner))]
|
||||
[Required]
|
||||
public int OwnerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所有人
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public UserItem? Owner { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类别 id
|
||||
/// </summary>
|
||||
@ -59,12 +66,6 @@ public class FlowerItem
|
||||
[Column("purchase")]
|
||||
public string? Purchase { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 购买照片
|
||||
/// </summary>
|
||||
[Column("photo")]
|
||||
public byte[]? Photo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
@ -77,4 +78,9 @@ public class FlowerItem
|
||||
[NotMapped]
|
||||
[JsonIgnore]
|
||||
public DateTimeOffset DateBuy => DateTimeOffset.FromUnixTimeMilliseconds(DateBuyUnixTime);
|
||||
|
||||
/// <summary>
|
||||
/// 封面相关照片
|
||||
/// </summary>
|
||||
public ICollection<PhotoItem>? Photos { get; set; }
|
||||
}
|
||||
|
84
Server/Data/Model/PhotoItem.cs
Normal file
84
Server/Data/Model/PhotoItem.cs
Normal file
@ -0,0 +1,84 @@
|
||||
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("fid")]
|
||||
[ForeignKey(nameof(Flower))]
|
||||
[Required]
|
||||
public int FlowerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联花草
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public FlowerItem? Flower { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联的事件 id
|
||||
/// </summary>
|
||||
[Column("rid")]
|
||||
[ForeignKey(nameof(Record))]
|
||||
[Required]
|
||||
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 long DateUploadUnixTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上传时间
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
[JsonIgnore]
|
||||
public DateTimeOffset DateUpload => DateTimeOffset.FromUnixTimeMilliseconds(DateUploadUnixTime);
|
||||
}
|
@ -19,12 +19,33 @@ public class RecordItem
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联人 uid
|
||||
/// 关联人 id
|
||||
/// </summary>
|
||||
[Column("uid")]
|
||||
[ForeignKey(nameof(Owner))]
|
||||
[Required]
|
||||
public int OwnerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联人
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public UserItem? Owner { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联花草 id
|
||||
/// </summary>
|
||||
[Column("fid")]
|
||||
[ForeignKey(nameof(Flower))]
|
||||
[Required]
|
||||
public int FlowerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关联花草
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public FlowerItem? Flower { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 事件类型
|
||||
/// </summary>
|
||||
@ -52,12 +73,6 @@ public class RecordItem
|
||||
[Column("byname")]
|
||||
public string? ByUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 事件关联照片
|
||||
/// </summary>
|
||||
[Column("photo")]
|
||||
public byte[]? Photo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
@ -70,4 +85,9 @@ public class RecordItem
|
||||
[NotMapped]
|
||||
[JsonIgnore]
|
||||
public DateTimeOffset Date => DateTimeOffset.FromUnixTimeMilliseconds(DateUnixTime);
|
||||
|
||||
/// <summary>
|
||||
/// 事件关联照片
|
||||
/// </summary>
|
||||
public ICollection<PhotoItem>? Photos { get; set; }
|
||||
}
|
||||
|
Reference in New Issue
Block a user