tiny server.
This commit is contained in:
15
Server/Data/FlowerDatabase.cs
Normal file
15
Server/Data/FlowerDatabase.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Blahblah.FlowerStory.Server.Data.Model;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Blahblah.FlowerStory.Server.Data;
|
||||
|
||||
public class FlowerDatabase : DbContext
|
||||
{
|
||||
public FlowerDatabase(DbContextOptions<FlowerDatabase> options) : base(options) { }
|
||||
|
||||
public DbSet<UserItem> Users { get; set; }
|
||||
|
||||
public DbSet<FlowerItem> Flowers { get; set; }
|
||||
|
||||
public DbSet<RecordItem> Records { get; set; }
|
||||
}
|
32
Server/Data/Model/FlowerItem.cs
Normal file
32
Server/Data/Model/FlowerItem.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Blahblah.FlowerStory.Server.Data.Model;
|
||||
|
||||
[Table("flowers")]
|
||||
public class FlowerItem
|
||||
{
|
||||
[Column("fid"), Key, Required]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("categoryid"), Required]
|
||||
public int CategoryId { get; set; }
|
||||
|
||||
[Column("name"), Required]
|
||||
public required string Name { get; set; }
|
||||
|
||||
[Column("datebuy"), Required]
|
||||
public long DateBuyUnixTime { get; set; }
|
||||
|
||||
[Column("cost", TypeName = "real")]
|
||||
public decimal? Cost { get; set; }
|
||||
|
||||
[Column("purchase")]
|
||||
public string? Purchase { get; set; }
|
||||
|
||||
[Column("photo")]
|
||||
public byte[]? Photo { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset DateBuy => DateTimeOffset.FromUnixTimeMilliseconds(DateBuyUnixTime);
|
||||
}
|
29
Server/Data/Model/RecordItem.cs
Normal file
29
Server/Data/Model/RecordItem.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Blahblah.FlowerStory.Server.Data.Model;
|
||||
|
||||
[Table("records")]
|
||||
public class RecordItem
|
||||
{
|
||||
[Column("rid"), Key, Required]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("eid"), Required]
|
||||
public int EventId { get; set; }
|
||||
|
||||
[Column("date"), Required]
|
||||
public long DateUnixTime { get; set; }
|
||||
|
||||
[Column("byuid")]
|
||||
public int? ByUserId { get; set; }
|
||||
|
||||
[Column("byname")]
|
||||
public string? ByUserName { get; set; }
|
||||
|
||||
[Column("photo")]
|
||||
public byte[]? Photo { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset Date => DateTimeOffset.FromUnixTimeMilliseconds(DateUnixTime);
|
||||
}
|
32
Server/Data/Model/UserItem.cs
Normal file
32
Server/Data/Model/UserItem.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Blahblah.FlowerStory.Server.Data.Model;
|
||||
|
||||
[Table("users")]
|
||||
public class UserItem
|
||||
{
|
||||
[Column("uid"), Key, Required]
|
||||
public int Id { get; set; }
|
||||
[Column("id"), Required]
|
||||
public required string UserId { get; set; }
|
||||
[Column("password"), Required]
|
||||
public required string Password { get; set; }
|
||||
[Column("level"), Required]
|
||||
public int Level { get; set; }
|
||||
[Column("regdate"), Required]
|
||||
public long RegisterDateUnixTime { get; set; }
|
||||
[Column("activedate")]
|
||||
public long? ActiveDateUnixTime { get; set; }
|
||||
[Column("name"), Required]
|
||||
public required string Name { get; set; }
|
||||
[Column("email")]
|
||||
public string? Email { get; set; }
|
||||
[Column("mobile")]
|
||||
public string? Mobile { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset RegisterDate => DateTimeOffset.FromUnixTimeMilliseconds(RegisterDateUnixTime);
|
||||
[NotMapped]
|
||||
public DateTimeOffset? ActiveDate => ActiveDateUnixTime == null ? null : DateTimeOffset.FromUnixTimeMilliseconds(ActiveDateUnixTime.Value);
|
||||
}
|
Reference in New Issue
Block a user