import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { GoalVO, GoalForm, GoalQuery } from '@/api/ygpassport/goal/types';

/**
 * 查询目标信息列表
 * @param query
 * @returns {*}
 */

export const listGoal = (query?: GoalQuery): AxiosPromise<GoalVO[]> => {
  return request({
    url: '/ygpassport/goal/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询目标信息详细
 * @param id
 */
export const getGoal = (id: string | number): AxiosPromise<GoalVO> => {
  return request({
    url: '/ygpassport/goal/' + id,
    method: 'get'
  });
};

/**
 * 新增目标信息
 * @param data
 */
export const addGoal = (data: GoalForm) => {
  return request({
    url: '/ygpassport/goal',
    method: 'post',
    data: data
  });
};

/**
 * 修改目标信息
 * @param data
 */
export const updateGoal = (data: GoalForm) => {
  return request({
    url: '/ygpassport/goal',
    method: 'put',
    data: data
  });
};

/**
 * 删除目标信息
 * @param id
 */
export const delGoal = (id: string | number | Array<string | number>) => {
  return request({
    url: '/ygpassport/goal/' + id,
    method: 'delete'
  });
};
