import { IRes, IResult } from '@/api/common'
import axios from '@/utils/request'
import { base, IStatisticsBase, IStatisticsData, IStatisticsDayNHour } from './common'
export interface IQueryParam {
  checkCode: string
  siteId: number
  beginDate: string
  endDate: string
}

const uris = {
  data: `${base}/indicateSts/data`,
  day: `${base}/indicateSts/dayData`,
  base: `${base}/indicateSts/info`,
  hour: `${base}/indicateSts/rainfallHour`,
  notes: `${base}/monitorsitenotes`
}

export const fetchData = (params: Partial<IQueryParam>) =>
  axios.request<IResult<IStatisticsData[]>>({ url: uris.data, method: 'get', params })

export const fetchDayData = (params: Partial<IQueryParam>) =>
  axios.request<IResult<IStatisticsDayNHour>>({ url: uris.day, method: 'get', params })

export const fetchBaseData = (siteId) =>
  axios.request<IResult<IStatisticsBase>>({ url: uris.base, method: 'get', params: { siteId } })

export const fetchHourData = (params: Partial<IQueryParam>) =>
  axios.request<IResult<IStatisticsDayNHour>>({ url: uris.hour, method: 'get', params })

export const addNote = (data: { analyzeNote: string; siteId: number }) =>
  axios.request<IRes<boolean>>({ url: uris.notes, method: 'post', data })
