lg_backend/langguanApi/Controllers/RoleController.cs

98 lines
2.9 KiB
C#
Raw Normal View History

2024-05-28 16:00:38 +00:00
using langguanApi.Model;
using langguanApi.Model.Entity;
using langguanApi.Model.Dto.SystemConfigurationDto;
using langguanApi.Service;
2024-05-28 16:00:38 +00:00
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
namespace langguanApi.Controllers
{
/// <summary>
2024-05-28 16:00:38 +00:00
/// 角色 权限
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class RoleController : ControllerBase
{
2024-05-28 16:00:38 +00:00
public readonly RoleService _roleService;
2024-05-29 15:53:04 +00:00
private readonly RoleMenuServie _roleMenuServie;
public RoleController(RoleService roleService, RoleMenuServie roleMenuServie)
{
_roleService = roleService;
2024-05-29 15:53:04 +00:00
_roleMenuServie = roleMenuServie;
}
/// <summary>
2024-05-28 16:00:38 +00:00
/// 获取角色详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("get")]
public async Task<IActionResult> Get(string id)
{
var role = await _roleService.GetRoleAndMenu(id);
return Ok(role);
}
/// <summary>
/// 添加角色
/// </summary>
/// <param name="role"></param>
/// <returns></returns>
[HttpPost("add")]
public async Task<IActionResult> Add([FromBody] AddRoleDto role)
{
var result = await _roleService.Add(role);
return Ok(result);
}
/// <summary>
/// update角色
/// </summary>
/// <param name="role"></param>
/// <returns></returns>
[HttpPut("update")]
public async Task<IActionResult> Update([FromBody] UpdateRoleDto role)
{
var result = await _roleService.update(role);
return Ok(result);
}
/// <summary>
/// 删除角色
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[HttpDelete("remove")]
public async Task<IActionResult> Remove(IEnumerable<string> ids)
{
var result = await _roleService.Remove(ids);
return Ok(result);
}
/// <summary>
/// 获取角色列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("list")]
public async Task<IActionResult> List([FromQuery] reqpage input)
{
var roles = await _roleService.GetPager(input);
return Ok(roles);
}
/// <summary>
/// 获取所有角色
/// </summary>
/// <returns></returns>
[HttpGet("all")]
public async Task<IActionResult> GetAllrole()
{
var roles = await _roleService.GetAsync();
return Ok(new ApiResult()
{
code = 0,
data = roles.
Select(s => new { s.Id, s.RoleName })
});
}
2024-05-29 09:32:21 +00:00
}
}