Skip to content

Commit

Permalink
添加用户权限菜单控制, 非管理员用户无法 添加图书, 添加读者, 管理用户, 添加管理员
Browse files Browse the repository at this point in the history
  • Loading branch information
LovebuildJ committed Aug 7, 2020
1 parent 42ad2e2 commit 3421109
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
10 changes: 5 additions & 5 deletions sql/book.sql
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ CREATE TABLE `users` (
-- ----------------------------
-- Records of users
-- ----------------------------
INSERT INTO `users` VALUES ('1', '上海', 'string', '2020-07-14 19:01:33.863000', '[email protected]', '0', '0', '学生', '123', '2', '13576145550', 'stu');
INSERT INTO `users` VALUES ('2', '上海', 'string', '2020-07-14 19:01:33.863000', '[email protected]', '1', '0', '教师', '123', '0', 'string', 'tea');
INSERT INTO `users` VALUES ('3', '北京', 'a.jpg', '2020-07-14 19:01:33.863000', '[email protected]', '2', '0', '社会人士', '123', '3', '15078826452', 'other');
INSERT INTO `users` VALUES ('1', '上海', 'string', '2020-07-14 19:01:33.863000', '[email protected]', '0', '1', '学生', '123', '2', '13576145550', 'stu');
INSERT INTO `users` VALUES ('2', '上海', 'string', '2020-07-14 19:01:33.863000', '[email protected]', '1', '1', '教师', '123', '0', 'string', 'tea');
INSERT INTO `users` VALUES ('3', '北京', 'a.jpg', '2020-07-14 19:01:33.863000', '[email protected]', '2', '1', '社会人士', '123', '3', '15078826452', 'other');
INSERT INTO `users` VALUES ('4', '北京', 'b.jpa', '2020-07-16 16:06:43.000000', '[email protected]', '3', '0', '管理员', '123', '3', '17679088880', 'admin');
INSERT INTO `users` VALUES ('8', '北京朝阳', 'b.jpa', '1998-02-12 08:00:00.000000', '[email protected]', '3', '0', '游客1', '123', '10', '13576008880', 'guest01');
INSERT INTO `users` VALUES ('9', '北京', 'b.jpa', '1982-01-01 08:00:00.000000', '[email protected]', '3', '0', '游客2', '123', '10', '1768220000', 'guest02');
INSERT INTO `users` VALUES ('8', '北京朝阳', 'b.jpa', '1998-02-12 08:00:00.000000', '[email protected]', '3', '1', '游客1', '123', '10', '13576008880', 'guest01');
INSERT INTO `users` VALUES ('9', '北京', 'b.jpa', '1982-01-01 08:00:00.000000', '[email protected]', '3', '1', '游客2', '123', '10', '1768220000', 'guest02');
33 changes: 21 additions & 12 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,34 +59,34 @@
<li class="menu-item">
<a href="javascript:;">图书管理<i class="icon-keyboard_arrow_left"></i></a>
<ul>
<li><a href="javascript:page('book/book-list');">图书列表</a></li>
<li><a href="javascript:page('book/book-add');">图书上架</a></li>
<li><a id="book-list" href="javascript:page('book/book-list');">图书列表</a></li>
<li><a id="add-book" href="javascript:page('book/book-add');">图书上架</a></li>
</ul>
</li>

<li class="menu-item">
<a href="javascript:;">借阅管理<i class="icon-keyboard_arrow_left"></i></a>
<ul>
<li><a href="javascript:page('borrow/book-search');">搜索图书</a></li>
<li><a href="javascript:page('borrow/borrow');">借阅图书</a></li>
<li><a href="javascript:page('borrow/back');">归还图书</a></li>
<li><a id="book-search" href="javascript:page('borrow/book-search');">搜索图书</a></li>
<li><a id="book-borrow" href="javascript:page('borrow/borrow');">借阅图书</a></li>
<li><a id="book-back" href="javascript:page('borrow/back');">归还图书</a></li>
</ul>
</li>

<li class="menu-item">
<a href="javascript:;">读者管理<i class="icon-keyboard_arrow_left"></i></a>
<ul>
<li><a href="javascript:page('reader/reader-list');">读者列表</a></li>
<li><a href="javascript:page('reader/reader-add');">读者添加</a></li>
<li><a id="reader-list" href="javascript:page('reader/reader-list');">读者列表</a></li>
<li><a id="reader-add" href="javascript:page('reader/reader-add');">读者添加</a></li>
</ul>
</li>

<li class="menu-item">
<a href="javascript:;">用户中心<i class="icon-keyboard_arrow_left"></i></a>
<ul>
<li><a href="javascript:page('user/user-info');">个人信息</a></li>
<li><a href="javascript:page('user/user-list');">用户管理</a></li>
<li><a href="javascript:page('user/user-add');">添加管理员</a></li>
<li><a id="user-info" href="javascript:page('user/user-info');">个人信息</a></li>
<li><a id="user-manage" href="javascript:page('user/user-list');">用户管理</a></li>
<li><a id="admin-add" href="javascript:page('user/user-add');">添加管理员</a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -130,14 +130,23 @@
}

$(document).ready(function(){
// 页面一加载, 读取登录用户信息
// get读取参数
// 页面一加载, 读取登录用户信息, 进行权限限制
$.get("/user/currUser", function(data){
var code = data.code;
var user = data.data;
if (code == 200) {
// 设置用户昵称
$("#nickname").text(user.nickname);
// 根据用户权限, 控制用户可见菜单
var auth = user.isAdmin;
if (auth != 0) {
console.log(auth);
// 若为普通用户权限, 则无法访问修改类菜单 无法添加图书,添加读者,管理用户以及添加管理员
$("#add-book").hide();
$("#reader-add").hide();
$("#user-manage").hide();
$("#admin-add").hide();
}
}

return false;
Expand Down

0 comments on commit 3421109

Please sign in to comment.