-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0d45e5c
Showing
96 changed files
with
14,392 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiqManga", "MiqManga\MiqManga.csproj", "{19333878-8372-440F-BF20-FD97E0B08153}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{19333878-8372-440F-BF20-FD97E0B08153}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{19333878-8372-440F-BF20-FD97E0B08153}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{19333878-8372-440F-BF20-FD97E0B08153}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{19333878-8372-440F-BF20-FD97E0B08153}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using MiqManga.Data; | ||
using MiqManga.Data.Entities; | ||
using MiqManga.Data.Models.Requests; | ||
using MiqManga.Services; | ||
|
||
namespace MiqManga.Controllers | ||
{ | ||
// https://www.miq.com/api/auth | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
[AllowAnonymous] | ||
public class AuthController : ControllerBase | ||
{ | ||
// CRUD -> Create Read Update Delete -> Conventions | ||
// CRUD -> Post Get Put Delete -> Http Methods -> Http Client | ||
|
||
private readonly IAuthServices _authServices; | ||
|
||
public AuthController(IAuthServices authServices) | ||
{ | ||
_authServices = authServices; | ||
} | ||
|
||
// POST : api/auth/register | ||
[HttpPost("register")] | ||
public IActionResult Register([FromBody] RegisterUserRequest request) | ||
{ | ||
if (!ModelState.IsValid) | ||
{ | ||
return BadRequest(); | ||
} | ||
var newUser = new User | ||
{ | ||
Username = request.Username, | ||
Email = request.Email | ||
}; | ||
var result = _authServices.Register(newUser, request.Password); | ||
|
||
return Ok(result); | ||
} | ||
|
||
// POST : api/auth/login | ||
[HttpPost("login")] | ||
public IActionResult Login([FromBody] LoginRequest request) | ||
{ | ||
var loginResult = _authServices.Login(request.Username, request.Password); | ||
return Ok(loginResult); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace MiqManga.Data.Entities | ||
{ | ||
public class Chapter | ||
{ | ||
public long Id { get; set; } | ||
public DateTime? CreatedAt { get; set; } | ||
public DateTime? UpdatedAt { get; set; } | ||
public byte? IsDeleted { get; set; } | ||
|
||
[MaxLength(256)] public string Path { get; set; } | ||
|
||
public List<Page> Pages { get; set; } | ||
public List<Comment> Comments { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace MiqManga.Data.Entities | ||
{ | ||
public class Comment | ||
{ | ||
public long Id { get; set; } | ||
public DateTime? CreatedAt { get; set; } | ||
public DateTime? UpdatedAt { get; set; } | ||
public byte? IsDeleted { get; set; } | ||
|
||
public User Owner { get; set; } | ||
|
||
[MaxLength(1024)] public string Content { get; set; } | ||
public byte? IsSpoiler { get; set; } | ||
|
||
public long ParentId { get; set; } | ||
public ParentType ParentType { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace MiqManga.Data.Entities | ||
{ | ||
public class FreeWall | ||
{ | ||
public long Id { get; set; } | ||
public DateTime? CreatedAt { get; set; } | ||
public DateTime? UpdatedAt { get; set; } | ||
public byte? IsDeleted { get; set; } | ||
|
||
public List<Comment> Comments { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace MiqManga.Data.Entities | ||
{ | ||
public class ParentType | ||
{ | ||
public long Id { get; set; } | ||
public DateTime? CreatedAt { get; set; } | ||
public DateTime? UpdatedAt { get; set; } | ||
public byte? IsDeleted { get; set; } | ||
|
||
[MaxLength(50)] | ||
public string Type { get; set; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace MiqManga.Data.Entities | ||
{ | ||
public class PostType | ||
{ | ||
public short Id { get; set; } | ||
public DateTime? CreatedAt { get; set; } | ||
public DateTime? UpdatedAt { get; set; } | ||
public byte? IsDeleted { get; set; } | ||
|
||
[MaxLength(50)] | ||
public string Type { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace MiqManga.Data.Entities | ||
{ | ||
public class Page | ||
{ | ||
public long Id { get; set; } | ||
public DateTime? CreatedAt { get; set; } | ||
public DateTime? UpdatedAt { get; set; } | ||
public byte? IsDeleted { get; set; } | ||
|
||
[MaxLength(255)] public string Path { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace MiqManga.Data.Entities | ||
{ | ||
public class Post | ||
{ | ||
public long Id { get; set; } | ||
public DateTime? CreatedAt { get; set; } | ||
public DateTime? UpdatedAt { get; set; } | ||
public byte? IsDeleted { get; set; } | ||
|
||
[MaxLength(255)] public string Title { get; set; } | ||
[MaxLength(1024)] public string Description { get; set; } | ||
[MaxLength(255)] public string PosterPath { get; set; } | ||
[MaxLength(255)] public string CoverPath { get; set; } | ||
public double? Rating { get; set; } | ||
public byte? Language { get; set; } | ||
|
||
public User Owner { get; set; } | ||
public PostType PostType { get; set; } | ||
public List<Chapter> Chapters { get; set; } | ||
public List<Comment> Comments { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace MiqManga.Data.Entities | ||
{ | ||
public class User | ||
{ | ||
public long Id { get; set; } | ||
public DateTime? CreatedAt { get; set; } | ||
public DateTime? UpdatedAt { get; set; } | ||
public byte? IsDeleted { get; set; } | ||
|
||
[MinLength(4), MaxLength(50)] public string Username { get; set; } | ||
|
||
[MaxLength(50)] public string Email { get; set; } | ||
|
||
[MaxLength(2048)] public string PasswordHash { get; set; } | ||
[MaxLength(2048)] public string PasswordSalt { get; set; } | ||
|
||
public byte Role { get; set; } | ||
|
||
[MaxLength(255)] public string AvatarPath { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Buffers.Text; | ||
using Microsoft.EntityFrameworkCore; | ||
using MiqManga.Data.Entities; | ||
|
||
namespace MiqManga.Data | ||
{ | ||
public class MiqMangaDbContext : DbContext | ||
{ | ||
public MiqMangaDbContext(DbContextOptions options) : base(options) | ||
{ | ||
|
||
} | ||
|
||
public DbSet<Post> Posts { get; set; } | ||
public DbSet<Chapter> Chapters { get; set; } | ||
public DbSet<Page> Pages { get; set; } | ||
public DbSet<Comment> Comments { get; set; } | ||
public DbSet<User> Users { get; set; } | ||
public DbSet<FreeWall> FreeWalls { get; set; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace MiqManga.Data.Models.Requests | ||
{ | ||
public class LoginRequest | ||
{ | ||
[MinLength(4), MaxLength(50)] public string Username { get; set; } | ||
|
||
[MinLength(8)] public string Password { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace MiqManga.Data.Models.Requests | ||
{ | ||
public class RegisterUserRequest | ||
{ | ||
[MinLength(4), MaxLength(50)] public string Username { get; set; } | ||
|
||
[MaxLength(50)] public string Email { get; set; } | ||
|
||
[MinLength(8)] public string Password { get; set; } | ||
} | ||
} |
Oops, something went wrong.