You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.9 KiB
68 lines
1.9 KiB
import bureau from './organization/bureau.json';
|
|
import effect from './organization/effect.json';
|
|
import school from './organization/school.json';
|
|
import department from './organization/department.json';
|
|
|
|
// 代码中会兼容本地 service mock 以及部署站点的静态数据
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
function getBureau(req: any, res: any) {
|
|
const currentPage: number = req.query.currentPage ? Number(req.query.currentPage) : 1;
|
|
const pageSize: number = req.query.pageSize ? Number(req.query.pageSize) : 10;
|
|
const items = [];
|
|
|
|
let i: number;
|
|
|
|
for (
|
|
i = (currentPage - 1) * pageSize;
|
|
i < (Number(currentPage) - 1) * Number(pageSize) + Number(pageSize);
|
|
|
|
) {
|
|
if (bureau.hasOwnProperty(i)) {
|
|
// console.log((Number(currentPage) - 1) * Number(pageSize) + Number(pageSize));
|
|
items.push(bureau[i]);
|
|
}
|
|
i += 1;
|
|
}
|
|
|
|
return res.json({
|
|
list: items,
|
|
pagination: { total: 12, pageSize, current: currentPage },
|
|
});
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
function getEffect(req: any, res: any) {
|
|
return res.json({
|
|
list: effect,
|
|
pagination: {
|
|
total: 12,
|
|
pageSize: Number(req.query.pageSize),
|
|
current: Number(req.query.currentPage),
|
|
},
|
|
});
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
function getSchool(req: any, res: any) {
|
|
return res.json({
|
|
list: school,
|
|
pagination: { total: 12, pageSize: req.query.pageSize, current: req.query.currentPage },
|
|
});
|
|
}
|
|
|
|
// 获取部门
|
|
function getDepartment(req: any, res: any) {
|
|
return res.json({
|
|
list: department,
|
|
pagination: { total: 12, pageSize: 10, current: 1 },
|
|
});
|
|
}
|
|
|
|
export default {
|
|
'GET /api/organization/bureau': getBureau,
|
|
'GET /api/organization/effect': getEffect,
|
|
'GET /api/organization/school': getSchool,
|
|
'GET /api/organization/department': getDepartment,
|
|
};
|