diff --git a/.gitignore b/.gitignore index 034c379..b205596 100644 --- a/.gitignore +++ b/.gitignore @@ -390,3 +390,24 @@ FodyWeavers.xsd .idea/ *.sln.iml +# Vim gitignore +# https://github.com/github/gitignore/blob/main/Global/Vim.gitignore +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ diff --git a/migrations/20220206082350_add-user.down.sql b/migrations/20220206082350_add-user.down.sql new file mode 100644 index 0000000..e71d539 --- /dev/null +++ b/migrations/20220206082350_add-user.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS `user`; diff --git a/migrations/20220206082350_add-user.up.sql b/migrations/20220206082350_add-user.up.sql new file mode 100644 index 0000000..f55517a --- /dev/null +++ b/migrations/20220206082350_add-user.up.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS `user` ( + id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + email varchar(255) NOT NULL COMMENT 'Email', + password_hash varchar(255) NOT NULL COMMENT 'Hashed password', + is_deleted TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Whether the item is deleted or not. 0 = active, 1 = deleted', + created_on DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'The DateTime when the item was created', + updated_on DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'The DateTime when the item was created', + KEY `idx_email` (`email`) +) ENGINE=INNODB COMMENT 'Contains user information.'; diff --git a/src/Api/Controllers/AccountController.cs b/src/Api/Controllers/AccountController.cs new file mode 100644 index 0000000..cd62b78 --- /dev/null +++ b/src/Api/Controllers/AccountController.cs @@ -0,0 +1,47 @@ +using Shared.Models; +using Shared.Repositories; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System.Data; + +namespace Api.Controllers +{ + [ApiController] + [Route("[controller]")] + public class AccountController : ControllerBase + { + private readonly ILogger _logger; + private readonly IDbTransaction _transaction; + private readonly IUserRepository _userRepository; + + public AccountController(ILogger logger, IDbTransaction transaction, IUserRepository userRepository) + { + _logger = logger; + _transaction = transaction; + _userRepository = userRepository; + } + + [HttpPost("register")] + public async Task Register() + { + await Task.Delay(1); + throw new System.NotImplementedException(); + } + + [HttpPost("login")] + public async Task Login() + { + await Task.Delay(1); + throw new System.NotImplementedException(); + } + + [HttpGet("me")] + public async Task Get() + { + await Task.Delay(1); + throw new System.NotImplementedException(); + } + } +} diff --git a/src/Api/Program.cs b/src/Api/Program.cs index 2df9ce5..8eff021 100644 --- a/src/Api/Program.cs +++ b/src/Api/Program.cs @@ -23,6 +23,7 @@ }); services.AddScoped(); services.AddScoped(); +services.AddScoped(); services.AddControllers(); services.AddSwaggerGen(c => diff --git a/src/Shared/IUserRepository.cs b/src/Shared/IUserRepository.cs new file mode 100644 index 0000000..696c136 --- /dev/null +++ b/src/Shared/IUserRepository.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Shared.Models; + +namespace Shared.Repositories +{ + public interface IUserRepository + { + Task> Get(); + Task Get(int id); + Task Insert(User User); + Task Update(User User); + } +} diff --git a/src/Shared/Models/User.cs b/src/Shared/Models/User.cs new file mode 100644 index 0000000..4ece293 --- /dev/null +++ b/src/Shared/Models/User.cs @@ -0,0 +1,8 @@ +namespace Shared.Models +{ + public class User : BaseModel + { + public string Email { get; set; } + public string PasswordHash { get; set; } + } +} diff --git a/src/Shared/Repositories/UserRepository.cs b/src/Shared/Repositories/UserRepository.cs new file mode 100644 index 0000000..4e098c7 --- /dev/null +++ b/src/Shared/Repositories/UserRepository.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Shared.Models; + +namespace Shared.Repositories +{ + public class UserRepository : IUserRepository + { + public Task> Get() + { + throw new System.NotImplementedException(); + } + + public Task Get(int id) + { + throw new System.NotImplementedException(); + } + + public Task Insert(User User) + { + throw new System.NotImplementedException(); + } + + public Task Update(User User) + { + throw new System.NotImplementedException(); + } + } +}