import request from '@/utils/request'

/**
 * 创建账号组
 * @param {Object} data 账号组数据
 */
export function createAccountGroup(data) {
  return request({
    url: '/api/account-group/create',
    method: 'post',
    data
  })
}

/**
 * 更新账号组
 * @param {Object} data 账号组数据
 */
export function updateAccountGroup(data) {
  return request({
    url: '/api/account-group/update',
    method: 'post',
    data
  })
}

/**
 * 删除账号组
 * @param {Number} groupId 账号组ID
 */
export function deleteAccountGroup(groupId) {
  return request({
    url: `/api/account-group/${groupId}`,
    method: 'delete'
  })
}

/**
 * 获取账号组列表（分页）
 * @param {Number} pageNum 页码
 * @param {Number} pageSize 每页数量
 */
export function getAccountGroupList(pageNum = 1, pageSize = 10) {
  return request({
    url: '/api/account-group/list',
    method: 'get',
    params: { pageNum, pageSize }
  })
}

export function getAccountGroupListAll() {
  return request({
    url: '/api/account-group/all',
    method: 'get'
  })
}

/**
 * 获取账号组详情
 * @param {Number} groupId 账号组ID
 */
export function getAccountGroupDetail(groupId) {
  return request({
    url: `/api/account-group/${groupId}`,
    method: 'get'
  })
}

/**
 * 添加账号到账号组
 * @param {Object} data { groupId, accountIds }
 */
export function addAccountsToGroup(data) {
  return request({
    url: '/api/account-group/add-accounts',
    method: 'post',
    data
  })
}

/**
 * 从账号组移除账号
 * @param {Object} data { groupId, accountIds }
 */
export function removeAccountsFromGroup(data) {
  return request({
    url: '/api/account-group/remove-accounts',
    method: 'post',
    data
  })
}

/**
 * 获取账号组的账号列表
 * @param {Number} groupId 账号组ID
 */
export function getGroupAccounts(groupId) {
  return request({
    url: `/api/account-group/${groupId}/accounts`,
    method: 'get'
  })
}
