详解nodejs中express搭建权限管理系统(2)

/api/acl_role/getList:获取角色列表 参数:无 返回值: { "code": "200", "msg": "获取详情成功", "result": [ { "name": "经适房用户", "createdAt": "2017-05-26T09:49:22.361Z", "updatedAt": "2017-05-26T09:49:22.361Z", "id": "27aab6d9-325c-4c88-be4a-5da516dc9613" }, { "name": "对账单用户", "createdAt": "2017-05-26T09:52:15.061Z", "updatedAt": "2017-05-26T09:52:15.061Z", "id": "ba306957-9c80-4abb-89fd-17be828dd5f5" }, { "name": "对账单管理员", "createdAt": "2017-05-26T09:52:26.914Z", "updatedAt": "2017-05-26T09:52:26.914Z", "id": "fc154424-2264-4de9-9a7c-1b1df048f802" }, { "name": "超级管理员", "createdAt": "2017-05-26T09:52:39.894Z", "updatedAt": "2017-05-26T09:52:39.894Z", "id": "442cfc56-23a9-4cb9-85b5-641bc161c4c3" } ], "count": 4 }

2.修改角色

/api/acl_role/update 参数: { id:xxx, name:xxx, } 返回值: { code:"200", msg:"修改成功!", result:data.update }

3.查询角色详情(含角色的权限列表)

/api/acl_role/getOne 参数: id:27aab6d9-325c-4c88-be4a-5da516dc9613 返回值: { "code": "200", "msg": "获取详情成功", "result": { "info": { "name": "经适房用户", "createdAt": "2017-05-26T09:49:22.361Z", "updatedAt": "2017-05-26T09:49:22.361Z", "id": "27aab6d9-325c-4c88-be4a-5da516dc9613" }, "resources": { "1": ["*"], "74a7970a-d53e-494b-9671-4b7b415c3469":["*"], "15862997-acef-43c1-a1c3-3af4b8e6588b": ["*"], "d2da6e56-f005-43cf-b109-af3a966fb059": ["*"], "d336dd69-80c7-492f-aee7-78a651b8305e":["*"] } } }

4.删除角色

/api/acl_role/delete ① db删除角色 ② acl删除该角色和资源的关系removeAllow、删除角色removeRole 参数: { id:xxx, } 返回值: { code:"200", msg:"删除成功!", result:result }

5.给角色添加资源

/api/acl_role/allow ① 删除角色和资源的关系acl.removeAllow ② 给角色和资源添加关系acl.allow 参数: { role:xxx, resources:xxx } 返回值: { code:"200", msg:"成功!" }

用户相关:

1.用户登录

/api/acl_user/login 参数: { account:xxx, password:xxx } 返回值: { code:200, msg:"登录成功" } { code:400, msg:"密码错误" } { code:400, msg:"账号不存在" }

2.用户退出

/api/acl_user/logout 参数:{} 返回值: { code:200, msg:"退出成功!" }

3.添加用户

/api/acl_user/add 参数: { name:xxx, account:xxx, password:xxx } 返回值: { code:"200", msg:"创建成功!", result:data.save }

4.修改用户

/api/acl_user/update 参数: { id:xxx, name:xxx, account:xxx, password:xxx } 返回值: { code:"200", msg:"修改成功!", result:data.save }

5.查询用户详情(含用户权限列表)

/api/acl_user/getOne ① db获取用户信息 ② acl获取用户权限allowedPermissions 参数: { id:xxx, name:xxx, account:xxx, password:xxx } 返回值: { code:"200", msg:"修改成功!", result:data.save }

6.获取用户列表

/api/acl_user/getList 参数: { } 返回值: { "code": "200", "msg": "获取详情成功", "result": [ { "name": "wuwanyu", "createdAt": "2017-05-27T02:14:19.994Z", "updatedAt": "2017-05-27T02:50:56.309Z", "account": "120", "password": "123", "id": "7daa4635-9f9d-4c79-9f15-c827097ac15a" } ], "count": 1 }

7.删除用户

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyzpjy.html