123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- using Microsoft.AspNetCore.Mvc;
- using ProductionLineMonitor.Application.Services.AdminService;
- using ProductionLineMonitor.Core.Dtos;
- using ProductionLineMonitor.Core.Services;
- using System.Collections.Generic;
- namespace ProductionLineMonitor.Web.Controllers
- {
- public class AdminController : BaseController
- {
- private readonly IAdminService _adminService;
- public AdminController(IAdminService adminService)
- {
- _adminService = adminService;
- }
- [HttpPost("/Admin/ChangePassword")]
- public IActionResult ChangePassword([FromBody] UserChangePasswordDto dto)
- {
- return Ok(_adminService.ChangePassword(dto));
- }
- [HttpGet("/Admin/User")]
- public new IActionResult User()
- {
- return View();
- }
- [HttpGet("/Admin/User/{id}")]
- public new IActionResult User([FromRoute] string id)
- {
- return Ok(_adminService.GetUserById(id));
- }
- [HttpGet("/Admin/GetUsers")]
- public IActionResult GetUsers(int pageNumber, int pageSize, string keyword)
- {
- pageNumber = pageNumber == 0 ? 1 : pageNumber;
- pageSize = pageSize == 0 ? 10 : pageSize;
- keyword ??= "";
- return Ok(_adminService.GetUserPageList(pageNumber, pageSize, keyword));
- }
- [HttpPost("/Admin/CreateUser")]
- public IActionResult CreateUser([FromBody] UserCreateOrUpdateDto dto)
- {
- return Ok(_adminService.CreateUser(dto));
- }
- [HttpPost("/Admin/UpdateUser/{id}")]
- public IActionResult UpdateUser([FromRoute] string id, [FromBody] UserCreateOrUpdateDto dto)
- {
- return Ok(_adminService.UpdateUser(id, dto));
- }
- [HttpPost("/Admin/DeleteUser/{id}")]
- public IActionResult UpdateUser([FromRoute] string id)
- {
- return Ok(_adminService.DeleteUser(id));
- }
- [HttpGet("/Admin/Role")]
- public IActionResult Role()
- {
- return View();
- }
- [HttpGet("/Admin/Role/{id}")]
- public IActionResult GetRoleById([FromRoute] string id)
- {
- return Ok(_adminService.GetRoleById(id));
- }
- [HttpGet("/Admin/GetRoles")]
- public IActionResult GetRoles(int pageNumber, int pageSize, string keyword)
- {
- pageNumber = pageNumber == 0 ? 1 : pageNumber;
- pageSize = pageSize == 0 ? 10 : pageSize;
- keyword ??= "";
- return Ok(_adminService.GetRolePageList(pageNumber, pageSize, keyword));
- }
- [HttpGet("/Admin/GetAllRoles")]
- public IActionResult GetAllRoles()
- {
- return Ok(_adminService.GetAllRoles());
- }
- [HttpPost("/Admin/CreateRole")]
- public IActionResult CreateRole([FromBody] RoleCreateOrUpdateDto dto)
- {
- return Ok(_adminService.CreateRole(dto));
- }
- [HttpPost("/Admin/UpdateRole/{id}")]
- public IActionResult UpdateRole([FromRoute] string id, [FromBody] RoleCreateOrUpdateDto dto)
- {
- return Ok(_adminService.UpdateRole(id, dto));
- }
- [HttpPost("/Admin/DeleteRole/{id}")]
- public IActionResult DeleteRole([FromRoute] string id)
- {
- return Ok(_adminService.DeleteRole(id));
- }
- [HttpGet("/Admin/Menu")]
- public IActionResult GetMenus()
- {
- return Ok(_adminService.GetZNodes());
- }
- [HttpPost("/Admin/SetPermissions/{id}")]
- public IActionResult SetPermissions([FromRoute] string id, [FromBody] IEnumerable<MenuDto> dto)
- {
- return Ok(_adminService.SetPermissions(id, dto));
- }
- [HttpPost("/Admin/Permissions/{id}")]
- public IActionResult GetPermissions([FromRoute] string id)
- {
- return Ok(_adminService.GetPermissions(id));
- }
- }
- }
|