package com.ruoyi.web.controller.liandao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.DeleteBody;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.liandao.domain.TourGuideAppointment;
import com.ruoyi.liandao.domain.TourGuideInfo;
import com.ruoyi.liandao.dto.tourGuide.TourGuideAppointmentAddReqDto;
import com.ruoyi.liandao.dto.tourGuide.TourGuideInfoAddReqDto;
import com.ruoyi.liandao.dto.tourGuide.TourGuideInfoEditReqDto;
import com.ruoyi.liandao.dto.tourGuide.TourGuidePageReqDto;
import com.ruoyi.liandao.service.TourGuideAppointmentService;
import com.ruoyi.liandao.service.TourGuideInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 导游数据
 * @Author : chenzhengyu
 * @create 2024/3/18 13:34
 */
@RestController
@RequestMapping("/liandao/tour/guide")
public class TourGuideController extends BaseController {

    @Autowired
    private TourGuideInfoService infoService;
    @Autowired
    private TourGuideAppointmentService appointmentService;

    /**
     * 导游信息分页查询
     * @param dto
     * @return
     */
    @GetMapping("/info/page")
    public TableDataInfo infoPage(TourGuidePageReqDto dto){
        IPage<TourGuideInfo> iPage = infoService.getPage(dto);
        return getDataTable(iPage);
    }

    /**
     * 导游信息添加
     * @param dto
     * @return
     */
    @PostMapping("/info/add")
    public AjaxResult infoAdd(@RequestBody TourGuideInfoAddReqDto dto){
        infoService.add(dto);
        return success();
    }

    /**
     * 导游信息修改
     * @param dto
     * @return
     */
    @PostMapping("/info/edit")
    public AjaxResult infoEdit(@RequestBody TourGuideInfoEditReqDto dto){
        infoService.edit(dto);
        return success();
    }

    /**
     * 导游信息 根据id查看详情
     * @param id
     * @return
     */
    @GetMapping("/info/detail")
    public AjaxResult infoDetail(@RequestParam Long id){
        TourGuideInfo tourGuideInfo = infoService.getById(id);
        return success(tourGuideInfo);
    }

    /**
     * 导游信息删除
     * @param deleteBody
     * @return
     */
    @PostMapping("/info/delete")
    public AjaxResult infoDelete(@RequestBody DeleteBody deleteBody){
        infoService.removeById(deleteBody.getId());
        return success();
    }

    /**
     * 导游预约分页查询
     * @param dto
     * @return
     */
    @GetMapping("/appointment/page")
    public TableDataInfo appointmentPage(TourGuidePageReqDto dto){
        IPage<TourGuideAppointment> iPage = appointmentService.getPage(dto);
        return getDataTable(iPage);
    }

    /**
     * 导游预约新增
     * @param dto
     * @return
     */
    @PostMapping("/appointment/add")
    public AjaxResult appointmentAdd(@RequestBody TourGuideAppointmentAddReqDto dto){
        appointmentService.add(dto);
        return success();
    }

}
