import request from "@/utils/request";
const { api } = process.env.CONFIG;

/**
 * 获取客服号fu 列表
 * @param data 
 * @returns 
 */
export async function getCorpUserApi(data: CORP_USER_ASSIGN_API.GetCorpUserProps) {
    return request({
        url: api + `/corpOperation/corpUser/list`,
        method: 'POST',
        data
    });
}

/**
 * 指派人
 * @param data 
 * @returns 
 */
export async function putCorpUserTOApi({ corpId, corpUserId, ...data }: CORP_USER_ASSIGN_API.PutCorpUserTOProps) {
    return request({
        url: api + `/corpOperation/corpUser/config/${corpId}/${corpUserId}`,
        method: 'PUT',
        data
    });
}

/**
 * 企微号禁用
 * @param param0 
 * @returns 
 */
export async function putStatusCorpUserApi({ corpId, corpUserId, status }: CORP_USER_ASSIGN_API.PutStatusCorpUserProps) {
    return request({
        url: api + `/corpOperation/corpUser/stopUse/${corpId}/${corpUserId}/${status}`,
        method: 'POST'
    });
}


/*************************************************/

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


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

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

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

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


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

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

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

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