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 TestController : ControllerBase
    {
        private readonly ITest_CategoryInfoServices test_CategoryInfoServices;
        private readonly ITest_QuestionInfoServices test_QuestionInfoServices;
        private readonly IV_SubjectSelectServices v_SubjectSelectServices;
        private readonly ITest_PsychMeasurementInfoServices test_PsychMeasurementInfoServices;
        private readonly IT_EnrollmentPlanedescServices t_EnrollmentPlanedescServices;

        public TestController(ITest_CategoryInfoServices ITest_CategoryInfoServices
            , ITest_QuestionInfoServices ITest_QuestionInfoServices
            , ITest_PsychMeasurementInfoServices ITest_PsychMeasurementInfoServices
            , IV_SubjectSelectServices IV_SubjectSelectServices
            , IT_EnrollmentPlanedescServices IT_EnrollmentPlanedescServices)
        {
            test_CategoryInfoServices = ITest_CategoryInfoServices;
            test_QuestionInfoServices = ITest_QuestionInfoServices;
            test_PsychMeasurementInfoServices = ITest_PsychMeasurementInfoServices;
            v_SubjectSelectServices = IV_SubjectSelectServices;
            t_EnrollmentPlanedescServices = IT_EnrollmentPlanedescServices;
        }

        /// <summary>
        /// 获取分类  根绝type 
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<MessageModel<List<CategoryInfoResult>>> GetCateSelectByType([FromQuery] CategoryInfoQuery query)
        {
            var result = await test_CategoryInfoServices.GetCateSelectByType(query);
            return new MessageModel<List<CategoryInfoResult>>()
            {
                success = true,
                msg = "获取成功",
                response = result
            };
        }

        /// <summary>
        /// 获取个人某个维度测评结果
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<List<PsychMeasurementListResult>>> GetPsychListByCateAndCustomerId([FromQuery] PsychMeasurementQuery query)
        {
            var result = await test_PsychMeasurementInfoServices.GetPsychListByCateAndCustomerId(query);
            return new MessageModel<List<PsychMeasurementListResult>>()
            {
                msg = "获取成功",
                success = true,
                response = result
            };
        }

        /// <summary>
        /// 获取测评状态
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<CategoryStatusResult>> GetTestStatus([FromQuery] CategoryStatusQuery query)
        {
            var result = await test_CategoryInfoServices.GetTestStatus(query);
            return new MessageModel<CategoryStatusResult>()
            {
                msg = "获取成功",
                success = true,
                response = result
            };
        }

        /// <summary>
        /// 获取问题
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<List<appQuestionResult>>> GetQuestion([FromQuery] appQuestionQuery query)
        {
            var result = await test_QuestionInfoServices.GetQuestion(query);
            return new MessageModel<List<appQuestionResult>>()
            {
                success = true,
                msg = "获取成功",
                response = result
            };
        }

        /// <summary>
        /// 获取mbti试题
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<List<QuestionMBTI>>> GetQuestionMBTI()
        {
            var result = await test_QuestionInfoServices.GetQuestionMBTI();
            return new MessageModel<List<QuestionMBTI>>()
            {
                success = true,
                msg = "获取成功",
                response = result
            };
        }

        /// <summary>
        /// 提交
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [Authorize]
        public async Task<MessageModel<bool>> SavePsych([FromBody] SavePsychQuery query)
        {
            var result = await test_PsychMeasurementInfoServices.SavePsych(query);
            return new MessageModel<bool>()
            {
                success = result,
                msg = result == true ? "提交成功" : "提交失败",
                response = result
            };
        }

        /// <summary>
        /// 提交  霍兰德和MBTI
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        [Authorize]
        public async Task<MessageModel<bool>> SaveHolland(SaveHollandQuery query)
        {
            var result = await test_PsychMeasurementInfoServices.SaveHolland(query);
            return new MessageModel<bool>()
            {
                success = result,
                msg = result == true ? "提交成功" : "提交失败",
                response = result
            };
        }

        /// <summary>
        /// 获取学生发展
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<ShowPsychologicalResult>> GetPsychDetail([FromQuery] ResultLookQuery query)
        {
            var result = await test_PsychMeasurementInfoServices.GetPsychDetail(query);
            return new MessageModel<ShowPsychologicalResult>()
            {
                success = true,
                msg = "获取成功",
                response = result
            };
        }

        /// <summary>
        /// 获取霍兰德测评结果
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<TagtestingHollandResult>> GetHollandResult([FromQuery] ResultLookQuery query)
        {
            var result = await test_PsychMeasurementInfoServices.GetHollandResult(query);
            return new MessageModel<TagtestingHollandResult>()
            {
                success = true,
                msg = "获取成功",
                response = result
            };
        }

        /// <summary>
        /// 获取MBTI测评结果
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<UserResult>> GetMBTIResult([FromQuery] ResultLookQuery query)
        {
            var result = await test_PsychMeasurementInfoServices.GetMBTIResult(query);
            return new MessageModel<UserResult>()
            {
                success = true,
                msg = "获取成功",
                response = result
            };
        }


        /// <summary>
        /// 学科探索 结果
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<SubjectEvBillDTO>> SubjectChartRadar([FromQuery] ResultLookQuery query)
        {
            return await test_PsychMeasurementInfoServices.SubjectChartRadar(query);
        }

        /// <summary>
        /// 传入用户Id 获取霍兰德测评状态
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<string>> GetHollandStatus([FromQuery] IdQuery query)
        {
            return await test_PsychMeasurementInfoServices.GetHollandStatus(query);
        }

        /// <summary>
        /// 传入用户Id 获取学科探索测评状态
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<bool>> GetSubjectSelectStatus([FromQuery] IdQuery query)
        {
            return await test_PsychMeasurementInfoServices.GetSubjectSelectStatus(query);
        }


        /// <summary>
        /// 获取我的自选科目
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<string>> GetSubjectSelect([FromQuery] IdQuery query)
        {
            return await v_SubjectSelectServices.GetSubjectSelect(query);
        }

        /// <summary>
        /// 保存我的选科
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        [Authorize]
        public async Task<MessageModel<bool>> SaveSubjectSelect([FromBody] SubjectSelectQuery query)
        {
            return await v_SubjectSelectServices.SaveSubjectSelect(query);
        }

        /// <summary>
        /// 根据标签推荐选科
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<string>> GetSubjectSelectByTag([FromQuery] ByTagSubjectSelectQuery query)
        {
            return await t_EnrollmentPlanedescServices.GetSubjectSelectByTag(query);
        }

        /// <summary>
        /// 获取测评最新周期Id
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public async Task<MessageModel<CycleInfoResult>> GetReportCycleInfo([FromQuery] IdQuery query)
        {
            return await test_PsychMeasurementInfoServices.GetReportCycleInfo(query);
        }

        /// <summary>
        /// 获取三种推荐选科
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        //[Authorize]
        public async Task<MessageModel<List<SubjectSelectResult>>> GetSubjectSelectResult([FromQuery] NewSubjectQuery query)
        {
            return await test_PsychMeasurementInfoServices.GetSubjectSelectResult(query);
        }


        /// <summary>
        /// 根绝霍兰德获取推荐选科
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        //[Authorize]
        public async Task<MessageModel<string>> GetHollandSubject([FromQuery]HollandSubjectQuery query)
        {
            return await test_PsychMeasurementInfoServices.GetHollandSubject(query);
        }
    }
}
