import request from '@/utils/request'

export interface SessionVO {
  sessionId?: number
  sessionNo?: string
  sessionType: number
  fromUserId: number
  fromUserName: string
  fromUserAvatar?: string
  lastMsg?: string
  lastMsgTime?: string
  unreadCount?: number
  status?: number
  waiterInfo?: {
    waiterId: number
    waiterName: string
    waiterAvatar: string
    isOnline: boolean
  }
}

export interface SessionQuery {
  sessionType?: number
  status?: number
  keyword?: string
  pageNum: number
  pageSize: number
}

export const createSession = (data: Partial<SessionVO>) => {
  return request({
    url: '/main/session/create',
    method: 'post',
    data
  })
}

export const getSessionList = (query: SessionQuery) => {
  return request({
    url: '/main/session/list',
    method: 'get',
    params: query
  })
}

export const endSession = (sessionId: number) => {
  return request({
    url: `/main/session/${sessionId}/end`,
    method: 'put'
  })
}

export const forceEndSession = (sessionId: number) => {
  return request({
    url: `/main/session/${sessionId}/force-end`,
    method: 'put'
  })
}
