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

/**
 * 添加分组API
 * @returns 
 */
export async function addGroupApi(data: { groupName: string }) {
    return request(api + '/adq/group/add', {
        method: 'POST',
        data
    });
}


/**
 * 删除分组
 * @param data 
 * @returns 
 */
export async function delGroupApi(data: { groupId: number }) {
    return request(api + `/adq/group/delete/${data.groupId}`, {
        method: 'POST'
    });
}

/**
 * 获取分组列表
 * @returns 
 */
export async function getGroupListApi() {
    return request(api + `/adq/group/list`)
}

/**
 * 修改分组
 * @param data 
 * @returns 
 */
export async function editGroupApi(data: { groupName: string, groupId: number }) {
    return request(api + '/adq/group/update', {
        method: 'POST',
        data
    });
}

/**
 * 根据分组ID获取账号列表
 * @param groupId 
 * @returns 
 */
export async function getAccountListApi(groupId: number) {
    return request(api + `/adq/group/account/${groupId}`)
}


/**
 * 添加账号进入分组
 * @param AddAccountToGroupProps
 * @returns 
 */
export interface AddAccountToGroupProps {
    accountIds: number[],
    currGroupId?: number,
    newGroupId?: number,
}
export async function addAccountToGroupApi(data: AddAccountToGroupProps) {
    return request(api + `/adq/group/account/add`, {
        method: 'POST',
        data
    })
}

/**
 * 新增账号到分组
 * @param data 
 * @returns 
 */
export async function addNewAccountToGroupApi(data: AddAccountToGroupProps) {
    return request(api + `/adq/group/account/addNew`, {
        method: 'POST',
        data
    })
}

/**
 * 移动账号到新分组
 * @param data 
 * @returns 
 */
export async function moveAccountToGroupApi(data: AddAccountToGroupProps) {
    return request(api + `/adq/group/account/modify`, {
        method: 'POST',
        data
    })
}

/**
 * 账号移出分组
 * @param data 
 * @returns 
 */
export async function delAccountToGroupApi(data: AddAccountToGroupProps) {
    return request(api + `/adq/group/account/move`, {
        method: 'POST',
        data
    })
}