import apiRequest from '@/network/http/apiRequest'

/**
 * 分页查询发送消息
 * @param data
 * @returns
 */
export function getMsgSentByPage(data: any) {
  return apiRequest({
    url: '/msg/sent/page',
    method: 'GET',
    params: data,
  })
}

/**
 * 分页查询接收消息
 * @param data
 * @returns
 */
export function getMsgReceivedByPage(data: any) {
  return apiRequest({
    url: '/msg/received/page',
    method: 'GET',
    params: data,
  })
}

/**
 * 基于ID获取消息详情
 * @param msgId
 * @returns
 */
export function getMsgById(msgId: number) {
  return apiRequest({
    url: `/msg/${msgId}`,
    method: 'GET',
  })
}

/**
 * 基于ID置已读状态
 * @param msgId
 * @returns
 */
export function putReadStatus(msgId: number) {
  return apiRequest({
    url: `/msg/read/${msgId}`,
    method: 'PUT',
  })
}

/**
 * 获取未读消息数目
 * @returns
 */
export function getUnReadCounter() {
  return apiRequest({
    url: '/msg/unread/count',
    method: 'GET',
  })
}

/**
 * 发送消息
 * @param data
 * @returns
 */
export function sendMsg(data: any) {
  return apiRequest({
    url: '/msg/send',
    method: 'POST',
    data,
  })
}

/**
 * 删除消息
 * @param msgId
 * @returns
 */
export function deleteMsgById(msgId: number) {
  return apiRequest({
    url: `/msg/${msgId}`,
    method: 'DELETE',
  })
}
