import request from '@/utils/request';
import type { ApiResult, PageQuery } from '../sys/types';

// ============================ 主导航 ============================
export interface GameNavigatorVo {
  navId?: number;
  name?: string;
  pic?: string;
  color?: string;
  jumpType?: number;
  jumpPath?: string;
  activityType?: number;
  appId?: string;
  sortNum?: number;
  status?: number;
  title?: string;
  createBy?: string;
  createTime?: string;
  updateBy?: string;
  updateTime?: string;
  remark?: string;
}

export interface GameNavigatorBo {
  navId?: number;
  name?: string;
  pic?: string;
  color?: string;
  jumpType?: number;
  jumpPath?: string;
  activityType?: number;
  appId?: string;
  sortNum?: number;
  status?: number;
  remark?: string;
}

// 赛事关联菜单查询参数
export interface RelateMenuQuery {
  eventId?: string | number;
}

// 编辑赛事关联菜单参数
export interface EditRelateMenuParams {
  /**
   * 赛事id
   */
  eventId: string | number;
  /**
   * 菜单列表 - 菜单的navId数组
   */
  menus: number[];
}

// 查询底部主导航列表
export function listNavigator(query: GameNavigatorBo & PageQuery) {
  return request<
    ApiResult<{
      rows: GameNavigatorVo[];
      total: number;
    }>
  >({
    url: '/system/scenic/navigator/list',
    method: 'get',
    params: query
  });
}

// 查询可用的主导航列表
export function getEnabledNavigator() {
  return request({
    url: '/system/scenic/navigator/enabled',
    method: 'get'
  });
}

// 查询底部主导航详细
export function getNavigator(navId: number) {
  return request<ApiResult<GameNavigatorVo>>({
    url: `/system/scenic/navigator/${navId}`,
    method: 'get'
  });
}

// 新增底部主导航
export function addNavigator(data: GameNavigatorBo) {
  return request<ApiResult<void>>({
    url: '/system/scenic/navigator',
    method: 'post',
    data: data
  });
}

// 修改底部主导航
export function updateNavigator(data: GameNavigatorBo) {
  return request<ApiResult<void>>({
    url: '/system/scenic/navigator',
    method: 'put',
    data: data
  })
}

// 删除底部主导航
export function delNavigator(navId: number | Array<number>) {
  return request<ApiResult<void>>({
    url: `/system/scenic/navigator/${navId}`,
    method: 'delete'
  })
}

// 导出底部主导航
export function exportNavigator(query: GameNavigatorBo) {
  return request({
    url: '/system/scenic/navigator/export',
    method: 'post',
    data: query
  })
}

// 金刚区（type=4）固定类型数据
export function listKingKongNav() {
  return request<ApiResult<GameNavigatorVo[]>>({
    url: '/system/scenic/navigator/byType/4',
    method: 'get'
  });
}

// 查询赛事关联菜单
export function listRelateMenu(query: RelateMenuQuery & PageQuery) {
  return request<
    ApiResult<{
      rows: GameNavigatorVo[];
      total: number;
    }>
  >({
    url: '/system/scenic/navigator/list/relate',
    method: 'get',
    params: query
  });
}

// 编辑赛事关联菜单
export function editRelate(data: EditRelateMenuParams) {
  return request({
    url: '/system/scenic/navigator/edit/relate',
    method: 'post',
    data: data
  });
}
