using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authorization;
using Api.SignToken;
using MadRunFabric.Common;
using System.Threading;
using System.Security.Claims;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace SignTokenApi.Controllers
{
    [Authorize]
    [Route("api/[controller]")]
    public class PermissionController : BaseController
    {
        private readonly IPermissionService _permissionService;
        private readonly ILogger<PermissionController> _logger;

        public PermissionController(IPermissionService permissionService, ILogger<PermissionController> logger)
        {
            _permissionService = permissionService;
            _logger = logger;
        }


        // GET: api/values
        [HttpGet]
        public async Task<IActionResult> Get()
        {
            var permissionmsg = new List<Permission> {
                              new Permission {  Type="User.Create", Name="system"},
                              new Permission {  Type="User.Read", Name="system"}
                          };
            var result = new
            {
                usercode= User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value,
                permission = permissionmsg
            };
            return Success("权限信息", result);

            //_logger.LogInformation($"111获取所有权限 ");
            //string ss = await GetVAsync();
            ////string ss= await _permissionService.GetPermissionAsync();
            //_logger.LogInformation($"获取所有权限{ss}");
            //return ss;
        }

      

    }
}
