Updated lots of stuff, got multi scrape working, need to test not-nullable chapter novel ids with our current model, now supports sqlite and postgres concurrently (and easy add more), need to get it deployed/do auth
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2022-07-16 17:17:43 -04:00
parent eab3399268
commit d98324c11e
73 changed files with 1591 additions and 680 deletions

View File

@@ -0,0 +1,32 @@
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;
namespace Treestar.Shared.Models.DBDomain
{
public class Author : BaseEntity
{
[Key]
public string Url { get; set; }
public string Name { get; set; }
[JsonIgnore]
public List<Novel> Novels { get; set; }
protected bool Equals(Author other)
{
return Url == other.Url;
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((Author) obj);
}
public override int GetHashCode()
{
return Url.GetHashCode();
}
}
}

View File

@@ -0,0 +1,8 @@
namespace Treestar.Shared.Models.DBDomain
{
public abstract class BaseEntity
{
public DateTime DateCreated { get; set; }
public DateTime DateModified { get; set; }
}
}

View File

@@ -0,0 +1,37 @@
using System.ComponentModel.DataAnnotations;
namespace Treestar.Shared.Models.DBDomain
{
public class Chapter : BaseEntity
{
public int ChapterNumber { get; set; }
public string Name { get; set; }
public string? Content { get; set; }
public string? RawContent { get; set; }
[Key]
public string Url { get; set; }
public DateTime? DatePosted { get; set; }
public DateTime? DateUpdated { get; set; }
public DateTime? LastContentFetch { get; set; }
[Required]
public string NovelUrl { get; set; }
protected bool Equals(Chapter other)
{
return Url == other.Url;
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((Chapter) obj);
}
public override int GetHashCode()
{
return Url.GetHashCode();
}
}
}

View File

@@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;
using Treestar.Shared.Models.Enums;
namespace Treestar.Shared.Models.DBDomain
{
[Index(nameof(Guid))]
public class Novel : BaseEntity
{
[Key]
public string Url { get; set; }
public Guid Guid { get; set; }
public string Title { get; set; }
public Author? Author { get; set; }
public List<Tag> Tags { get; set; }
public List<Chapter> Chapters { get; set; }
public NovelStatus Status { get; set; }
public DateTime LastUpdated { get; set; }
public DateTime DatePosted { get; set; }
}
}

View File

@@ -0,0 +1,31 @@
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;
namespace Treestar.Shared.Models.DBDomain
{
public class Tag : BaseEntity
{
[Key]
public string TagValue { get; set; }
[JsonIgnore]
public List<Novel> Novels { get; set; }
protected bool Equals(Tag other)
{
return TagValue == other.TagValue;
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((Tag) obj);
}
public override int GetHashCode()
{
return TagValue.GetHashCode();
}
}
}

View File

@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
namespace Treestar.Shared.Models.DBDomain
{
public class User : BaseEntity
{
[Key]
public int Id { get; set; }
public string Email { get; set; }
public List<UserNovel> WatchedNovels { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using Newtonsoft.Json;
namespace Treestar.Shared.Models.DBDomain
{
public class UserNovel
{
[JsonIgnore]
public int UserId { get; set; }
public string NovelUrl { get; set; }
public Novel Novel { get; set; }
public User User { get; set; }
public int LastChapterRead { get; set; }
}
}