|
|
|
/*
|
|
|
|
* @Author: donghao donghao@supervision.ltd
|
|
|
|
* @Date: 2024-01-24 15:08:23
|
|
|
|
* @LastEditors: donghao donghao@supervision.ltd
|
|
|
|
* @LastEditTime: 2024-04-02 10:03:02
|
|
|
|
* @FilePath: \general-ai-platform-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 {
|
|
|
|
status: 200, // 0 成功状态码
|
|
|
|
success: true, // true 成功
|
|
|
|
data: data || null, // mock业务层数据
|
|
|
|
msg: msg | 'ok', // 成功提示
|
|
|
|
isMock: true, // true 标识当前是模拟数据
|
|
|
|
} as successMockApiProps;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function fetchMockFailFullByOther({ data, msg }): failMockApiProps {
|
|
|
|
return {
|
|
|
|
status: 500, // 失败状态码
|
|
|
|
success: true, // true 成功
|
|
|
|
data: data || null, // mock业务层数据
|
|
|
|
msg: msg | 'fail', // 成功提示
|
|
|
|
isMock: true, // true 标识当前是模拟数据
|
|
|
|
} as failMockApiProps;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 分页展示
|
|
|
|
export function fetchCurrPageByList({ data }): successMockApiProps {
|
|
|
|
console.log('fetchCurrPageByList_data', data);
|
|
|
|
const { page, pageSize } = data;
|
|
|
|
const prevPage = page - 1;
|
|
|
|
const currPageData = {
|
|
|
|
...data,
|
|
|
|
results: data.results.slice(prevPage * pageSize, page * pageSize),
|
|
|
|
};
|
|
|
|
return fetchMockSuccessFullByOther({ data: currPageData });
|
|
|
|
}
|