import { get, post, put, del } from '@/utils/request';

export interface NewProductApplyQuery {
  page?: number;
  pageSize?: number;
  productName?: string;
  barcode?: string;
  status?: number;
  applicantId?: number;
}

export interface NewProductApplyItem {
  id?: number;
  productName: string;
  barcode: string;
  category?: string;
  brand?: string;
  specification?: string;
  unit?: string;
  price?: number;
  costPrice?: number;
  images?: string;
  description?: string;
  productType?: number;
  standard?: number;
  stickerNum?: string;
  length?: number;
  width?: number;
  height?: number;
  exhibitHeight?: number;
  columns?: number;
  numbers?: number;
  reason?: string;
  status?: number;
  applicantId?: number;
  applicantName?: string;
  applyTime?: string;
  auditStatus?: number;
  auditRemark?: string;
}

export interface NewProductApplyStatistics {
  total: number;
  pending: number;
  approved: number;
  rejected: number;
}

export interface NewProductApplyListResponse {
  list: NewProductApplyItem[];
  total: number;
  pageSize: number;
  currentPage: number;
}

export async function getNewProductApplyList(params: NewProductApplyQuery = {}): Promise<NewProductApplyListResponse> {
  return get('/new-product-apply/list', params);
}

export async function getNewProductApplyById(id: number): Promise<NewProductApplyItem> {
  return get(`/new-product-apply/${id}`);
}

export async function getNewProductApplyStatistics(): Promise<NewProductApplyStatistics> {
  return get('/new-product-apply/statistics');
}

export async function submitNewProductApply(data: NewProductApplyItem): Promise<any> {
  return post('/new-product-apply/submit', data);
}

export async function saveNewProductApplyDraft(data: NewProductApplyItem): Promise<any> {
  return post('/new-product-apply/save-draft', data);
}

export async function updateNewProductApply(id: number, data: NewProductApplyItem): Promise<any> {
  return put(`/new-product-apply/${id}`, data);
}

export async function deleteNewProductApply(id: number): Promise<any> {
  return del(`/new-product-apply/${id}`);
}

export async function checkBarcode(barcode: string): Promise<any> {
  return get('/new-product-apply/check-barcode', { barcode });
}
