You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
/*
|
|
* @Author: donghao donghao@supervision.ltd
|
|
* @Date: 2025-03-07 14:58:39
|
|
* @LastEditors: donghao donghao@supervision.ltd
|
|
* @LastEditTime: 2025-03-13 14:29:26
|
|
* @FilePath: \5G-Loading-Bay-Web\mock\utils\apiMock.ts
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
*/
|
|
import { failMockApiProps, successMockApiProps } from "../typing";
|
|
export function fetchMockSuccessFullByOther({
|
|
data,
|
|
msg,
|
|
}): successMockApiProps {
|
|
// return {
|
|
// code: 200, // 200 成功
|
|
// success: true, // true 成功
|
|
// data: data || null, // mock业务层数据
|
|
// msg: msg | "ok", // 成功提示
|
|
// isMock: true // true 标识当前是模拟数据
|
|
// } as 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 {
|
|
// return {
|
|
// code: 599, // 200 成功
|
|
// success: true, // true 成功
|
|
// data: data || null, // mock业务层数据
|
|
// msg: msg | "fail", // 成功提示
|
|
// isMock: true // true 标识当前是模拟数据
|
|
// } as 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 { current, pageSize } = data;
|
|
const prevPage = current - 1;
|
|
const currPageData = {
|
|
...data,
|
|
data: data.data.slice(prevPage * pageSize, current * pageSize),
|
|
};
|
|
return fetchMockSuccessFullByOther({ data: currPageData });
|
|
}
|