import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PtCardVO, PtCardForm, PtCardQuery } from '@/api/cardCenter/cardOperation/ptCard/types';

/**
 * 查询账户卡片列表
 * @param query
 * @returns {*}
 */
export const listPtCard = (query?: PtCardQuery): AxiosPromise<PtCardVO[]> => {
  return request({
    url: '/backstage/cardOperation/ptCard/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询账户卡片详细
 * @param cardId
 */
export const getPtCard = (cardId: string | number): AxiosPromise<PtCardVO> => {
  return request({
    url: '/backstage/cardOperation/ptCard/' + cardId,
    method: 'get'
  });
};

/**
 * 新增账户卡片
 * @param data
 */
export const addPtCard = (data: PtCardForm) => {
  return request({
    url: '/backstage/cardOperation/ptCard',
    method: 'post',
    data: data
  });
};

/**
 * 修改账户卡片
 * @param data
 */
export const updatePtCard = (data: PtCardForm) => {
  return request({
    url: '/backstage/cardOperation/ptCard',
    method: 'put',
    data: data
  });
};

/**
 * 删除账户卡片
 * @param cardId
 */
export const delPtCard = (cardId: string | number | Array<string | number>) => {
  return request({
    url: '/backstage/cardOperation/ptCard/' + cardId,
    method: 'delete'
  });
};
/**
 * 挂失账户卡片
 * @param cardId
 */
export const lockPtCard = (cardId: string | number | Array<string | number>) => {
  return request({
    url: '/backstage/cardOperation/ptCard/lockCard/' + cardId,
    method: 'put'
  });
};
/**
 * 解挂账户卡片
 * @param cardId
 */
export const unlockPtCard = (cardId: string | number) => {
  return request({
    url: '/backstage/cardOperation/ptCard/unlockCard/' + cardId,
    method: 'put'
  });
};

export default {
  listPtCard,
  getPtCard,
  addPtCard,
  updatePtCard,
  delPtCard,
  lockPtCard,
  unlockPtCard
};
