import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { BaseResult } from "@/types/api/base";
import {
    ExchangeOrderQueryForm,
    walletQueryForm,
    CoinsQueryForm,
} from "@/types/api/coinspot";
import { CoinPageResult } from "@/types/api/system/coin";

export const exchangeOrder = (data: ExchangeOrderQueryForm) => {
    return request({
        url: "/exchangeadmin/exchange-order/admin/page",
        method: "post",
        data: data,
    });
};

export const find_by_conditions_page = (data: walletQueryForm) => {
    return request({
        url: "/exchangeadmin/exchange-wallet/admin/find_by_conditions_page",
        method: "post",
        data: data,
    });
};

export const exchange_coins = (data: CoinsQueryForm) => {
    return request({
        url: "/exchangeadmin/exchange-coin/coins",
        method: "post",
        data: data,
    });
};

export const exchange_coin_add = (data: CoinPageResult) => {
    return request({
        url: "/exchangeadmin/exchange-coin/add",
        method: "post",
        data: data,
    });
};

export const exchange_coin_update = (data: CoinPageResult) =>
    request({
        url: "/exchangeadmin/exchange-coin/update",
        method: "post",
        data: data,
    });

export const exchange_coin_delete = (id: number): AxiosPromise<BaseResult> =>
    request({
        url: `/exchangeadmin/exchange-coin/delete/${id}`,
        method: "put",
    });

export const configCoinSymbolPage = (data: {
    pageNo: number;
    pageSize: number;
    coinSymbol?: string;
    startTime?: string;
    endTime?: string;
}) =>
    request({
        url: "admin/system/config-coin-symbol/page-query",
        method: "post",
        params: data,
    });

export const configCoinSymbolCreate = (data: any) =>
    request({
        url: "admin/system/config-coin-symbol/create",
        method: "post",
        data,
    });

export const configCoinSymbolUpdate = (data: any) =>
    request({
        url: "admin/system/config-coin-symbol/update",
        method: "post",
        data,
    });

export const configCoinSymbolDelete = (id: number) =>
    request({
        url: "admin/system/config-coin-symbol/delete",
        method: "post",
        params: { id },
    });

export const configCoinSymbolToggle = (id: number) =>
    request({
        url: "admin/system/config-coin-symbol/toggle-status",
        method: "post",
        params: { id },
    });

export const configCoinSymbolList = () =>
    request({
        url: "admin/system/config-coin-symbol/list",
        method: "get",
    });

export const configSymbolPage = (data: {
    pageNo: number;
    pageSize: number;
    base?: string;
    quote?: string;
    zone?: string;
    isOpen?: string;
}) =>
    request({
        url: "admin/system/config-symbol/page-query",
        method: "post",
        params: data,
    });

export const configSymbolDetail = (id: number) =>
    request({
        url: "admin/system/config-symbol/detail",
        method: "get",
        params: { id },
    });

export const configSymbolCreate = (data: any) =>
    request({
        url: "admin/system/config-symbol/create",
        method: "post",
        data,
    });

export const configSymbolUpdate = (data: any) =>
    request({
        url: "admin/system/config-symbol/update",
        method: "post",
        data,
    });

export const configSymbolDelete = (id: number) =>
    request({
        url: "admin/system/config-symbol/delete",
        method: "post",
        params: { id },
    });

export const configSymbolToggleStatus = (id: number) =>
    request({
        url: "admin/system/config-symbol/toggle-status",
        method: "post",
        params: { id },
    });

export const configSymbolTogglePublish = (id: number) =>
    request({
        url: "admin/system/config-symbol/toggle-publish",
        method: "post",
        params: { id },
    });

export const configSymbolCancelAllOrders = (symbol: string) =>
    request({
        url: "admin/system/config-symbol/cancel-all-orders",
        method: "post",
        params: { symbol },
    });

export const adminOrderPage = (data: any) =>
    request({
        url: "admin/system/spot/order/page",
        method: "post",
        data,
    });

export const adminTradePage = (data: any) =>
    request({
        url: "admin/system/spot/trade/page",
        method: "post",
        data,
    });

export const adminSymbolAll = () =>
    request({
        url: "admin/system/spot/symbol/all",
        method: "get",
    });

export const configRobotPage = (data: {
    pageNo: number;
    pageSize: number;
    symbol?: string;
    status?: number;
}) =>
    request({
        url: "admin/system/config-robot/page-query",
        method: "post",
        params: data,
    });

export const configRobotDetail = (id: number) =>
    request({
        url: "admin/system/config-robot/detail",
        method: "get",
        params: { id },
    });

export const configRobotSymbols = () =>
    request({
        url: "admin/system/config-robot/symbols",
        method: "get",
    });

export const configRobotCreate = (data: any) =>
    request({
        url: "admin/system/config-robot/create",
        method: "post",
        data,
    });

export const configRobotUpdate = (data: any) =>
    request({
        url: "admin/system/config-robot/update",
        method: "post",
        data,
    });

export const configRobotDelete = (id: number) =>
    request({
        url: "admin/system/config-robot/delete",
        method: "post",
        params: { id },
    });
