import request from '@/utils/request';
import { NoticeForm, NoticeQuery, NoticeVO } from './types';
import { AxiosPromise } from 'axios';

// ========== 公告基础接口 ==========

// 查询公告列表
export function listNotice(query: NoticeQuery): AxiosPromise<NoticeVO[]> {
  return request({
    url: '/system/notice/list',
    method: 'get',
    params: query
  });
}

// 查询公告详细 - 参数使用notificationId
export function getNotice(notificationId: string | number): AxiosPromise<NoticeVO> {
  return request({
    url: '/system/notice/' + notificationId,
    method: 'get'
  });
}

// 新增公告
export function addNotice(data: NoticeForm) {
  return request({
    url: '/system/notice/add',
    method: 'post',
    data: data
  });
}

// 修改公告
export function updateNotice(data: NoticeForm) {
  return request({
    url: '/system/notice/edit',
    method: 'post',
    data: data
  });
}

// 删除公告 - 参数使用notificationId
export function delNotice(notificationId: string | number | Array<string | number>) {
  return request({
    url: '/system/notice/remove/' + notificationId,
    method: 'post'
  });
}

// ========== 人员选择相关接口 ==========

// 获取用户列表（用于下拉选择）
export function getUserOptions(query?: {
  pageNum?: number;
  pageSize?: number;
  userName?: string;
  nickName?: string;
  deptId?: number;
}): AxiosPromise<any[]> {
  return request({
    url: '/system/notice/users/options',
    method: 'get',
    params: query
  });
}
