Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mystogun committed Jul 13, 2020
0 parents commit 0d45e5c
Show file tree
Hide file tree
Showing 96 changed files with 14,392 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .idea/.idea.MiqManga/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/.idea.MiqManga/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.MiqManga/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.MiqManga/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/.idea.MiqManga/riderModule.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions MiqManga.sln
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
55 changes: 55 additions & 0 deletions MiqManga/Controllers/AuthController.cs
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);
}

}
}
19 changes: 19 additions & 0 deletions MiqManga/Data/Entities/Chapter.cs
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; }
}
}
21 changes: 21 additions & 0 deletions MiqManga/Data/Entities/Comment.cs
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; }
}
}
15 changes: 15 additions & 0 deletions MiqManga/Data/Entities/FreeWall.cs
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; }
}
}
17 changes: 17 additions & 0 deletions MiqManga/Data/Entities/Lookups/ParentType.cs
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; }

}
}
16 changes: 16 additions & 0 deletions MiqManga/Data/Entities/Lookups/PostType.cs
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; }
}
}
15 changes: 15 additions & 0 deletions MiqManga/Data/Entities/Page.cs
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; }
}
}
26 changes: 26 additions & 0 deletions MiqManga/Data/Entities/Post.cs
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; }
}
}
24 changes: 24 additions & 0 deletions MiqManga/Data/Entities/User.cs
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; }
}
}
22 changes: 22 additions & 0 deletions MiqManga/Data/MiqMangaDbContext.cs
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; }

}
}
11 changes: 11 additions & 0 deletions MiqManga/Data/Models/Requests/LoginRequest.cs
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; }
}
}
13 changes: 13 additions & 0 deletions MiqManga/Data/Models/Requests/RegisterUserRequest.cs
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; }
}
}
Loading

0 comments on commit 0d45e5c

Please sign in to comment.