import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CompanyCertificateVO, CompanyCertificateForm, CompanyCertificateQuery } from '@/api/smarttrace/companyCertificate/types';
import { ApprovalForm } from '../companyFieldApply/types';

/**
 * 查询企业认证列表
 * @param query
 * @returns {*}
 */

export const listCompanyCertificate = (query?: CompanyCertificateQuery): AxiosPromise<CompanyCertificateVO[]> => {
  return request({
    url: '/companyCertificate/queryList',
    method: 'get',
    params: query
  });
};

/**
 * 查询企业认证详细
 * @param id
 */
export const getCompanyCertificate = (id: string | number): AxiosPromise<CompanyCertificateVO> => {
  return request({
    url: '/smarttrace/companyCertificate/getInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增企业认证
 * @param data
 */
export const addCompanyCertificate = (data: CompanyCertificateForm) => {
  return request({
    url: '/smarttrace/companyCertificate/add',
    method: 'post',
    data: data
  });
};

/**
 * 修改企业认证
 * @param data
 */
export const updateCompanyCertificate = (data: CompanyCertificateForm) => {
  return request({
    url: '/smarttrace/companyCertificate/edit',
    method: 'post',
    data: data
  });
};

/**
 * 删除企业认证
 * @param id
 */
export const delCompanyCertificate = (id: string | number | Array<string | number>) => {
  return request({
    url: '/smarttrace/companyCertificate/remove/' + id,
    method: 'get'
  });
};

/**
 * 审批企业认证
 * @param id
 */
export const approvalCert = (data:ApprovalForm) => {
  return request({
    url: '/approval/approvalCert',
    method: 'post',
    data
  });
};
