import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WateringLogVO, WateringLogForm, WateringLogQuery } from '@/api/app/wateringLog/types';

/**
 * 查询浇水记录列表
 * @param query
 * @returns {*}
 */

export const listWateringLog = (query?: WateringLogQuery): AxiosPromise<WateringLogVO[]> => {
  return request({
    url: '/app/wateringLog/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询浇水记录详细
 * @param id
 */
export const getWateringLog = (id: string | number): AxiosPromise<WateringLogVO> => {
  return request({
    url: '/app/wateringLog/' + id,
    method: 'get'
  });
};

/**
 * 新增浇水记录
 * @param data
 */
export const addWateringLog = (data: WateringLogForm) => {
  return request({
    url: '/app/wateringLog',
    method: 'post',
    data: data
  });
};

/**
 * 修改浇水记录
 * @param data
 */
export const updateWateringLog = (data: WateringLogForm) => {
  return request({
    url: '/app/wateringLog',
    method: 'put',
    data: data
  });
};

/**
 * 删除浇水记录
 * @param id
 */
export const delWateringLog = (id: string | number | Array<string | number>) => {
  return request({
    url: '/app/wateringLog/' + id,
    method: 'delete'
  });
};
