import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AuditVO, AuditQuery, AuditForm } from './types';

/**
 * 查询审核信息列表
 */
export function listAudit(query: AuditQuery): AxiosPromise<AuditVO[]> {
  return request({
    url: '/main/audit/list',
    method: 'get',
    params: query
  });
}

/**
 * 获取审核信息详细信息
 */
export function getAudit(id: string | number): AxiosPromise<AuditVO> {
  return request({
    url: '/main/audit/' + id,
    method: 'get'
  });
}

/**
 * 修改审核信息（处理审核）
 */
export function updateAudit(data: AuditForm) {
  return request({
    url: '/main/audit/edit',
    method: 'put',
    data: data
  });
}

/**
 * 审核通过
 */
export function auditPass(id: string | number, remark?: string) {
  return request({
    url: '/main/audit/pass/' + id,
    method: 'put',
    params: {
      remark: remark || ''
    }
  });
}

/**
 * 审核驳回
 */
export function auditReject(id: string | number, remark: string) {
  return request({
    url: '/main/audit/reject/' + id,
    method: 'put',
    params: {
      remark: remark
    }
  });
}

/**
 * 删除审核信息
 */
export function delAudit(ids: string | number | (string | number)[]) {
  return request({
    url: '/main/audit/' + ids,
    method: 'delete'
  });
}
