import request from '@/request'
import type * as TYPE from './types'

/**
 * 告警计划保存
 */
export const saveAlarmPlan = (
  params: TYPE.AlarmPlanParams
): Promise<ResponseData<TYPE.AlarmPlanResponseData>> => {
  return request.post('/alarm/plan/save', params)
}

/**
 * 告警事件类型下拉列表
 */
export const getAlarmEventTypeList = (): Promise<
  ResponseData<TYPE.AlarmEventTypeListResponseData>
> => {
  return request.get('/alarm/plan/queryEventType')
}

/**
 * 告警计划查询
 */
export const getAlarmPlanList = (params: {
  clientId: string
}): Promise<ResponseData<TYPE.AlarmPlanListResponseData>> => {
  return request.post('/alarm/plan/query', params)
}

/**
 * 告警计划删除
 */
export const deleteAlarmPlan = (params: { id: number }): Promise<ResponseData<null>> => {
  return request.post('/alarm/plan/del', params)
}

/**
 * 告警计划禁启用
 */
export const enableAlarmPlan = (params: {
  id: number
  enable: 0 | 1
}): Promise<ResponseData<null>> => {
  return request.post('/alarm/plan/enable', params)
}

/**
 * 告警计划模板保存
 */
export const saveAlarmPlanTemplate = (params: TYPE.AlarmPlanTemplateParams) => {
  return request.post('/alarm/plan/saveTpl', params)
}

/**
 * 告警计划模板查询
 */
export const getAlarmPlanTemplateList = (params: {
  pageNo: number
  pageSize: number
  enable?: 0 | 1 | null
  eventVal?: number | null
  name?: string | null
}): Promise<ResponseData<TYPE.AlarmPlanTemplateListResponseData>> => {
  return request.post('/alarm/plan/queryTpl', params)
}

/**
 * 告警计划模板删除
 */
export const deleteAlarmPlanTemplate = (params: { id: number }): Promise<ResponseData<object>> => {
  return request.post('/alarm/plan/delTpl', params)
}

/**
 * 告警计划模板禁启用
 */
export const enableAlarmPlanTemplate = (params: {
  id: number
  enable: 0 | 1
}): Promise<ResponseData<null>> => {
  return request.post('/alarm/plan/enableTpl', params)
}
