import {request} from "@/api/request";

export interface Meeting {
  id: number
  /** 部门ID */
  dep_id: number | null;
  department_id: number | null;
  company_id: number,
  companyId: number,
  /** 现场会描述 */
  description: string;
  /** 预计结束时间 */
  estimate_end_time: number;
  /** 预计开始时间 */
  estimate_start_time: number;
  /** 现场会标题 */
  name: string;
  status: 0
    | 1 // 已开始
    | 2 // 进行中
    | 3 // 结束中
}

interface MeetingInfo {
  type: number
  data: Meeting
}

export const meetingAPi = {
  setMeetings(data: Meeting) {
    return request<{ id: number }>('/api/v1/meetings/meeting', "POST", data)
  },
  putMeeting(id: number, data: Partial<Meeting>) {
    return request(`/api/v1/meetings/meeting/${id}`, "PUT", data)
  },
  setMeeting(id: string) {
    return request<Meeting>(`/api/v1/meetings/meeting/${id}`, "GET")
  },
  setList(page: number, page_size: number) {
    return request<{
      data: Meeting[],
      total: number
    }>(`/api/v1/meetings/meeting?page=${page}&page_size=${page_size}`, "GET")
  },
  exists() {
    return request<Meeting>('/api/v1/meetings/exists', "GET")
  },
  del(id: number) {
    return request(`/api/v1/meetings/meeting/${id}`, "DELETE")
  },
  start(id: number) {
    return request(`/api/v1/meetings/meeting/${id}/start`, "PUT")
  },
  end(id: number) {
    return request(`/api/v1/meetings/meeting/${id}/end`, "PUT")
  },
  meetingInfo(id: string) {
    return request<MeetingInfo>(`/api/v1/meetings/meeting/info?id=${id}`, "GET")
  }
}
