package com.usky.meeting.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.common.security.annotation.InnerAuth;
import com.usky.meeting.domain.MeetingInfo;
import com.usky.meeting.service.MeetingInfoService;
import com.usky.meeting.service.dto.DmMeetingDto;
import com.usky.meeting.service.dto.DmMeetingDtoV2;
import com.usky.meeting.service.vo.MeetingInfoRequestVO;
import com.usky.meeting.service.vo.MyMeetingInfoRequestVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 会议表(预约成功) 前端控制器
 * </p>
 *
 * @author zyj
 * @since 2024-03-08
 */
@RestController
@RequestMapping("/meetingInfo")
public class MeetingInfoController {
    @Autowired
    private MeetingInfoService meetingInfoService;

    /**
     * 新增会议
     * @param resources
     * @return
     */
    @PostMapping("add")
    public ApiResult<DmMeetingDto> add(@Validated @RequestBody DmMeetingDto resources){
        return ApiResult.success(meetingInfoService.add(resources));
    }

    /**
     * 查询会议记录
     * @param requestVO
     * @return
     */
    @PostMapping("meetingInfoList")
    public ApiResult<CommonPage<MeetingInfo>> meetingInfoList(@RequestBody MeetingInfoRequestVO requestVO){
        return ApiResult.success(meetingInfoService.meetingInfoList(requestVO));
    }

    /**
     * 取消会议预约申请
     * @param meetingId
     * @return
     */
    @PostMapping("cancel")
    public ApiResult<Void> cancel(@RequestParam Long meetingId){
        meetingInfoService.cancel(meetingId);
        return ApiResult.success();
    }

    /**
     * 我的会议列表
     * @param requestVO
     * @return
     */
    @PostMapping("myMeetingList")
    public ApiResult<CommonPage<MeetingInfo>> myMeetingList(@RequestBody MyMeetingInfoRequestVO requestVO){
        return ApiResult.success(meetingInfoService.myMeetingList(requestVO));
    }

    /**
     * 查询会议签到信息
     * @param meetingId
     * @return
     */
    @GetMapping("meetingSignList")
    public ApiResult<List<Map<String,Object>>> meetingSignList(@RequestParam(value = "meetingId") Long meetingId){
        return ApiResult.success(meetingInfoService.meetingSignList(meetingId));
    }

    /**
     * 人员签到/人员签退
     * @param requestVO
     * @return
     */
    @PostMapping("signOnOut")
    public ApiResult<Void> signOnOut(@RequestBody SignOnOutRequestVO requestVO){
        meetingInfoService.signOnOut(requestVO);
        return ApiResult.success();
    }



}







