-
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
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
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,77 @@ | ||
using System.Threading.Tasks; | ||
using MediatR; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Zeus.Api.Web.Attributes; | ||
using Zeus.Enums.Users; | ||
using Zeus.Models.Users.Commands; | ||
using Zeus.Models.Users.Queries; | ||
|
||
namespace Zeus.Api.Web.Controllers | ||
{ | ||
public sealed class UserController : BaseController | ||
{ | ||
public UserController(IMediator mediator) : base(mediator) | ||
{ | ||
} | ||
|
||
[Authorization(UserRole.Admin)] | ||
[HttpGet] | ||
public async Task<IActionResult> GetUsers() | ||
{ | ||
return await SendAsync(new GetUsersQuery()); | ||
} | ||
|
||
[Authorization(UserRole.Admin)] | ||
[HttpGet] | ||
public async Task<IActionResult> GetUserHistory([FromQuery] GetUserHistoryQuery request) | ||
{ | ||
return await SendAsync(request); | ||
} | ||
|
||
[HttpGet] | ||
public async Task<IActionResult> GetUserRoleDictionary() | ||
{ | ||
return await SendAsync(new GetUserRoleDictionaryQuery()); | ||
} | ||
|
||
[AllowAnonymous] | ||
[HttpPost] | ||
public async Task<IActionResult> GetUserToken([FromBody] GetUserTokenQuery request) | ||
{ | ||
return await SendAsync(request); | ||
} | ||
|
||
[HttpPost] | ||
public async Task<IActionResult> GetUserTokenRefresh() | ||
{ | ||
return await SendAsync(new GetUserTokenRefreshQuery() | ||
{ | ||
UserId = GetUserId() | ||
}); | ||
} | ||
|
||
[Authorization(UserRole.Admin)] | ||
[HttpPost] | ||
public async Task<IActionResult> CreateUser([FromBody] CreateUserCommand request) | ||
{ | ||
request.Update(GetUserId()); | ||
return await SendAsync(request); | ||
} | ||
|
||
[Authorization(UserRole.Admin)] | ||
[HttpPost] | ||
public async Task<IActionResult> UpdateUser([FromBody] UpdateUserCommand request) | ||
{ | ||
request.Update(GetUserId()); | ||
return await SendAsync(request); | ||
} | ||
|
||
[AllowAnonymous] | ||
[HttpPost] | ||
public async Task<IActionResult> ChangeUserPassword([FromBody] ChangePasswordUserCommand request) | ||
{ | ||
return await SendAsync(request); | ||
} | ||
} | ||
} |