package com.fs.app.controller;

import com.fs.delivery.domain.CtCloudClass;
import com.fs.delivery.domain.CtLongVideo;
import com.fs.delivery.domain.CtShortVideo;
import com.fs.delivery.service.ICtCloudClassService;
import com.fs.delivery.service.ICtLongVideoService;
import com.fs.delivery.service.ICtShortVideoService;
import com.fs.doctor.domain.Doctor;
import com.fs.task.domain.TaskDeliveryInfo;
import com.fs.task.dto.PublicIndexDto;
import com.fs.app.service.AppTaskService;
import com.fs.common.core.domain.AjaxResult;
import com.fs.task.mapper.TaskInfoMapper;
import com.fs.task.service.ITaskDeliveryInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "首页开放数据中心")
@RestController
@RequestMapping(value="/app/index")
public class PublicIndexController extends AppBaseController {
    @Autowired
    private ICtCloudClassService iCtCloudClassService;



    @ApiOperation("空中课堂： 根据配置列表获取视频资料列表")
    @PostMapping("/getClassroomList")
    public AjaxResult getClassroomList(@RequestBody CtCloudClass ctCloudClass) {
//        startPage();
//        List<PublicIndexDto> publicIndexDtoList = appTaskService.getClassroomList(publicIndexDto);
//        return AjaxResult.success(getDataTable(publicIndexDtoList));
        startPage();
        List<CtCloudClass> ctCloudClasses = iCtCloudClassService.selectCtCloudClassList(ctCloudClass);
        return AjaxResult.success(getDataTable(ctCloudClasses));
    }

    @ApiOperation("查询课堂信息详情")
    @GetMapping("/getClassroomDetail/{cloudClassId}")
    public AjaxResult getClassroomDetail(@PathVariable("cloudClassId") Long cloudClassId) {
//        PublicIndexDto result = new PublicIndexDto();
//        TaskDeliveryInfo taskDeliveryInfo = new TaskDeliveryInfo();
//        if (publicIndexDto.getVideoType().equals("long")){
//            CtLongVideo ctLongVideo = iCtLongVideoService.selectCtLongVideoById(publicIndexDto.getId());
//            result.setVideoUrl(ctLongVideo.getVideoUrl());
//            result.setSummary(ctLongVideo.getSummary());
//            result.setCreateTime(ctLongVideo.getCreateTime());
//
//            taskDeliveryInfo.setProjectLink(ctLongVideo.getId().toString());
//            taskDeliveryInfo.setTaskType(6);
//            TaskDeliveryInfo taskDeliveryInfo1 = iTaskDeliveryInfoService.selectTaskDeliveryInfoList(taskDeliveryInfo).get(0);
//            result.setViewCount(taskDeliveryInfo1.getViewCount());
//
//            Doctor doctor = taskInfoMapper.getTaskDoctorDetail(ctLongVideo.getId().toString());
//            result.setInstitution(doctor.getInstitution());
//            result.setDoctorName(doctor.getDoctorName());
//            result.setJobTitle(doctor.getJobTitle());
//            result.setDepartment(doctor.getDepartment());
//
//        }else if (publicIndexDto.getVideoType().equals("short")){
//            CtShortVideo ctShortVideo = iCtShortVideoService.selectCtShortVideoById(publicIndexDto.getId());
//            result.setVideoUrl(ctShortVideo.getVideoUrl());
//            result.setSummary(ctShortVideo.getSummary());
//            result.setCreateTime(ctShortVideo.getCreateTime());
//
//            taskDeliveryInfo.setProjectLink(ctShortVideo.getId().toString());
//            taskDeliveryInfo.setTaskType(5);
//            TaskDeliveryInfo taskDeliveryInfo1 = iTaskDeliveryInfoService.selectTaskDeliveryInfoList(taskDeliveryInfo).get(0);
//            result.setViewCount(taskDeliveryInfo1.getViewCount());
//
//            Doctor doctor = taskInfoMapper.getTaskDoctorDetail(ctShortVideo.getId().toString());
//            result.setInstitution(doctor.getInstitution());
//            result.setDoctorName(doctor.getDoctorName());
//            result.setJobTitle(doctor.getJobTitle());
//            result.setDepartment(doctor.getDepartment());
//        }
        CtCloudClass ctCloudClass = iCtCloudClassService.selectCtCloudClassByCloudClassId(cloudClassId);


        return AjaxResult.success(ctCloudClass);
    }




}
