import request from '@/utils/request'

const BASE = '/admin/aiModel'
const SCENE_BASE = '/admin/aiScene'

// ─── 模型管理 ───

export function listAiModel() {
  return request({ url: BASE + '/list', method: 'get' })
}

export function getAiModel(id) {
  return request({ url: BASE + '/' + id, method: 'get' })
}

export function addAiModel(data) {
  return request({ url: BASE, method: 'post', data })
}

export function updateAiModel(id, data) {
  return request({ url: BASE + '/' + id, method: 'put', data })
}

export function deleteAiModel(id) {
  return request({ url: BASE + '/' + id, method: 'delete' })
}

export function batchSortAiModel(sortList) {
  return request({ url: BASE + '/batchSort', method: 'put', data: sortList })
}

export function testAiModel(id) {
  return request({ url: BASE + '/test/' + id, method: 'post' })
}

export function refreshAiModel() {
  return request({ url: BASE + '/refresh', method: 'post' })
}

// ─── 场景管理 ───

export function listAiScene() {
  return request({ url: SCENE_BASE + '/list', method: 'get' })
}

export function getAiScene(sceneCode) {
  return request({ url: SCENE_BASE + '/' + sceneCode, method: 'get' })
}

export function updateAiScene(sceneCode, data) {
  return request({ url: SCENE_BASE + '/' + sceneCode, method: 'put', data })
}

export function updateSceneThreshold(sceneCode, qualityThreshold) {
  return request({ url: SCENE_BASE + '/' + sceneCode + '/threshold', method: 'put', data: { qualityThreshold } })
}

export function getSceneModels(sceneCode) {
  return request({ url: SCENE_BASE + '/' + sceneCode + '/models', method: 'get' })
}

export function getSceneEnabledModels(sceneCode) {
  return request({ url: SCENE_BASE + '/' + sceneCode + '/enabledModels', method: 'get' })
}

export function addSceneModel(sceneCode, data) {
  return request({ url: SCENE_BASE + '/' + sceneCode + '/models', method: 'post', data })
}

export function deleteSceneModel(sceneCode, id) {
  return request({ url: SCENE_BASE + '/' + sceneCode + '/models/' + id, method: 'delete' })
}

export function clearSceneModels(sceneCode) {
  return request({ url: SCENE_BASE + '/' + sceneCode + '/models', method: 'delete' })
}

export function updateSceneModel(sceneCode, id, data) {
  return request({ url: SCENE_BASE + '/' + sceneCode + '/models/' + id, method: 'put', data })
}

export function refreshAiScene() {
  return request({ url: SCENE_BASE + '/refresh', method: 'post' })
}
