/*
 * @Author: donghao donghao@supervision.ltd
 * @Date: 2025-07-08 15:57:23
 * @LastEditors: donghao donghao@supervision.ltd
 * @LastEditTime: 2025-07-10 10:16:38
 * @FilePath: \Robot-Al-Platform-Web\src\renderer\src\mock\utils\apiMock.ts
 * @Description: mock返回结果模版
 */
import { failMockApiProps, successMockApiProps } from '../typing'
export function fetchMockSuccessFullByOther({ data, msg }): successMockApiProps {
  const result: successMockApiProps = {
    code: 200, // 200 成功
    success: true, // true 成功
    data: data || null, // mock业务层数据
    msg: msg as string | 'ok', // 成功提示
    isMock: true // true 标识当前是模拟数据
  }
  return result
}

export function fetchMockFailFullByOther({ data, msg }): failMockApiProps {
  const result: failMockApiProps = {
    code: 599, // 200 成功
    success: false, // true 成功
    data: data || null, // mock业务层数据
    msg: msg as string | 'fail', // 成功提示
    isMock: true // true 标识当前是模拟数据
  }
  return result
}

// 分页展示
export function fetchCurrPageByList({ data }): successMockApiProps {
  // console.log("fetchCurrPageByList_data", data);
  const { page, pageSize } = data
  const prevPage = page - 1
  const currPageData = {
    ...data,
    data: data.data.slice(prevPage * pageSize, page * pageSize)
  }
  return fetchMockSuccessFullByOther({ data: currPageData })
}
