import { http } from '@/utils/http/axios';
import type { QueryPageRequest, QueryPageResponse } from '@/types/basic-query';

import type { IssueItem } from '../types';

// 查询今日异常告警数量（评分）
export function getTodayIssueNumber() {
  return http.request<number>({
    url: '/issue/queryTodayIssueCount',
    method: 'get',
  });
}
// 通过相机id分页查询异常告警问题列表
export function getIssueListByCameraId(data: QueryPageRequest<number>) {
  return http.request<QueryPageResponse<IssueItem>>({
    url: '/issue/queryIssuePageByCameraId',
    method: 'post',
    data,
  });
}

// 通过车间code分页查询异常告警问题列表
export function getIssueListByWorkshopCode(data: QueryPageRequest<{ workshopCodeList: string[] }>) {
  return http.request<QueryPageResponse<IssueItem>>({
    url: '/issue/queryIssuePageByWorkshopCodes',
    method: 'post',
    data,
  });
}

// 查询弹窗报警
export function getNewIssueList() {
  return http.request<IssueItem[]>({
    url: '/issue/queryTodayNewIssueList',
    method: 'get',
  });
}

// 更新已读问题id
export function updateReadIssueId(issueId: number) {
  return http.request({
    url: `/issue/updateLastReadIssueId?issueId=${issueId}`,
    method: 'post',
  });
}
