using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;

namespace Application.Web.Controllers.Login
{
    /// <summary>
    /// 登录接口
    /// </summary>
    [ApiExplorerSettings(GroupName = "Login")]
    [Route("[controller]/[action]")]
    [ApiController]    
    public class LoginController : ControllerBase
    {
        private readonly IHubContext<ChatHub> _hubContext;
        public LoginController(IHubContext<ChatHub> hubContext)
        {
            _hubContext = hubContext;
        }
       /// <summary>
       /// 登录接口
       /// </summary>
       /// <param name="parms"></param>
       /// <returns></returns>
        [HttpPost]
        public async Task<IPoAction> Login([FromBody] LoginParms parms)
        {
            
            return PoAction.Ok(parms.code);
        }
        /// <summary>
        /// 测试接口
        /// </summary>
        /// <param name="name">测试名</param>
        /// <param name="ttt">测试2</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IPoAction> Test(string name,string ttt)
        {
           await _hubContext.Clients.All.SendAsync("ReceiveMessage", "系统"); 

            return PoAction.Ok(name);
            
        }

    }
}
