using System.Collections.Generic;
using System.Threading.Tasks;
using GxPress.Repository.Interface;
using GxPress.Request.Role;
using GxPress.Result.Role;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace GxPress.Api.AdminControllers
{
///
/// 角色
///
[Route("api/admin/role")]
[ApiController]
[Authorize]
public class AdminRoleController : ControllerBase
{
private readonly IRoleRepository _roleRepository;
public AdminRoleController(IRoleRepository roleRepository)
{
_roleRepository = roleRepository;
}
///
/// 添加
///
///
///
[HttpPost]
public async Task Add(RoleAddRequest request)
{
return await _roleRepository.AddAsync(request);
}
///
/// 删除
///
///
///
[HttpDelete("{id}")]
public async Task Delete(int id)
{
return await _roleRepository.DeleteAsync(id);
}
///
/// 修改
///
///
///
///
[HttpPut("{id}")]
public async Task Update(int id, [FromBody]RoleAddRequest request)
{
return await _roleRepository.UpdateAsync(id, request);
}
///
/// 详情
///
///
///
[HttpGet("{id}")]
public async Task GetDetail(int id)
{
return await _roleRepository.GetDetailAsync(id);
}
///
/// 列表
///
///
///
[HttpGet("list")]
public async Task> GetList(int groupId)
{
return await _roleRepository.GetDetailListAsync(groupId);
}
}
}