import request from '@/utils/request';
import { NotificationParams } from './types';
import { AxiosPromise } from 'axios';
// 查询公告列表
/**
 * 获取通知列表
 * @param params 查询参数
 */
export function getNotifications(params: NotificationParams): AxiosPromise<any> {
  return request({
    url: '/system/notification/notifications',
    method: 'get',
    params
  });
}

/**
 * 获取未读通知统计
 */
export function getUnreadCount(): AxiosPromise<any> {
  return request({
    url: '/system/notification/unread/count',
    method: 'get'
  });
}

/**
 * 标记通知为已读
 * @param notificationId 通知ID
 */
export function markNotificationRead(notificationId: number | string): AxiosPromise<any> {
  return request({
    url: `/system/notification/read/${notificationId}`,
    method: 'put'
  });
}

/**
 * 批量标记通知为已读
 * @param notificationIds 通知ID数组
 */
export function batchMarkRead(notificationIds: (number | string)[]): AxiosPromise<any> {
  return request({
    url: '/system/notification/read/batch',
    method: 'put',
    data: { notificationIds }
  });
}

/**
 * 标记所有通知为已读
 * @param type 通知类型（可选）
 */
export function markAllRead(type?: string): AxiosPromise<any> {
  return request({
    url: '/system/notification/read/all',
    method: 'put',
    params: { type }
  });
}

/**
 * 获取用户待办任务列表
 */
export function getTodoList(): AxiosPromise<any> {
  return request({
    url: '/system/notification/todo/list',
    method: 'get'
  });
}

/**
 * 获取用户待办任务列表（含数量，不分页）
 */
export function getTodoListWithCount(): AxiosPromise<any> {
  return request({
    url: '/system/notification/todo/list',  // 路径已合并到notification下
    method: 'get'
  });
}

/**
 * 获取用户待办配置列表（不含数量）
 */
export function getTodoConfigs(): AxiosPromise<any> {
  return request({
    url: '/system/notification/todo/configs',
    method: 'get'
  });
}

/**
 * 获取待办统计信息
 */
export function getTodoStatistics(): AxiosPromise<any> {
  return request({
    url: '/system/notification/todo/statistics',
    method: 'get'
  });
}
