import request from './request'

export interface SysNotice {
  id: number
  noticeTitle: string
  noticeType: string
  noticeContent: string
  status: string
  createBy: string | null
  updateBy: string | null
  createdAt: string
  updatedAt: string
  deletedAt: string | null
}

export interface CreateNoticeDto {
  noticeTitle: string
  noticeType: string
  noticeContent: string
  status?: string
}

export interface UpdateNoticeDto {
  noticeTitle?: string
  noticeType?: string
  noticeContent?: string
  status?: string
}

/** 获取所有公告 */
export function getAllNotices(): Promise<SysNotice[]> {
  return request.get('/api/notices')
}

/** 根据ID获取公告 */
export function getNoticeById(id: number): Promise<SysNotice> {
  return request.get(`/api/notices/${id}`)
}

/** 根据状态获取公告 */
export function getNoticesByStatus(status: string): Promise<SysNotice[]> {
  return request.get(`/api/notices/status/${status}`)
}

/** 创建公告 */
export function createNotice(data: CreateNoticeDto): Promise<SysNotice> {
  return request.post('/api/notices', data)
}

/** 更新公告 */
export function updateNotice(id: number, data: UpdateNoticeDto): Promise<SysNotice> {
  return request.put(`/api/notices/${id}`, data)
}

/** 删除公告 */
export function deleteNotice(id: number): Promise<void> {
  return request.delete(`/api/notices/${id}`)
}
