using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ASHermed.SinoInterface.Api.ContractModel.Framework.Login;
using ASHermed.SinoInterface.Api.IService.Login;
using ASHermed.SinoInterface.ContractModel;
using ASHermed.SinoInterface.IFramework.SingleSignOn;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace ASHermed.SinoInterface.WebApi.Controllers.Login.v1
{
    /// <summary>
    /// 单点登录
    /// </summary>
    [Route("api/v1/[controller]")]
    [ApiVersion("1.0")]
    [ApiController]
    public class LoginController : ControllerBase
    {
        #region 初始化

        /// <summary>
        /// 用户登录服务
        /// </summary>
        private readonly ISingleSignOnService  singleSignOnService;

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="_singleSignOnService"></param>
        public LoginController(ISingleSignOnService _singleSignOnService)
        {
            singleSignOnService = _singleSignOnService;
        }

        #endregion

        /// <summary>
        /// 发送短信验证码
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("SendSMSVerifyCode")]
        public Task<BaseResponse> SendSMSVerifyCode(SendSMSVerifyCodeParam param)
        {
            return singleSignOnService.SendSMSVerifyCode(param);
        }

        /// <summary>
        /// 通过手机号码和验证码进行单点登录
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("SingleSignOnByPhones")]
        public Task<BaseResponse<SingleSignOnModel>> SingleSignOnByPhones(SingleSignOnByPhonesParam param)
        {
            return singleSignOnService.SingleSignOnByPhones(param);
        }

        /// <summary>
        /// 通过登录名和密码进行单点登录
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("SingleSignOnByLoginId")]
        public Task<BaseResponse<SingleSignOnModel>> SingleSignOnByLoginId(SingleSignOnByLoginIdParam param)
        {
            return singleSignOnService.SingleSignOnByLoginId(param);
        }

        /// <summary>
        /// 退出登录
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("SignOut")]
        public Task<BaseResponse> SignOut(SignOutParam param)
        {
            return singleSignOnService.SignOut(param);
        }
    }
}