From 54bd66d8a99192c763b77305aef02d45bbd59fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=AF=85=E9=AA=8F?= Date: Tue, 12 Jan 2021 15:16:15 +0800 Subject: [PATCH] 'update' --- db/mydoc.sql | 640 +++++++++++++----- .../server/user/contant/CommonConstants.java | 2 + .../user/controller/UserAuthController.java | 12 +- .../user/login/service/PermissionService.java | 35 +- .../mydoc/server/user/mapper/MenuMapper.java | 8 + .../server/user/service/MenuService.java | 12 + .../user/service/impl/MenuServiceImpl.java | 67 ++ .../mydoc/server/util/jwt/TokenUtil.java | 2 +- src/main/resources/mapper/user/MenuMapper.xml | 13 + 9 files changed, 604 insertions(+), 187 deletions(-) diff --git a/db/mydoc.sql b/db/mydoc.sql index 5cb2c27..e5e2a4f 100644 --- a/db/mydoc.sql +++ b/db/mydoc.sql @@ -1,199 +1,477 @@ -create DATABASE mydoc; -use mydoc; -create table article ( - id varchar(64) not null PRIMARY key comment '文章id', - user_id varchar(64) not null comment '作者id', - status int(4) default 1 comment '显示状态 0 私密 1 公开 2不显示 3删除', - original int(4) comment '原创 0 原创 1 转载', - reprint_link varchar(100) comment '转载来源链接url', - examine_status int(4) comment '文章审核状态 0 待审核 1 已审核 2、已驳回', - examine_time datetime comment '文章审核时间', - browse_num int(11) comment '浏览次数', - fabulous_num int(11) comment '点赞次数', - create_time datetime comment '创建时间', - update_time datetime comment '更新时间' -); +/* + Navicat Premium Data Transfer -create table article_information ( - id varchar(64) NOT NULL PRIMARY KEY, - article_id varchar(64) not null comment '文章id', - content_id varchar(64) not null comment '内容id', - user_id varchar(64) not null comment '用户id', - classify_id varchar(64) comment '分类id', - tag_id varchar(64) comment '标签id', - type_id int(4) comment '文章类型表id' -); + Source Server : mysql57 + Source Server Type : MySQL + Source Server Version : 50732 + Source Host : localhost:3306 + Source Schema : mydoc -create table article_content ( - id varchar(64) comment '内容id', - content longtext default null COMMENT '内容' -); + Target Server Type : MySQL + Target Server Version : 50732 + File Encoding : 65001 -create table article_classify ( - id varchar(64) not null primary key comment '分类id', - parent_id varchar(64) default 0 comment '父分类id 若为0则父分类', - name varchar(64) comment '分类名称', - status int comment '状态 0删除/弃用 1表示使用', - create_time datetime comment '创建时间', - update_time datetime comment '更新时间' -); -create table article_tag ( - id varchar(64) not null primary key comment '标签id', - name varchar(20) not null comment '标签名称', - status int(2) default 1 comment '状态 0删除/弃用 1表示使用', - create_time datetime comment '创建时间', - update_time datetime comment '更新时间' -); + Date: 12/01/2021 15:13:42 +*/ -create table article_type ( - id varchar(64) not null primary key comment '文章类型id', - name varchar(20) comment '文章类型名字', - user_id varchar(64) comment '创建者 用户id', - create_time datetime comment '创建时间', - update_time datetime comment '更新时间' -); +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; -create table article_fabulous ( - id varchar(64) not null primary key comment 'id', - article_id varchar(64) not null comment '文章id', - user_id varchar(64) not null comment '点赞者 用户id', - fabulous_time datetime comment '点赞时间' -); +-- ---------------------------- +-- Table structure for article +-- ---------------------------- +DROP TABLE IF EXISTS `article`; +CREATE TABLE `article` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '文章id', + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '作者id', + `status` int(4) NULL DEFAULT 1 COMMENT '显示状态 0 私密 1 公开 2不显示 3删除', + `original` int(4) NULL DEFAULT NULL COMMENT '原创 0 原创 1 转载', + `reprint_link` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '转载来源链接url', + `examine_status` int(4) NULL DEFAULT NULL COMMENT '文章审核状态 0 待审核 1 已审核 2、已驳回', + `examine_time` datetime(0) NULL DEFAULT NULL COMMENT '文章审核时间', + `browse_num` int(11) NULL DEFAULT NULL COMMENT '浏览次数', + `fabulous_num` int(11) NULL DEFAULT NULL COMMENT '点赞次数', + `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '简介', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -create table article_discuss ( - id varchar(64) not null primary key comment '评论表id', - article_id varchar(64) not null comment '文章id', - user_id varchar(64) not null comment '评论用户id', - content nvarchar(500) default NULL comment '评论内容', - target_user_id varchar(64) not null comment '评论目标用户id', - discuss_time datetime comment '评论时间' -); +-- ---------------------------- +-- Records of article +-- ---------------------------- -create table article_browse ( - id varchar(64) not null primary key comment 'id', - article_id varchar(64) not null comment '评论表id', - user_id varchar(64) not null comment '评论用户id', - browse_time datetime comment '评论时间' -); +-- ---------------------------- +-- Table structure for article_browse +-- ---------------------------- +DROP TABLE IF EXISTS `article_browse`; +CREATE TABLE `article_browse` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'id', + `article_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '评论表id', + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '评论用户id', + `browse_time` datetime(0) NULL DEFAULT NULL COMMENT '评论时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -create table user ( - id varchar(64) not null primary key comment '用户id', - username varchar(64) not null comment '用户名', - nickname varchar(64) comment '昵称', - age int(3) comment '用户年龄', - avatar varchar(255) DEFAULT NULL COMMENT '头像', - password varchar(100) comment '用户密码', - phone int(12) comment '用户密码', - email varchar(64) comment '邮箱', - introduction varchar(600) default null comment '用户介绍', - status int(4) comment '用户状态 0启用 1注销', - follow_num int(11) comment '关注数量', - fans_num int(11) comment '粉丝数量', - create_time datetime comment '创建时间', - update_time datetime comment '更新时间' -); +-- ---------------------------- +-- Records of article_browse +-- ---------------------------- -create table user_relation ( - id varchar(64) not null primary key comment 'id', - user_id varchar(64) not null comment '用户id', - user_tag_id varchar(64) comment '标签id', - follow_id varchar(64) comment '关注列表id', - fans_id varchar(64) comment '粉丝列表id', - collect_id varchar(64) comment '粉丝列表id' -); +-- ---------------------------- +-- Table structure for article_classify +-- ---------------------------- +DROP TABLE IF EXISTS `article_classify`; +CREATE TABLE `article_classify` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '分类id', + `parent_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '0' COMMENT '父分类id 若为0则父分类', + `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '分类名称', + `status` int(11) NULL DEFAULT NULL COMMENT '状态 0删除/弃用 1表示使用', + `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '简介', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -create table user_tag ( - id varchar(64) not null primary key comment '标签id', - parent_id varchar(64) default null comment '父标签id null 父标签 其余则为子标签 ', - name varchar(64) comment '标签名称' -); +-- ---------------------------- +-- Records of article_classify +-- ---------------------------- -create table user_follow ( - id varchar(64) not null primary key comment 'id', - user_id varchar(64) not null comment '用户id', - user_follow_id varchar(64) not null comment '关注目标用户id' -); +-- ---------------------------- +-- Table structure for article_content +-- ---------------------------- +DROP TABLE IF EXISTS `article_content`; +CREATE TABLE `article_content` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '内容id', + `content` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '内容' +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -create table user_fans ( - id varchar(64) not null primary key comment 'id', - user_id varchar(64) not null comment '用户id', - user_fans_id varchar(64) not null comment '粉丝id' -); +-- ---------------------------- +-- Records of article_content +-- ---------------------------- -create table user_collect ( - id varchar(64) not null primary key comment '收藏夹id', - name varchar(64) not null comment '收藏夹名字', - user_id varchar(64) not null comment '用户id', - article_id varchar(64) not null comment '文章id' -); +-- ---------------------------- +-- Table structure for article_discuss +-- ---------------------------- +DROP TABLE IF EXISTS `article_discuss`; +CREATE TABLE `article_discuss` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '评论表id', + `article_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '文章id', + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '评论用户id', + `content` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '评论内容', + `target_user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '评论目标用户id', + `discuss_time` datetime(0) NULL DEFAULT NULL COMMENT '评论时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -create table user_configure ( - id varchar(64) not null primary key comment '用户配置id', - user_id varchar(64) not null comment '用户id', - theme_colour int(4) default 0 comment '主题 0 白色 1黑色', - theme_background varchar(50) default null comment '系统背景图片 url String', - editor int default 0 comment '默认编辑器id 0 markdown 1.富文本' -); +-- ---------------------------- +-- Records of article_discuss +-- ---------------------------- -create table system_configure ( - id varchar(64) not null primary key comment '全局配置表id', - icp varchar(64) default null comment '备案信息', - footer varchar(100) default null comment '页脚信息', - title varchar(50) default '笔记' comment '站点标题', - subtitle varchar(50) default null comment '站点副标题', - site_name varchar(50) default '笔记' comment '站点名称', - register int(4) default 0 comment '注册是否需要邀请码 0不需要 1需要' -); +-- ---------------------------- +-- Table structure for article_fabulous +-- ---------------------------- +DROP TABLE IF EXISTS `article_fabulous`; +CREATE TABLE `article_fabulous` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'id', + `article_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '文章id', + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '点赞者 用户id', + `fabulous_time` datetime(0) NULL DEFAULT NULL COMMENT '点赞时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -create table information ( - id varchar(64) not null primary key comment '消息id', - user_id varchar(64) not null comment '发送者id 发送者为0 则为系统', - news_content varchar(600) default null comment '内容', - point_user_id varchar(64) not null comment '目标用户id', - images varchar(640) default null comment '图片列表', - send_time datetime comment '发送时间' -); +-- ---------------------------- +-- Records of article_fabulous +-- ---------------------------- -create table invitation_code ( - id varchar(64) not null primary key comment '邀请码id', - code varchar(20) not null comment '邀请码', - status int(2) default 0 comment '状态 0 正常 1失效 ', - use_times int(4) default 10 comment '可以使用的次数', - create_id varchar(64) not null comment '创建者id', - create_time datetime comment '创建时间', - invalid_time datetime comment '失效时间' -); -CREATE TABLE user_role ( - id varchar(64) NOT NULL PRIMARY KEY comment '用户角色关联表id', - user_id varchar(64) DEFAULT NULL comment '用户id', - role_id varchar(64) DEFAULT NULL comment '角色id' -); +-- ---------------------------- +-- Table structure for article_information +-- ---------------------------- +DROP TABLE IF EXISTS `article_information`; +CREATE TABLE `article_information` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `article_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '文章id', + `content_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '内容id', + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户id', + `classify_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '分类id', + `tag_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '标签id', + `type_id` int(4) NULL DEFAULT NULL COMMENT '文章类型表id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -CREATE TABLE role ( - id varchar(64) NOT NULL primary key comment 'id', - name varchar(64) DEFAULT NULL comment '角色名字', - icon varchar(64) DEFAULT NULL comment '角色图标', - description varchar(64) DEFAULT NULL comment '角色介绍', - create_time datetime comment '创建时间', - update_time datetime comment '更新时间' -); -CREATE TABLE menu_role ( - id varchar(64) NOT NULL PRIMARY KEY comment '角色权限关联表id', - role_id varchar(64) DEFAULT NULL comment '角色id', - menu_id varchar(64) DEFAULT NULL comment '权限id' -); -CREATE TABLE menu ( - id varchar(64) NOT NULL primary key comment '权限表id', - name varchar(64) DEFAULT NULL comment '权限名字', - icon varchar(64) DEFAULT NULL comment '权限权限图标', - url varchar(64) DEFAULT NULL comment '权限路径', - parent_id varchar(64) DEFAULT NULL comment '父节点', - description varchar(64) DEFAULT NULL comment '介绍', - create_time datetime comment '创建时间', - update_time datetime comment '更新时间' -); -CREATE TABLE user_menu ( - id varchar(64) NOT NULL PRIMARY KEY, - user_id varchar(64) DEFAULT NULL, - role_id varchar(64) DEFAULT NULL -); \ No newline at end of file +-- ---------------------------- +-- Records of article_information +-- ---------------------------- + +-- ---------------------------- +-- Table structure for article_tag +-- ---------------------------- +DROP TABLE IF EXISTS `article_tag`; +CREATE TABLE `article_tag` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标签id', + `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标签名称', + `status` int(2) NULL DEFAULT 1 COMMENT '状态 0删除/弃用 1表示使用', + `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '介绍', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of article_tag +-- ---------------------------- + +-- ---------------------------- +-- Table structure for article_type +-- ---------------------------- +DROP TABLE IF EXISTS `article_type`; +CREATE TABLE `article_type` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '文章类型id', + `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文章类型名字', + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建者 用户id', + `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '简介', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of article_type +-- ---------------------------- + +-- ---------------------------- +-- Table structure for information +-- ---------------------------- +DROP TABLE IF EXISTS `information`; +CREATE TABLE `information` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '消息id', + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '发送者id 发送者为0 则为系统', + `news_content` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '内容', + `point_user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '目标用户id', + `images` varchar(640) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图片列表', + `send_time` datetime(0) NULL DEFAULT NULL COMMENT '发送时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of information +-- ---------------------------- + +-- ---------------------------- +-- Table structure for invitation_code +-- ---------------------------- +DROP TABLE IF EXISTS `invitation_code`; +CREATE TABLE `invitation_code` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '邀请码id', + `code` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '邀请码', + `status` int(2) NULL DEFAULT 0 COMMENT '状态 0 正常 1失效 ', + `use_times` int(4) NULL DEFAULT 10 COMMENT '可以使用的次数', + `create_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '创建者id', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `invalid_time` datetime(0) NULL DEFAULT NULL COMMENT '失效时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of invitation_code +-- ---------------------------- + +-- ---------------------------- +-- Table structure for menu +-- ---------------------------- +DROP TABLE IF EXISTS `menu`; +CREATE TABLE `menu` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '权限表id', + `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '权限名字', + `icon` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '权限权限图标', + `url` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '权限路径', + `type` int(4) NOT NULL COMMENT '类型 0菜单 1按钮', + `parent_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '父节点', + `description` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '介绍', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of menu +-- ---------------------------- +INSERT INTO `menu` VALUES ('1', '系统管理员权限', NULL, '/**', 0, NULL, '所有权限', '2021-01-06 18:18:55', '2021-01-06 18:18:57'); +INSERT INTO `menu` VALUES ('2', '系统菜单', NULL, NULL, 0, '-1', '系统菜单', '2021-01-08 10:12:31', '2021-01-08 10:12:34'); +INSERT INTO `menu` VALUES ('3', '文章管理', NULL, '/article', 0, '2', '文章管理', '2021-01-08 10:12:26', '2021-01-08 10:12:29'); +INSERT INTO `menu` VALUES ('4', '添加', NULL, '/add/**', 1, '3', '添加文章', NULL, NULL); +INSERT INTO `menu` VALUES ('5', '修改', NULL, '/edit/**', 1, '3', '修改文章', NULL, NULL); +INSERT INTO `menu` VALUES ('6', '系统管理', NULL, '/system', 0, '2', '系统管理', NULL, NULL); +INSERT INTO `menu` VALUES ('7', '消息管理', NULL, '/infomation', 0, '2', '消息管理', NULL, NULL); + +-- ---------------------------- +-- Table structure for menu_role +-- ---------------------------- +DROP TABLE IF EXISTS `menu_role`; +CREATE TABLE `menu_role` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '角色权限关联表id', + `role_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色id', + `menu_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '权限id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of menu_role +-- ---------------------------- +INSERT INTO `menu_role` VALUES ('1', '1', '1'); +INSERT INTO `menu_role` VALUES ('2', '2', '2'); +INSERT INTO `menu_role` VALUES ('3', '2', '3'); +INSERT INTO `menu_role` VALUES ('4', '2', '4'); + +-- ---------------------------- +-- Table structure for persistent_logins +-- ---------------------------- +DROP TABLE IF EXISTS `persistent_logins`; +CREATE TABLE `persistent_logins` ( + `username` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `series` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `token` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `last_used` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0), + PRIMARY KEY (`series`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of persistent_logins +-- ---------------------------- + +-- ---------------------------- +-- Table structure for role +-- ---------------------------- +DROP TABLE IF EXISTS `role`; +CREATE TABLE `role` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'id', + `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色名字', + `icon` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色图标', + `description` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色介绍', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of role +-- ---------------------------- +INSERT INTO `role` VALUES ('1', '系统管理员', NULL, '系统管理员', '2021-01-06 18:22:54', '2021-01-06 18:22:57'); +INSERT INTO `role` VALUES ('2', 'test', NULL, 'test', NULL, NULL); + +-- ---------------------------- +-- Table structure for system_configure +-- ---------------------------- +DROP TABLE IF EXISTS `system_configure`; +CREATE TABLE `system_configure` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '全局配置表id', + `icp` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备案信息', + `footer` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '页脚信息', + `title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '笔记' COMMENT '站点标题', + `subtitle` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '站点副标题', + `site_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '笔记' COMMENT '站点名称', + `register` int(4) NULL DEFAULT 0 COMMENT '注册是否需要邀请码 0不需要 1需要', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of system_configure +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user +-- ---------------------------- +DROP TABLE IF EXISTS `user`; +CREATE TABLE `user` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户id', + `username` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名', + `nickname` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '昵称', + `age` int(11) NULL DEFAULT NULL COMMENT '用户年龄', + `avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '头像', + `password` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户密码', + `phone` int(12) NULL DEFAULT NULL COMMENT '用户密码', + `email` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邮箱', + `invite_user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邀请者id', + `status` int(4) NULL DEFAULT NULL COMMENT '用户状态 1启用 0注销', + `follow_num` int(6) NULL DEFAULT NULL COMMENT '关注数量', + `fans_num` int(10) NULL DEFAULT NULL COMMENT '粉丝数量', + `login_time` datetime(0) NULL DEFAULT NULL COMMENT '登录时间', + `description` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户介绍', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE INDEX `username`(`username`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user +-- ---------------------------- +INSERT INTO `user` VALUES ('1', 'zhuyijun', 'nicemoe', 23, NULL, '$2a$10$EQbRCiDDT59P.TdmjngyFucvSrtmpZRS7oQyiMJCVs7ZmPhXcVb3O', 1345411414, '111@qq.com', NULL, 1, 0, 0, '2021-01-02 00:08:12', '1111', '2021-01-02 00:08:15', '2021-01-02 00:08:18'); + +-- ---------------------------- +-- Table structure for user_collect +-- ---------------------------- +DROP TABLE IF EXISTS `user_collect`; +CREATE TABLE `user_collect` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '收藏夹id', + `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '收藏夹名字', + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户id', + `article_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '文章id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_collect +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user_configure +-- ---------------------------- +DROP TABLE IF EXISTS `user_configure`; +CREATE TABLE `user_configure` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户配置id', + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户id', + `theme_colour` int(4) NULL DEFAULT 0 COMMENT '主题 0 白色 1黑色', + `theme_background` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '系统背景图片 url String', + `editor` int(11) NULL DEFAULT 0 COMMENT '默认编辑器id 0 markdown 1.富文本', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_configure +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user_fans +-- ---------------------------- +DROP TABLE IF EXISTS `user_fans`; +CREATE TABLE `user_fans` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'id', + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户id', + `user_fans_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '粉丝id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_fans +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user_follow +-- ---------------------------- +DROP TABLE IF EXISTS `user_follow`; +CREATE TABLE `user_follow` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'id', + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户id', + `user_follow_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '关注目标用户id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_follow +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user_menu +-- ---------------------------- +DROP TABLE IF EXISTS `user_menu`; +CREATE TABLE `user_menu` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `menu_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_menu +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user_relation +-- ---------------------------- +DROP TABLE IF EXISTS `user_relation`; +CREATE TABLE `user_relation` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'id', + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户id', + `user_tag_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '标签id', + `follow_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '关注列表id', + `fans_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '粉丝列表id', + `collect_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '粉丝列表id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_relation +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user_role +-- ---------------------------- +DROP TABLE IF EXISTS `user_role`; +CREATE TABLE `user_role` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户角色关联表id', + `user_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户id', + `role_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_role +-- ---------------------------- +INSERT INTO `user_role` VALUES ('1', '1', '1'); + +-- ---------------------------- +-- Table structure for user_tag +-- ---------------------------- +DROP TABLE IF EXISTS `user_tag`; +CREATE TABLE `user_tag` ( + `id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标签id', + `parent_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '父标签id null 父标签 其余则为子标签 ', + `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '标签名称', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of user_tag +-- ---------------------------- + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/src/main/java/com/zyjblogs/mydoc/server/user/contant/CommonConstants.java b/src/main/java/com/zyjblogs/mydoc/server/user/contant/CommonConstants.java index e1b1f06..3c1d4b0 100644 --- a/src/main/java/com/zyjblogs/mydoc/server/user/contant/CommonConstants.java +++ b/src/main/java/com/zyjblogs/mydoc/server/user/contant/CommonConstants.java @@ -32,6 +32,8 @@ public class CommonConstants { public static final String USER_NAME_RESULT = "username"; public static final String USER_TOKEN_RESULT = "token"; public static final String TOKEN_INVAILD_TIME_RESULT = "invalid_time"; + public static final String USER_PREFIX = "user:"; + public static final String TOKEN_PREFIX = "token:"; public CommonConstants() { } diff --git a/src/main/java/com/zyjblogs/mydoc/server/user/controller/UserAuthController.java b/src/main/java/com/zyjblogs/mydoc/server/user/controller/UserAuthController.java index cccb84f..3b74b95 100644 --- a/src/main/java/com/zyjblogs/mydoc/server/user/controller/UserAuthController.java +++ b/src/main/java/com/zyjblogs/mydoc/server/user/controller/UserAuthController.java @@ -159,8 +159,7 @@ public class UserAuthController { @PathVariable("userId") @Length(message = "用户Id长度限制", min = 1, max = 64) @NotNull - @ApiParam - String userId, + @ApiParam String userId, @Length(message = "权限类型只能为0或者1", min = 1, max = 1) @NotNull @ApiParam @@ -172,4 +171,13 @@ public class UserAuthController { return ResponseResult.success(menuVOS); } + /** + * 获取权限菜单树结构 + * + * @return + */ + @PostMapping("/menutree") + public ResponseObject getRootMenus() { + return permissionService.getRootMenus(); + } } diff --git a/src/main/java/com/zyjblogs/mydoc/server/user/login/service/PermissionService.java b/src/main/java/com/zyjblogs/mydoc/server/user/login/service/PermissionService.java index 9d9a069..62d30c4 100644 --- a/src/main/java/com/zyjblogs/mydoc/server/user/login/service/PermissionService.java +++ b/src/main/java/com/zyjblogs/mydoc/server/user/login/service/PermissionService.java @@ -1,11 +1,14 @@ package com.zyjblogs.mydoc.server.user.login.service; +import com.zyjblogs.mydoc.server.user.contant.CommonConstants; import com.zyjblogs.mydoc.server.user.login.LoginUserDetails; import com.zyjblogs.mydoc.server.user.service.*; import com.zyjblogs.mydoc.server.user.vo.MenuVO; import com.zyjblogs.mydoc.server.user.vo.UserVO; import com.zyjblogs.mydoc.server.util.data.RedisTemplateService; import com.zyjblogs.mydoc.server.util.jwt.TokenUtil; +import com.zyjblogs.mydoc.server.util.response.ResponseObject; +import com.zyjblogs.mydoc.server.util.response.ResponseResult; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -16,6 +19,7 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -28,7 +32,7 @@ import java.util.Set; *