1
0
mirror of https://github.com/chillzhuang/Sword synced 2024-11-22 18:29:26 +08:00
Sword/mock/role.js

106 lines
2.2 KiB
JavaScript
Raw Normal View History

2019-02-13 17:16:39 +08:00
import { delay } from 'roadhog-api-doc';
function getFakeList(req, res) {
const json = { code: 200, success: true, msg: '操作成功' };
const data = [];
data.push(
{
id: '1',
roleName: '超级管理员',
2019-11-19 17:34:16 +08:00
tenantId: '000000',
2019-02-13 17:16:39 +08:00
roleAlias: 'administrator',
sort: '1',
children: [
{
id: '2',
roleName: '管理员',
2019-11-19 17:34:16 +08:00
tenantId: '000001',
2019-02-13 17:16:39 +08:00
roleAlias: 'admin',
sort: '1',
},
],
},
{
id: '3',
roleName: '用户',
2019-11-19 17:34:16 +08:00
tenantId: '000002',
2019-02-13 17:16:39 +08:00
roleAlias: 'user',
sort: '2',
children: [
{
id: '4',
roleName: '普通用户',
2019-11-19 17:34:16 +08:00
tenantId: '000003',
2019-02-13 17:16:39 +08:00
roleAlias: 'user',
sort: '1',
},
{
id: '5',
roleName: '访客',
2019-11-19 17:34:16 +08:00
tenantId: '000004',
2019-02-13 17:16:39 +08:00
roleAlias: 'guest',
sort: '2',
},
],
}
);
json.data = data;
return res.json(json);
}
function getFakeDetail(req, res) {
const json = { code: 200, success: true, msg: '操作成功' };
const detail = {
id: 2,
parentId: 1,
parentName: '超级管理员',
2019-11-19 17:34:16 +08:00
tenantId: '000000',
2019-02-13 17:16:39 +08:00
roleName: '用户',
roleAlias: 'user',
sort: 1,
nextSort: 4,
remark: '测试备注',
};
json.data = detail;
return res.json(json);
}
function getFakeTree(req, res) {
const json = { code: 200, success: true, msg: '操作成功' };
const list = [];
list.push({
title: '超级管理员',
value: '1',
key: '1',
children: [
{
title: '用户',
value: '2',
key: '2',
},
{
title: '测试',
value: '3',
key: '3',
},
],
});
json.data = list;
return res.json(json);
}
function fakeSuccess(req, res) {
const json = { code: 200, success: true, msg: '操作成功' };
return res.json(json);
}
const proxy = {
'GET /api/blade-system/role/list': getFakeList,
'GET /api/blade-system/role/detail': getFakeDetail,
'GET /api/blade-system/role/tree': getFakeTree,
'POST /api/blade-system/role/submit': fakeSuccess,
'POST /api/blade-system/role/remove': fakeSuccess,
'POST /api/blade-system/role/grant': fakeSuccess,
};
export default delay(proxy, 500);