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.
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { mockGetBusinessProjectData } from './pools/businessProjectData';
|
|
import { successMockApiProps } from './typing';
|
|
import { fetchCurrPageByList, fetchMockSuccessFullByOther } from './utils/apiMock';
|
|
export default {
|
|
// 企业列表
|
|
'GET /api/businessProject/': async (req: Request, res: Response) => {
|
|
// get 使用 query 读取参数
|
|
const { page, pageSize } = req.query;
|
|
const resData: successMockApiProps = {
|
|
...fetchCurrPageByList({
|
|
...mockGetBusinessProjectData,
|
|
data: { ...mockGetBusinessProjectData.data, page, pageSize: pageSize || 10 },
|
|
}),
|
|
};
|
|
res.json(resData);
|
|
},
|
|
// 企业详情
|
|
'GET /api/businessProject/detail': async (req: Request, res: Response) => {
|
|
// get 使用 query 读取参数
|
|
const { id } = req.query;
|
|
let finalData = {};
|
|
mockGetBusinessProjectData.data.results.forEach((item) => {
|
|
if (item.id === Number(id)) {
|
|
finalData = item;
|
|
// break;
|
|
}
|
|
});
|
|
const resData: successMockApiProps = fetchMockSuccessFullByOther({
|
|
data: finalData,
|
|
});
|
|
res.json(resData);
|
|
},
|
|
};
|