package com.yida.data.school.secondClass.controller.out;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.school.secondClass.EduSecondClassVenueOrder;
import com.yida.data.school.dto.secondClass.ListVenueExhibitDTO;
import com.yida.data.school.secondClass.service.EduSecondClassVenueExhibitGroupService;
import com.yida.data.school.secondClass.service.EduSecondClassVenueExhibitService;
import com.yida.data.school.secondClass.service.EduSecondClassVenueGuideService;
import com.yida.data.school.secondClass.service.EduSecondClassVenueOrderService;
import com.yida.data.school.secondClass.service.EduSecondClassVenueService;
import com.yida.data.school.vo.secondClass.VenueExhibitGroupVO;
import com.yida.data.school.vo.secondClass.VenueExhibitVO;
import com.yida.data.school.vo.secondClass.VenueGuideVO;
import com.yida.data.school.vo.secondClass.VenueH5ContentVO;
import com.yida.data.school.vo.secondClass.VenueOrdermemberVO;
import com.yida.data.school.vo.secondClass.VenueVO;
import com.yida.data.school.vo.secondClass.VenueOrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "第二课堂-场馆(不鉴权-外部使用)")
@Slf4j
@Validated
@RestController
@RequestMapping("/out/secondClass/venue")
@RequiredArgsConstructor
public class OutEduSecondClassVenueController {

    private final EduSecondClassVenueService eduSecondClassVenueService;
    private final EduSecondClassVenueExhibitService eduSecondClassVenueExhibitService;
    private final EduSecondClassVenueExhibitGroupService eduSecondClassVenueExhibitGroupService;
    private final EduSecondClassVenueGuideService eduSecondClassVenueGuideService;
    private final EduSecondClassVenueOrderService eduSecondClassVenueOrderService;

    @ApiOperation("查询场馆首页信息")
    @GetMapping("/getHomeInfo")
    public ResultBean<VenueH5ContentVO> getHomeInfo(Long deptId) {
        return ResultBean.buildSuccess(eduSecondClassVenueService.getHomeInfo(deptId));
    }

    @ApiOperation("根据主题分页查询场馆信息")
    @GetMapping("/listVenuePageBySubject")
    public ResultBean<IPage<VenueVO>> listVenuePageBySubject(Integer pageNum, Integer pageSize, Long subjectId) {
        return ResultBean.buildSuccess(eduSecondClassVenueService.listVenuePageBySubject(pageNum, pageSize, subjectId));
    }

    @ApiOperation("查询场馆详情")
    @GetMapping("/getVenueDetail")
    public ResultBean<VenueVO> getVenueDetail(Long id) {
        return ResultBean.buildSuccess(eduSecondClassVenueService.getInfo(id,true));
    }

    @ApiOperation("查询讲解员")
    @GetMapping("/listVenueGuide")
    public ResultBean<List<VenueGuideVO>> listVenueGuide(String time, Integer date, Long venueId) {
        return ResultBean.buildSuccess(eduSecondClassVenueGuideService.listGuide(time, date, venueId));
    }

    @ApiOperation("保存预约记录")
    @PostMapping("/saveVenueOrder")
    public ResultBean saveOrder(@RequestBody EduSecondClassVenueOrder order) {
        eduSecondClassVenueOrderService.saveOrder(order);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("查询预约记录")
    @GetMapping("/listVenueOrder")
    public ResultBean<List<VenueOrderVO>> listVenueOrder(Long venueId, String userId) {
        return ResultBean.buildSuccess(eduSecondClassVenueOrderService.listVenueOrder(venueId, userId));
    }


    @ApiOperation("取消预约")
    @GetMapping("/cancleOrder")
    public ResultBean cancleOrder(Long orderId, String userId) {
        eduSecondClassVenueOrderService.cancleOrder(orderId, userId);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("查询场馆分组信息列表")
    @GetMapping("/listVenueExhibitGroup")
    public ResultBean<List<VenueExhibitGroupVO>> listVenueExhibitGroup(Long venueId) {
        return ResultBean.buildSuccess(eduSecondClassVenueExhibitGroupService.listGroup(venueId));
    }

    @ApiOperation("查询场馆分组信息")
    @GetMapping("/getVenueExhibitGroup")
    public ResultBean<VenueExhibitGroupVO> getVenueExhibitGroup(Long groupId) {
        return ResultBean.buildSuccess(eduSecondClassVenueExhibitGroupService.getInfo(groupId));
    }

    @ApiOperation("查询展品信息列表")
    @GetMapping("/listVenueExhibitPage")
    public ResultBean<IPage<VenueExhibitVO>> listVenueExhibitPage(ListVenueExhibitDTO dto) {
        return ResultBean.buildSuccess(eduSecondClassVenueExhibitService.listExhibitPage(dto));
    }

    @ApiOperation("查询展品信息")
    @GetMapping("/getVenueExhibit")
    public ResultBean<VenueExhibitVO> getVenueExhibit(Long id) {
        return ResultBean.buildSuccess(eduSecondClassVenueExhibitService.getInfo(id));
    }
}
