From 3421109f8b5be1ab68a08a3a4e2c52245752bbbf Mon Sep 17 00:00:00 2001 From: LovebuildJ Date: Fri, 7 Aug 2020 13:59:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E6=9D=83?= =?UTF-8?q?=E9=99=90=E8=8F=9C=E5=8D=95=E6=8E=A7=E5=88=B6,=20=E9=9D=9E?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E7=94=A8=E6=88=B7=E6=97=A0=E6=B3=95?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E5=9B=BE=E4=B9=A6,=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=AF=BB=E8=80=85,=20=E7=AE=A1=E7=90=86=E7=94=A8=E6=88=B7,=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AE=A1=E7=90=86=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/book.sql | 10 ++++---- src/main/resources/templates/index.html | 33 ++++++++++++++++--------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/sql/book.sql b/sql/book.sql index 32fd708..b09ed92 100644 --- a/sql/book.sql +++ b/sql/book.sql @@ -107,9 +107,9 @@ CREATE TABLE `users` ( -- ---------------------------- -- Records of users -- ---------------------------- -INSERT INTO `users` VALUES ('1', '上海', 'string', '2020-07-14 19:01:33.863000', 'stu@163.com', '0', '0', '学生', '123', '2', '13576145550', 'stu'); -INSERT INTO `users` VALUES ('2', '上海', 'string', '2020-07-14 19:01:33.863000', 'tea@163.com', '1', '0', '教师', '123', '0', 'string', 'tea'); -INSERT INTO `users` VALUES ('3', '北京', 'a.jpg', '2020-07-14 19:01:33.863000', 'other@163.com', '2', '0', '社会人士', '123', '3', '15078826452', 'other'); +INSERT INTO `users` VALUES ('1', '上海', 'string', '2020-07-14 19:01:33.863000', 'stu@163.com', '0', '1', '学生', '123', '2', '13576145550', 'stu'); +INSERT INTO `users` VALUES ('2', '上海', 'string', '2020-07-14 19:01:33.863000', 'tea@163.com', '1', '1', '教师', '123', '0', 'string', 'tea'); +INSERT INTO `users` VALUES ('3', '北京', 'a.jpg', '2020-07-14 19:01:33.863000', 'other@163.com', '2', '1', '社会人士', '123', '3', '15078826452', 'other'); INSERT INTO `users` VALUES ('4', '北京', 'b.jpa', '2020-07-16 16:06:43.000000', 'admin@163.com', '3', '0', '管理员', '123', '3', '17679088880', 'admin'); -INSERT INTO `users` VALUES ('8', '北京朝阳', 'b.jpa', '1998-02-12 08:00:00.000000', 'guest01@163.com', '3', '0', '游客1', '123', '10', '13576008880', 'guest01'); -INSERT INTO `users` VALUES ('9', '北京', 'b.jpa', '1982-01-01 08:00:00.000000', 'guest02@163.com', '3', '0', '游客2', '123', '10', '1768220000', 'guest02'); +INSERT INTO `users` VALUES ('8', '北京朝阳', 'b.jpa', '1998-02-12 08:00:00.000000', 'guest01@163.com', '3', '1', '游客1', '123', '10', '13576008880', 'guest01'); +INSERT INTO `users` VALUES ('9', '北京', 'b.jpa', '1982-01-01 08:00:00.000000', 'guest02@163.com', '3', '1', '游客2', '123', '10', '1768220000', 'guest02'); diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index a884d89..73aa187 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -59,34 +59,34 @@ @@ -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;