using Microsoft.AspNetCore.Mvc;
|
using IStation.Model.Api;
|
using System.Net;
|
using System.Net.Http.Headers;
|
using Microsoft.Extensions.Hosting.Internal;
|
using Microsoft.AspNetCore.Http.Extensions;
|
using IStation.Untity;
|
|
namespace IStation.WebApi.Controllers
|
{
|
/// <summary>
|
/// UserAuthority标准Api
|
/// </summary>
|
[ApiController]
|
[Route("v1/Standard/UserAuthority")]
|
[ApiExplorerSettings(GroupName = "v1")]
|
public class UserAuthority_StandardController : ControllerBase
|
{
|
private Service.UserAuthority _service = new Service.UserAuthority();
|
|
/// <summary>
|
/// 通过 UserID 获取可下发的页面权限项列表
|
/// </summary>
|
[Route("GetAuthorizePageAuthTreeItemList")]
|
[HttpGet]
|
public Result GetAuthorizePageAuthTreeItemList(long UserID, string SoftType, string SoftTag)
|
{
|
if (UserID < 1)
|
{
|
return new Result(Code.Error, "UserID 参数错误");
|
}
|
if (string.IsNullOrEmpty(SoftType))
|
{
|
return new Result(Code.Error, "SoftTag 参数错误");
|
}
|
if (string.IsNullOrEmpty(SoftTag))
|
{
|
return new Result(Code.Error, "SoftTag 参数错误");
|
}
|
|
var list = _service.GetAuthorizePageAuthTreeItemList(UserID, SoftType, SoftTag);
|
return new Result<List<Model.AuthorizePageAuthTreeItem>>(list);
|
}
|
|
/// <summary>
|
/// 通过 UserID 获取页面权限项列表
|
/// </summary>
|
[Route("GetPageAuthTreeItemList")]
|
[HttpGet]
|
public Result GetPageAuthTreeItemList(long UserID, string SoftType, string SoftTag)
|
{
|
if (UserID < 1)
|
{
|
return new Result(Code.Error, "UserID 参数错误");
|
}
|
if (string.IsNullOrEmpty(SoftType))
|
{
|
return new Result(Code.Error, "SoftTag 参数错误");
|
}
|
if (string.IsNullOrEmpty(SoftTag))
|
{
|
return new Result(Code.Error, "SoftTag 参数错误");
|
}
|
var list = _service.GetPageAuthTreeItemList(UserID, SoftType, SoftTag);
|
return new Result<List<Model.PageAuthTreeItem>>(list);
|
}
|
|
/// <summary>
|
/// 通过 UserID 获取页面权限拥有项列表
|
/// </summary>
|
[Route("GetPageAuthHaveTreeItemList")]
|
[HttpGet]
|
public Result GetPageAuthHaveTreeItemList(long UserID, string SoftType, string SoftTag)
|
{
|
if (UserID < 1)
|
{
|
return new Result(Code.Error, "UserID 参数错误");
|
}
|
if (string.IsNullOrEmpty(SoftType))
|
{
|
return new Result(Code.Error, "SoftTag 参数错误");
|
}
|
if (string.IsNullOrEmpty(SoftTag))
|
{
|
return new Result(Code.Error, "SoftTag 参数错误");
|
}
|
var list = _service.GetPageAuthHaveTreeItemList(UserID, SoftType, SoftTag);
|
return new Result<List<Model.PageAuthHaveTreeItem>>(list);
|
}
|
|
|
/// <summary>
|
/// 通过 UserID 获取可下发的页面权限树列表
|
/// </summary>
|
[Route("GetAuthorizePageAuthTreeList")]
|
[HttpGet]
|
public Result GetAuthorizePageAuthTreeList(long UserID, string SoftType, string SoftTag)
|
{
|
if (UserID < 1)
|
{
|
return new Result(Code.Error, "UserID 参数错误");
|
}
|
if (string.IsNullOrEmpty(SoftType))
|
{
|
return new Result(Code.Error, "SoftTag 参数错误");
|
}
|
if (string.IsNullOrEmpty(SoftTag))
|
{
|
return new Result(Code.Error, "SoftTag 参数错误");
|
}
|
var list = _service.GetAuthorizePageAuthTreeList(UserID, SoftType, SoftTag);
|
return new Result<List<Model.AuthorizePageAuthTree>>(list);
|
}
|
|
/// <summary>
|
/// 通过 UserID 获取页面权限树列表
|
/// </summary>
|
[Route("GetPageAuthTreeList")]
|
[HttpGet]
|
public Result GetPageAuthTreeList(long UserID, string SoftType, string SoftTag)
|
{
|
if (UserID < 1)
|
{
|
return new Result(Code.Error, "UserID 参数错误");
|
}
|
if (string.IsNullOrEmpty(SoftType))
|
{
|
return new Result(Code.Error, "SoftTag 参数错误");
|
}
|
if (string.IsNullOrEmpty(SoftTag))
|
{
|
return new Result(Code.Error, "SoftTag 参数错误");
|
}
|
var list = _service.GetPageAuthTreeList(UserID, SoftType, SoftTag);
|
return new Result<List<Model.PageAuthTree>>(list);
|
}
|
|
/// <summary>
|
/// 获取页面拥有权限树列表
|
/// </summary>
|
[Route("GetPageAuthHaveTreeList")]
|
[HttpGet]
|
public Result GetPageAuthHaveTreeList(long UserID, string SoftType, string SoftTag)
|
{
|
if (UserID < 1)
|
{
|
return new Result(Code.Error, "UserID 参数错误");
|
}
|
if (string.IsNullOrEmpty(SoftType))
|
{
|
return new Result(Code.Error, "SoftTag 参数错误");
|
}
|
if (string.IsNullOrEmpty(SoftTag))
|
{
|
return new Result(Code.Error, "SoftTag 参数错误");
|
}
|
var list = _service.GetPageAuthHaveTreeList(UserID, SoftType, SoftTag);
|
return new Result<List<Model.PageAuthHaveTree>>(list);
|
|
}
|
|
/// <summary>
|
/// 下发权限
|
/// </summary>
|
[Route("Authorize")]
|
[HttpPost]
|
public Result Authorize(Model.UserAuthorize model)
|
{
|
if (model == null)
|
{
|
return new Result(Code.Error, "参数错误");
|
}
|
if (model.UserID < 1)
|
{
|
return new Result(Code.Error, "UserID 参数错误");
|
}
|
if (model.AuthItems == null || model.AuthItems.Count() < 1)
|
{
|
return new Result(Code.Error, "AuthItems 参数错误");
|
}
|
var status = _service.Authorize(model.UserID, model.AuthItems);
|
return new Result<Model.eAuthorizeStatus>(status);
|
}
|
|
|
}
|
}
|