import { request } from 'umi';
import { api } from '../api'

/**
 * 分页获取账号列表
 * @returns 
 */
export interface GetAdAccountParams {
    pageNum: number,
    pageSize: number,
    adUnitTypeList: Array<'NOVEL' | 'NOVEL_IAA' | 'GAME' | 'GAME_IAA' | 'SKIT_IAA'>, // 1小说 2游戏 3短剧
    groupId?: number,
    accountIds?: string[] | string
    putUserId?: number,
    addV3?: boolean,
    adUnitAccount?: boolean
    adUnitType?: string
}
export async function getAdAccountListApi(data: GetAdAccountParams) {
    return request(api + '/adq/adAccount/accountListOfAdUnitType', {
        method: 'POST',
        data
    });
}

/**
 * 授权详情
 * @returns 
 */
export async function getAuthInfoApi() {
    return request(api + '/adq/userRealnameAuth/authInfo', {
        method: 'GET'
    });
}

/**
 * 授权成功
 * @param data 
 * @returns 
 */
export async function setAuthSuccessApi(data: { userStatus: number, userToken: string, expireTime: number, wxId: string, state: any }) {
    return request(api + '/adq/userRealnameAuth/authSuccess', {
        method: 'PUT',
        data
    });
}

export async function getAdAccountGameListApi(data: GetAdAccountParams) {
    return request(api + '/adq/adAccount/accountListOfGame', {
        method: 'POST',
        data
    });
}

/**
 * 获取账号列表
 * @returns 
 */
export async function getAdAccountApi() {
    return request(api + '/adq/adAccount/allOfUserOfNovel', {
        method: 'GET',
    });
}

/**
 * 返回自己所有账号
 * @returns 
 */
export async function getAllUserAccountApi() {
    return request(api + '/adq/adAccount/allOfOwnerUser', {
        method: 'GET',
    });
}

/**
 * 分页查询账户列表
 * @returns 
 */
export async function getUserAccountListApi(data: { accountIdList?: number[], adUnitTypeList?: string[], groupId?: number, remark?: string, sysGroupId?: number, pageNum: number, pageSize: number }) {
    return request(api + '/adq/adAccount/pageOfOwnerUser', {
        method: 'POST',
        data
    });
}

/**
 * 获取所有账户
 * @returns 
 */
export async function getAccountAllListApi() {
    return request(api + '/adq/adAccount/allList', {
        method: 'GET',
    });
}

/**
 * 获取账号列表
 * @returns 
 */
export async function putAdAccountApi(adAccountId: any, remark: any) {
    return request(api + `/adq/adAccount/modifyRemark/${adAccountId}/${encodeURIComponent(remark)}`, {
        method: 'PUT',
    });
}

/**
 * 账号检查是否是同一个业务单元内账号
 * @param data 
 * @returns 
 */
export async function checkAccountUnitApi(data: number[]) {
    return request(api + `/adq/admin/adAccount/checkAccountUnit`, {
        method: 'POST',
        data
    });
}