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
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
32
Treestar.Shared/Models/DBDomain/Author.cs
Normal file
32
Treestar.Shared/Models/DBDomain/Author.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Treestar.Shared/Models/DBDomain/BaseEntity.cs
Normal file
8
Treestar.Shared/Models/DBDomain/BaseEntity.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Treestar.Shared.Models.DBDomain
|
||||
{
|
||||
public abstract class BaseEntity
|
||||
{
|
||||
public DateTime DateCreated { get; set; }
|
||||
public DateTime DateModified { get; set; }
|
||||
}
|
||||
}
|
||||
37
Treestar.Shared/Models/DBDomain/Chapter.cs
Normal file
37
Treestar.Shared/Models/DBDomain/Chapter.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Treestar.Shared/Models/DBDomain/Novel.cs
Normal file
21
Treestar.Shared/Models/DBDomain/Novel.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
31
Treestar.Shared/Models/DBDomain/Tag.cs
Normal file
31
Treestar.Shared/Models/DBDomain/Tag.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Treestar.Shared/Models/DBDomain/User.cs
Normal file
12
Treestar.Shared/Models/DBDomain/User.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
14
Treestar.Shared/Models/DBDomain/UserNovel.cs
Normal file
14
Treestar.Shared/Models/DBDomain/UserNovel.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Treestar.Shared.Models.DTO.Requests;
|
||||
|
||||
public class ScrapeNovelRequest
|
||||
{
|
||||
public string NovelUrl { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Treestar.Shared.Models.DTO.Requests;
|
||||
|
||||
public class ScrapeNovelsRequest
|
||||
{
|
||||
[JsonProperty("novelUrls")]
|
||||
public List<string> NovelUrls { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Treestar.Shared.Models.DBDomain;
|
||||
|
||||
namespace Treestar.Shared.Models.DTO.Responses;
|
||||
|
||||
public class ScrapeNovelsResponse
|
||||
{
|
||||
public List<Novel> SuccessfulNovels { get; set; }
|
||||
public Dictionary<string, Exception> Failures { get; set; }
|
||||
}
|
||||
9
Treestar.Shared/Models/Enums/NovelStatus.cs
Normal file
9
Treestar.Shared/Models/Enums/NovelStatus.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Treestar.Shared.Models.Enums;
|
||||
|
||||
public enum NovelStatus
|
||||
{
|
||||
Unknown,
|
||||
InProgress,
|
||||
Completed,
|
||||
Hiatus
|
||||
}
|
||||
11
Treestar.Shared/Models/HttpResponseWrapper.cs
Normal file
11
Treestar.Shared/Models/HttpResponseWrapper.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Treestar.Shared.Models;
|
||||
|
||||
public class HttpResponseWrapper<T> : HttpResponseWrapper
|
||||
{
|
||||
public T? ResponseObject { get; set; }
|
||||
}
|
||||
|
||||
public class HttpResponseWrapper
|
||||
{
|
||||
public HttpResponseMessage HttpResponseMessage { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user