import { Injectable } from '@angular/core';
import { Get, requestDone } from '../http.decorators';
import { _BaseApi } from './_base';

@Injectable({ providedIn: 'root' })
export class DatavApi extends _BaseApi {
  @Get('/board/info', false, ['lineId'])
  async getBoardInfo(lineId: number): Promise<Datav.BoardInfo> {
    requestDone();
  }

  @Get('/board/troubleYearInfo', false, ['year', 'month'])
  async getHazardStatisticInfo(year: number, month?: number): Promise<Datav.HazardStatisticsData> {
    requestDone();
  }

  async addAccident(data: Omit<Datav.Accident, 'id'>) {
    return this.http.post<Promise<ResWrapper<void>>>('/board/accident/add', data);
  }

  async updateAccident(id: number, data: Partial<Datav.Accident>) {
    return this.http.post<Promise<ResWrapper<void>>>('/board/accident/update', { ...data, id });
  }

  async getAccidents(params: Datav.GetAccidentsParams) {
    return this.http.get<Promise<{ items: Datav.Accident[]; total: number }>>('/board/accident/list', params);
  }
}
