using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using New_College.IServices;
using New_College.Model;
using New_College.Model.ViewModels;

namespace New_College.Api.Controllers.Front
{
    [Route("api/front/[controller]/[action]")]
    [ApiController]

    public class VipController : ControllerBase
    {
        private readonly IV_VipCardTypeServices v_VipCardTypeServices;
        private readonly IV_VipCardInfoServices v_VipCardInfoServices;
        public VipController(IV_VipCardTypeServices IV_VipCardTypeServices,
            IV_VipCardInfoServices IV_VipCardInfoServices)
        {
            v_VipCardTypeServices = IV_VipCardTypeServices;
            v_VipCardInfoServices = IV_VipCardInfoServices;
        }

        /// <summary>
        /// 获取Vip卡列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<MessageModel<List<VipCardTypeResult>>> GetVipCardTypeList()
        {
            var result = await v_VipCardTypeServices.GetVipCardTypeList();
            return new MessageModel<List<VipCardTypeResult>>()
            {
                success = true,
                msg = "获取成功",
                response = result
            };
        }

        /// <summary>
        /// 绑定卡
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        [Authorize]
        public async Task<MessageModel<bool>> BindCardInfo(VipCardQuery query)
        {
            return await v_VipCardInfoServices.BindCardInfo(query);
        }

        /// <summary>
        /// 获取vip信息 传用户Id
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<VipInfoResult>> GetVipInfo([FromQuery] IdQuery query)
        {
            return await v_VipCardInfoServices.GetVipInfo(query);
        }
    }
}
