package com.yida.data.school.visitor.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.school.dto.visitor.ListVisitorRecordDTO;
import com.yida.data.school.visitor.service.EduVisitorRecordService;
import com.yida.data.school.vo.visitor.ListVisitorRecordVO;
import com.yida.data.school.vo.visitor.StaVisitorDistributeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 访客管理-来访人员记录表 Controller
 *
 * @author zhanghaijun
 * @date 2021-11-09 15:04:42
 */
@Api(tags = "访客管理-访客记录")
@Slf4j
@Validated
@RestController
@RequestMapping("/visitor/record")
@RequiredArgsConstructor
public class EduVisitorRecordController {

    private final EduVisitorRecordService eduVisitorRecordService;

    @ApiOperation("查询预约记录分页列表")
    @GetMapping("/listRecordPage")
    public ResultBean<IPage<ListVisitorRecordVO>> listRecordPage(ListVisitorRecordDTO dto) {
        return ResultBean.buildSuccess(eduVisitorRecordService.listRecordPage(dto));
    }

    @ApiOperation("变更预约结果")
    @GetMapping("/changeResult")
    public ResultBean changeResult(Long id, Integer result, @RequestParam(required = false) String reason) {
        eduVisitorRecordService.changeResult(id, result, reason);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("看板-查询分布数据")
    @GetMapping("/staVisitorDistribute")
    public ResultBean<StaVisitorDistributeVO> staVisitorDistribute(String startDate,String endDate) {
        return ResultBean.buildSuccess(eduVisitorRecordService.staVisitorDistribute(startDate, endDate));
    }
}
