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]
    [Authorize]
    public class UniversityCollectionController : ControllerBase
    {
        private readonly ID_UniversityCollectionServices d_UniversityCollectionServices;
        private readonly ID_UniversityServices d_UniversityServices;
        public UniversityCollectionController(ID_UniversityCollectionServices ID_UniversityCollectionServices
            , ID_UniversityServices ID_UniversityServices)
        {
            d_UniversityCollectionServices = ID_UniversityCollectionServices;
            d_UniversityServices = ID_UniversityServices;
        }

        /// <summary>
        /// 获取收藏和对比
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<MessageModel<PageModel<UniversityCollectionResult>>> GetUniversityCollection([FromQuery] UniversityCollectionQuery query)
        {
            return await d_UniversityCollectionServices.GetUniversityCollection(query);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<MessageModel<bool>> DeleteCollection(UniversityCollectionAddQuery query)
        {
            return await d_UniversityCollectionServices.DeleteCollection(query);
        }

        /// <summary>
        /// 添加收藏、对比
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<MessageModel<bool>> AddCollection([FromBody] UniversityCollectionAddQuery query)
        {
            return await d_UniversityCollectionServices.AddCollection(query);
        }

        /// <summary>
        /// 获取院校对比结果  传Ids
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<MessageModel<List<UniversitycontrastResult>>> GetUniversityContrasts([FromBody] IdQuery query)
        {
            return await d_UniversityCollectionServices.GetUniversityContrasts(query);
        }

        /// <summary>
        /// 获取搜索学校
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<MessageModel<List<IdNameResult>>> GetUniversitList([FromQuery] NameQuery query)
        {
            return await d_UniversityServices.GetUniversitList(query);
        }


        /// <summary>
        /// 报告  获取我喜欢的院校
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<MessageModel<List<UniversityCollectionByMapResult>>> GetUniversityMap([FromQuery] IdQuery query)
        {
            return await d_UniversityCollectionServices.GetUniversityMap(query);
        }
    }
}
