import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UsrPetVO, UsrPetForm, UsrPetQuery } from '@/api/archieves/pet/types';

/**
 * 查询宠物列表
 */
export const listPet = (query?: UsrPetQuery): AxiosPromise<UsrPetVO[]> => {
  return request({
    url: '/archieves/pet/list',
    method: 'get',
    params: query
  });
};

/**
 * 按用户查询宠物列表
 */
export const listPetByUser = (userId: string | number): AxiosPromise<UsrPetVO[]> => {
  return request({
    url: '/archieves/pet/listByUser/' + userId,
    method: 'get'
  });
};

/**
 * 查询宠物详细
 */
export const getPet = (id: string | number): AxiosPromise<UsrPetVO> => {
  return request({
    url: '/archieves/pet/' + id,
    method: 'get'
  });
};

/**
 * 新增宠物
 */
export const addPet = (data: UsrPetForm) => {
  return request({
    url: '/archieves/pet',
    method: 'post',
    data: data
  });
};

/**
 * 下单页新增宠物
 */
export const addPetOnOrder = (data: UsrPetForm) => {
  return request({
    url: '/archieves/pet/addOnOrder',
    method: 'post',
    data: data
  });
};

/**
 * 修改宠物
 */
export const updatePet = (data: UsrPetForm) => {
  return request({
    url: '/archieves/pet',
    method: 'put',
    data: data
  });
};

/**
 * 删除宠物
 */
export const delPet = (id: string | number | Array<string | number>) => {
  return request({
    url: '/archieves/pet/' + id,
    method: 'delete'
  });
};
