import {
  get,
  post,
} from '@/common/utils/http-util.ts'

export default {
  paging(data: TaskTypes.SearchTaskParam) {
    return get<G.PageResult<TaskTypes.SearchTaskResult>>('/task/paging', data)
  },
  detail(id: string) {
    return get<TaskTypes.SearchTaskResult>('/task/detail', {id})
  },
  fn(keywords?: string) {
    return get<TaskTypes.FnHandle[]>('/task/fn', {keywords})
  },
  trigger(id: string) {
    return get<boolean>('/task/trigger', {id})
  },
  disable(id: string, disable: boolean) {
    return get<boolean>('/task/disable', {id, disable})
  },
  checkExpression(expression: string) {
    return get<string[]>('/task/check_expression', {expression})
  },
  add(data: TaskTypes.AddTaskParam) {
    return post('/task/add', data)
  },
  modify(data: TaskTypes.ModifyTaskParam) {
    return post('/task/modify', data)
  },
  del(ids: string[]) {
    return post('/task/del', ids)
  },
}
