import request, { type RequestOptions } from '/@/utils/request';

export interface LiveAccountParams {
	pageNum: number;
	pageSize: number;
	platform?: string;
	accountName?: string;
	accountId?: string;
	status?: number;
}

export interface LiveAccountSaveParams {
	id?: string;
	platform: string;
	accountName: string;
	accountId: string;
	status?: number;
	remark?: string;
}

export interface LiveAccount {
	id: string;
	platform: string;
	accountName: string;
	accountId: string;
	status: number;
	statusName: string;
	remark: string;
	createdAt: number;
	updatedAt: number;
}

export interface LiveAccountListResult {
	list: LiveAccount[];
	total: number;
}

export interface LiveAccountListResponse {
	code: number;
	message: string;
	data: LiveAccountListResult;
}

export interface LiveAccountDetailResponse {
	code: number;
	message: string;
	data: LiveAccount;
}

export function getLiveAccountList(params: LiveAccountParams, requestOptions?: RequestOptions): Promise<LiveAccountListResponse> {
	return request({
		url: '/erp/live/account/controller/listLiveAccounts',
		method: 'get',
		params,
		requestOptions,
	}) as Promise<LiveAccountListResponse>;
}

export function getLiveAccountDetail(params: { id: string }, requestOptions?: RequestOptions): Promise<LiveAccountDetailResponse> {
	return request({
		url: '/erp/live/account/controller/getLiveAccount',
		method: 'get',
		params,
		requestOptions,
	}) as Promise<LiveAccountDetailResponse>;
}

export function createLiveAccount(data: LiveAccountSaveParams, requestOptions?: RequestOptions) {
	return request({
		url: '/erp/live/account/controller/createLiveAccount',
		method: 'post',
		data,
		requestOptions,
	});
}

export function updateLiveAccount(data: LiveAccountSaveParams, requestOptions?: RequestOptions) {
	return request({
		url: '/erp/live/account/controller/updateLiveAccount',
		method: 'put',
		data,
		requestOptions,
	});
}

export function deleteLiveAccount(params: { id: string }, requestOptions?: RequestOptions) {
	return request({
		url: '/erp/live/account/controller/deleteLiveAccount',
		method: 'delete',
		params,
		requestOptions,
	});
}
