70 lines
2.5 KiB
C#
70 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using IRaCIS.Api.Filter;
|
|
using IRaCIS.Application.Interfaces;
|
|
using IRaCIS.Application.ViewModels;
|
|
using IRaCIS.Core.Application.Contracts.RequestAndResponse;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace IRaCIS.Api.Controllers
|
|
{
|
|
[Route("role")]
|
|
[ApiController, Authorize, ApiExplorerSettings(GroupName = "Management")]
|
|
public class RoleController : ControllerBase
|
|
{
|
|
private readonly IRoleService _roleService;
|
|
public RoleController(IRoleService roleService)
|
|
{
|
|
_roleService = roleService;
|
|
}
|
|
|
|
/// <summary> 添加角色 </summary>
|
|
[HttpPost, Route("addOrUpdateRole")]
|
|
[LogFilter]
|
|
public IResponseOutput AddOrUpdateRole(RoleCommand role)
|
|
{
|
|
var userId = Guid.Parse(User.FindFirst("id").Value);
|
|
return _roleService.AddOrUpdateRole(role, userId);
|
|
}
|
|
|
|
///// <summary> 复制角色 </summary>
|
|
//[HttpPost, Route("copyRole/{sourceRoleId:guid}")]
|
|
//public IResponseOutput<Guid> CopyRole(Guid sourceRoleId, RoleAddOrUpdateModel role)
|
|
//{
|
|
// return _roleService.CopyRole(sourceRoleId,role);
|
|
//}
|
|
|
|
/// <summary> 删除角色 </summary>
|
|
[HttpDelete, Route("deleteRole/{roleId:guid}")]
|
|
[LogFilter]
|
|
public IResponseOutput DeleteRole(Guid roleId)
|
|
{
|
|
return _roleService.DeleteRole(roleId);
|
|
}
|
|
|
|
/// <summary> 分页获取角色列表 </summary>
|
|
[HttpGet, Route("getRoleList/{pageIndex:int}/{pageSize:int}")]
|
|
public IResponseOutput<PageOutput<RoleDTO>> GetRoleListByPage(int pageIndex, int pageSize)
|
|
{
|
|
return ResponseOutput.Ok(_roleService.GetRoleListByPage(pageIndex, pageSize));
|
|
}
|
|
|
|
/// <summary> 获取用户角色列表 </summary>
|
|
[HttpGet, Route("getRoleList/{userId:guid}/{pageIndex:int}/{pageSize:int}")]
|
|
public IResponseOutput<PageOutput<UserSelectRoleDTO>> GetRoleListByPage(Guid userId, int pageIndex, int pageSize)
|
|
{
|
|
return ResponseOutput.Ok(_roleService.GetRoleListByPage(userId, pageIndex, pageSize));
|
|
}
|
|
|
|
/// <summary> 更新用户角色 </summary>
|
|
[HttpPost, Route("UpdateUserRole")]
|
|
[LogFilter]
|
|
public IResponseOutput UpdateUserRole(UserRoleSelectDTO userSelectRoleModel)
|
|
{
|
|
return _roleService.UpdateUserRole(userSelectRoleModel.userId, userSelectRoleModel.roleId, userSelectRoleModel.isSelect);
|
|
}
|
|
|
|
}
|
|
}
|