Skip to content

Commit

Permalink
rbac
Browse files Browse the repository at this point in the history
rbac

Co-Authored-By: icenotu <[email protected]>
  • Loading branch information
icenotu and icenotu committed Jan 8, 2019
1 parent dc7f6b4 commit 09097d8
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 2 deletions.
20 changes: 20 additions & 0 deletions app/controller/admin/access.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

const Controller = require('egg').Controller;

class AccessController extends Controller {
async index() {
this.ctx.body = '权限管理';
}
async add() {
this.ctx.body = '权限增加';
}
async edit() {
this.ctx.body = '权限编辑';
}
async delete() {
this.ctx.body = '权限删除';
}
}

module.exports = AccessController;
23 changes: 23 additions & 0 deletions app/controller/admin/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const Controller = require('egg').Controller;

class ManagerController extends Controller {
async index() {
await this.ctx.render('admin/manager/index',{
username:'chrisYoung',
});
}
async add() {
this.ctx.body = '管理员增加';
}
async edit() {
this.ctx.body = '管理员编辑';
}
async delete() {
this.ctx.body = '管理员删除';
}
}

module.exports = ManagerController;

20 changes: 20 additions & 0 deletions app/controller/admin/role.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

const Controller = require('egg').Controller;

class RoleController extends Controller {
async index() {
this.ctx.body = '角色管理';
}
async add() {
this.ctx.body = '角色增加';
}
async edit() {
this.ctx.body = '角色编辑';
}
async delete() {
this.ctx.body = '角色删除';
}
}

module.exports = RoleController;
5 changes: 4 additions & 1 deletion app/controller/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ const Controller = require('egg').Controller;

class HomeController extends Controller {
async index() {
this.ctx.body = 'hi, egg';
// this.ctx.body = 'hi, egg';
await this.ctx.render('index/home.nj',{
username:'boyayingwen',
});
}
}

Expand Down
15 changes: 15 additions & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,19 @@
module.exports = app => {
const { router, controller } = app;
router.get('/', controller.home.index);

router.get('/admin/manager', controller.admin.manager.index);
router.get('/admin/manager/add', controller.admin.manager.add);
router.get('/admin/manager/edit', controller.admin.manager.edit);
router.get('/admin/manager/delete', controller.admin.manager.delete);

router.get('/admin/role', controller.admin.role.index);
router.get('/admin/role/add', controller.admin.role.add);
router.get('/admin/role/edit', controller.admin.role.edit);
router.get('/admin/role/delete', controller.admin.role.delete);

router.get('/admin/access', controller.admin.access.index);
router.get('/admin/access/add', controller.admin.access.add);
router.get('/admin/access/edit', controller.admin.access.edit);
router.get('/admin/access/delete', controller.admin.access.delete);
};
12 changes: 12 additions & 0 deletions app/view/admin/manager/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>管理员管理</title>
</head>
<body>
<h2>hello world ejs--<%= username %> </h2>
</body>
</html>
12 changes: 12 additions & 0 deletions app/view/index/home.nj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>首页</title>
</head>
<body>
<h2>hello world nunjucks--{{username }}</h2>
</body>
</html>
7 changes: 7 additions & 0 deletions config/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@ module.exports = appInfo => {
// add your config here
config.middleware = [];


exports.view = {
mapping: {
'.html': 'ejs',
'.nj': 'nunjucks',
},
};
return config;
};
8 changes: 8 additions & 0 deletions config/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@

// had enabled by egg
// exports.static = true;
exports.ejs = {
enable: true,
package: 'egg-view-ejs',
};
exports.nunjucks = {
enable: true,
package: 'egg-view-nunjucks',
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"private": true,
"dependencies": {
"egg": "^2.2.1",
"egg-scripts": "^2.5.0"
"egg-scripts": "^2.5.0",
"egg-view-ejs": "^2.0.0",
"egg-view-nunjucks": "^2.2.0"
},
"devDependencies": {
"autod": "^3.0.1",
Expand Down

0 comments on commit 09097d8

Please sign in to comment.