import request from "@/benyun/utils/request";
//获得订单配置列表
export function queryOrderTimeConfig(
  params: IOrderTimeConfigRequest
): Promise<IOrderTimeResponse<IOrderTimeConfigItem[]>> {
  return request({
    url: "/omsOrder/orderConfig/list",
    params: params,
    method: "GET",
  });
}

//新增订单时间配置
export function addOrderTimeConfig(data: {
  timeout: number;
}): Promise<IOrderTimeResponse<IOrderTimeConfigItem[]>> {
  return request({
    url: "/omsOrder/orderConfig",
    data,
    method: "POST",
  });
}
//修改订单时间配置
export function updateOrderTimeConfig(data: {
  id: number;
  timeout: number;
}): Promise<IOrderTimeResponse<IOrderTimeConfigItem[]>> {
  return request({
    url: "/omsOrder/orderConfig",
    data,
    method: "PUT",
  });
}

//删除订单时间配置
export function delOrderTimeConfig(
  id: number
): Promise<IOrderTimeResponse<string>> {
  return request({
    url: `/omsOrder/orderConfig/${id}`,
    method: "DELETE",
  });
}

export interface IOrderTimeConfigRequest {
  createBy?: string;
  createTime?: string;
  updateBy?: string;
  updateTime?: string;
  params?: {
    key: {
      key?: string;
    };
  };
  id?: number; // int64使用number类型
  tenantId?: string;
  deleteBy?: string;
  deleteTime?: string;
  isDeleted?: number; // 0或1使用number类型
  extData?: string;
  version?: number;
  timeout?: string;
  pageSize?: number;
  pageNum?: number;
  orderByColumn?: string;
  isAsc?: string;
}

//订单时间配置数据项
export interface IOrderTimeConfigItem {
  createBy?: string;
  createTime?: string;
  updateBy?: string;
  updateTime?: string;
  params?: {
    [key: string]: any; // 处理空对象的情况
  };
  id?: number;
  tenantId?: string;
  deleteBy?: string;
  deleteTime?: string;
  isDeleted?: number;
  extData?: string;
  version?: number;
  timeout?: number; // 根据示例值0.0推断为number类型
}

//订单时间配置响应数据
export interface IOrderTimeResponse<T> {
  total: number;
  rows: T;
  code: number;
  msg: string;
}

// ... existing code ...
