import request from '@/utils/request'
import type { ShopMessage } from './model'

/** 获取消息列表 */
export function listShopMessage(params?: {
  page?: number
  limit?: number
  type?: string
  isRead?: boolean
}) {
  return request.get<{ code: number; data: { list: ShopMessage[]; total: number } }>('/user/message/list', params)
}

/** 获取消息详情 */
export function getShopMessage(id: string) {
  return request.get<{ code: number; data: ShopMessage }>(`/user/message/${id}`)
}

/** 标记消息已读 */
export function readShopMessage(id: string) {
  return request.put<{ code: number }>(`/user/message/read/${id}`)
}

/** 删除消息 */
export function deleteShopMessage(id: string) {
  return request.del<{ code: number }>(`/user/message/${id}`)
}

/** 全部标记已读 */
export function readAllShopMessage() {
  return request.put<{ code: number }>('/user/message/read-all')
}

/** 获取未读消息数量 */
export function getUnreadMessageCount() {
  return request.get<{ code: number; data: { count: number } }>('/user/message/unread-count')
}
