import {requestBodyClient, requestClient} from "#/api/request";

interface ApiResultListData {
    data: Object;
    status: number;
    total: number;
    list: Array<any>;
}

interface ApiResultInfoData {
    data: Object;
    status: number;
    message: string;
}

export async function getGameMinList() {
    return requestClient.get<ApiResultListData>('/game/get_games');
}

/**
 * 获取游戏列表
 */
export async function getGameList(data:any) {
    const params = new URLSearchParams(data); // 创建一个新的URLSearchParams对象
    const queryString = params.toString(); // 转换为查询字符串
    return requestClient.get<ApiResultListData>('/game/list?' + queryString);
}

/**
 * 获取游戏详情
 * @param game_id
 */
export async function getGameInfo(game_id:string | number) {
    return requestClient.get<ApiResultInfoData>('/game/detail?id=' + game_id);
}

/**
 * 更新游戏详情
 * @param data
 */
export async function updateGameDetail(data:any) {
    return requestBodyClient.post<ApiResultInfoData>('/game/update', data);
}

export async function updateGameStatus(data:any) {
    return requestBodyClient.post<ApiResultInfoData>('/game/update_status', data);
}