diff --git a/ReadMe.md b/ReadMe.md index 88f5415..87cfd13 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,67 +1,19 @@ -# 接口说明 +Github地址 -## 请求接口 +- [前端地址](https://github.com/BunnyMaster/bunny-admin-web.git) +- [后端地址](https://github.com/BunnyMaster/bunny-admin-server) -请求接口都是`/admin`前缀,部分接口会被忽略,忽略接口看下面。 +Gitee地址 -所有分页请求内容都是通过路径传参方式 - -请求时需要带有token,只要前端在请求头中添加`token:内容`即可 - -采用SpringSecurity验证 - -## 接口忽略 - -### SpringSecurity接口忽略 - -这是相关拦截请求内容,如果要访问接口必须携带token,但是有些接口是不需要token的,不需要token就配置在这里。但是放在这里后,如果用户请求的地址是被忽略的,那么也就拿不到token也就拿不到登录相关信息。 - -获取用户自身的登录请求是不需要携带用户Id,只要有token去解析即可。 - -```java -// 排出鉴定路径 -@Bean -public WebSecurityCustomizer webSecurityCustomizer() { - String[] annotations = { - "/", "/ws/**", - "/*/*/noAuth/**", "/*/noAuth/**", "/noAuth/**", - "/media.ico", "/favicon.ico", "*.html", "/webjars/**", "/v3/api-docs/**", "swagger-ui/**", - "/*/files/**", - "/error", "/*/i18n/getI18n", - }; - return web -> web.ignoring().requestMatchers(annotations) - .requestMatchers(RegexRequestMatcher.regexMatcher(".*\\.(css|js)$")); -} -``` - -![image-20241022095731221](./data/images/image-20241022095731221.png) - -有些会被忽略的接口,凡是带有`noAuth`都是不需要验证的,但是要注意一点,不需要验证但是后端需要拿到登录相关信息是拿不到的。 - -![image-20241022095311658](./data/images/image-20241022095311658.png) - -我是将用户相关请求使用SpringSecurity进行拦截,如果有相关匹配路径那么就会被拦截,此时接口参数中会带有token内容,拿到token进行解析,之后取出相关用户信息,比如用户Id、username等。 - -将这些信息拿出来后放到ThreadLocal中,存储在线程中,如果微服务中需要需要放在请求头中,因为微服务不在同一个线程中。这个操作适合单体或者是微服务中不需要请求其它微服务的方式。 - -![image-20241022095641040](./data/images/image-20241022095641040.png) - -### 不需要管理接口 - -请求是会有不需要登录就能访问的接口,也需要不要被管理的接口 - -## 验证码验证忽略 - -为了公网上的展示,如果需要获取验证码比较的麻烦,如果你的需求和我一样那么可以在这里放开这些注释 - -![image-20241022100317018](./data/images/image-20241022100317018.png) +- [前端地址](https://gitee.com/BunnyBoss/bunny-admin-web) +- [后端地址](https://gitee.com/BunnyBoss/bunny-admin-server) # 搭建后端环境 1. 需要JDK17 2. MySQL 3. Redis -4. Minion +4. Minio ## 下载JDK17 @@ -69,6 +21,38 @@ public WebSecurityCustomizer webSecurityCustomizer() { 官网:https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html +## 资料相关 + +### Docker配置 + +配置的端口号是8000根据自己需求进行更改 + +![image-20241023094711026](data/images/image-20241023094711026.png) + +部署命令 + +```bash +docker build -f Dockerfile -t bunny_auth_server:1.0.0 . && docker run -p 8000:8000 -v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -v /etc/docker/daemon.json:/etc/docker/daemon.json -v /bunny/docker_data/mysql/slave_3304/backup:/home/backup --name bunny_auth_server --restart always bunny_auth_server:1.0.0 +``` + +### 代码生成器 + +生成简单CURD后端文件和前端CURD页面使用`velocity` + +![image-20241023091904775](data/images/image-20241023091904775.png) + +### 后端相关文件 + +直接导入 + +![image-20241023091610302](data/images/image-20241023091610302.png) + +### 前端文件 + +有data.js可以生成权限相关内容,只是简单的生成 + +![image-20241023091503966](data/images/image-20241023091503966.png) + ## 搭建MySQL 使用docker,开发环境端口号为3304,生产环境为3306 @@ -174,6 +158,256 @@ docker run -d \ minio/minio server /data --console-address ":9090" ``` +# 接口说明 + +为了方便开发,这个功能已经测试过了,也是为了线上能看到效果,邮箱验证码后端验证部分已经注释 + +## 请求接口 + +请求接口都是`/admin`前缀,部分接口会被忽略,忽略接口看下面。 + +所有分页请求内容都是通过路径传参方式 + +请求时需要带有token,只要前端在请求头中添加`token:内容`即可 + +采用SpringSecurity验证 + +## 接口忽略 + +### SpringSecurity接口忽略 + +这是相关拦截请求内容,如果要访问接口必须携带token,但是有些接口是不需要token的,不需要token就配置在这里。但是放在这里后,如果用户请求的地址是被忽略的,那么也就拿不到token也就拿不到登录相关信息。 + +获取用户自身的登录请求是不需要携带用户Id,只要有token去解析即可。 + +```java +// 排出鉴定路径 +@Bean +public WebSecurityCustomizer webSecurityCustomizer() { + String[] annotations = { + "/", "/ws/**", + "/*/*/noAuth/**", "/*/noAuth/**", "/noAuth/**", + "/media.ico", "/favicon.ico", "*.html", "/webjars/**", "/v3/api-docs/**", "swagger-ui/**", + "/*/files/**", + "/error", "/*/i18n/getI18n", + }; + return web -> web.ignoring().requestMatchers(annotations) + .requestMatchers(RegexRequestMatcher.regexMatcher(".*\\.(css|js)$")); +} +``` + +![image-20241022095731221](./data/images/image-20241022095731221.png) + +有些会被忽略的接口,凡是带有`noAuth`都是不需要验证的,但是要注意一点,不需要验证但是后端需要拿到登录相关信息是拿不到的。 + +![image-20241022095311658](./data/images/image-20241022095311658.png) + +我是将用户相关请求使用SpringSecurity进行拦截,如果有相关匹配路径那么就会被拦截,此时接口参数中会带有token内容,拿到token进行解析,之后取出相关用户信息,比如用户Id、username等。 + +将这些信息拿出来后放到ThreadLocal中,存储在线程中,如果微服务中需要需要放在请求头中,因为微服务不在同一个线程中。这个操作适合单体或者是微服务中不需要请求其它微服务的方式。 + +![image-20241022095641040](./data/images/image-20241022095641040.png) + +### 不需要管理接口 + +请求是会有不需要登录就能访问的接口,也需要不要被管理的接口 + +## 验证码验证忽略 + +为了公网上的展示,如果需要获取验证码比较的麻烦,如果你的需求和我一样那么可以在这里放开这些注释 + +![image-20241022100317018](./data/images/image-20241022100317018.png) + +# 功能介绍 + +系统使用的是物理删除,但是引用了逻辑删除,使用mybatisPlus如果需要逻辑删除只需要将原先删除方法调用成mybatisplus自身的删除方法即可。 + +作为权限管理系统,校验功能已经路由功能都是由后端完成,后端使用SpringSecurity + +系统权限功能使用RBAC模型 + +## 系统设置 + +### 系统菜单 + +当用户登录时会根据,当前角色获取自身的菜单路由,防止返回不该返回的页面,之后权限和角色关联,根据用户权限查询可以访问的菜单内容,如果权限中没有这个路径那么会告知`无权访问`。 + +管理员需要在配置时,配置菜单和角色之间的关系,用户也要和角色关联,角色会关联权限表,返回路由时只返回当前用户可以访问的菜单。 + +- 前端做递归,排序后端也做了 +- 快捷排序,快捷禁用菜单 +- 路由菜单图标需要再系统配置中添加菜单图标 + +![image-20241023090359575](data/images/image-20241023090359575.png) + +为菜单分配角色 + +![image-20241023090640516](data/images/image-20241023090640516.png) + +### 用户管理 + +强制下线就是将Redis中用户信息删除 + +用户禁用先改数据库之后将Redis中数据进行删除 + +![image-20241023091239212](data/images/image-20241023091239212.png) + +#### 关于用户管理事务问题 + +如果用户禁用失败或者删除Redis失败需要回滚事务,在Spring中,有集成的事务,只需要简单的配置下即可, + +### 角色管理 + +![image-20241023091310533](data/images/image-20241023091310533.png) + +### 权限管理 + +权限管理可以设置父级内容,在前端文件中有`data.js`,可以自动生成权限相关内容。 + +![image-20241023091328271](data/images/image-20241023091328271.png) + +**前端文件** + +![image-20241023091503966](data/images/image-20241023091503966.png) + +### 部门管理 + +![image-20241023092027273](data/images/image-20241023092027273.png) + +## 系统配置 + +### 菜单图标 + +![image-20241023092123926](data/images/image-20241023092123926.png) + +### 邮件用户配置 + +发送邮件时,如果没有选定用户会去找默认用户,如果默认用户也没有会报错。 + +![image-20241023092145274](data/images/image-20241023092145274.png) + +### 邮件模板 + +邮箱验证码, + +![image-20241023092250382](data/images/image-20241023092250382.png) + +#### 模板类型说明 + +根据后端的枚举类进行返回 + +![image-20241023092355799](data/images/image-20241023092355799.png) + +后端文件 + +![image-20241023092439168](data/images/image-20241023092439168.png) + +## 系统监控 + +### 服务监控 + +服务监控来自springboot中actuator框架 + +![image-20241023092520931](data/images/image-20241023092520931.png) + +IDEA中也有集成只要使用了actuator包即可看到服务内容、健康检查等 + +详细参考官网API,当然如果需要后台服监控页面,德国工程师帮我们写了一个页面。 + +![image-20241023092652996](data/images/image-20241023092652996.png) + +也可以看到当前的请求API有哪些 + +![image-20241023093159928](data/images/image-20241023093159928.png) + +#### 相关admin服务包 + +或许在有些服务中不需要这个页面,有服务监控的功能,配置也简单,我之前我使用在这个项目中,和部分业务功能有些冲突,与其这样不如自己写个简单的也可以 + +```xml + + + + de.codecentric + spring-boot-admin-starter-server + 3.3.4 + + + de.codecentric + spring-boot-admin-starter-client + 3.2.3 + + +``` + +### 后台文件管理 + +用户上传的文件和头像内容都在这里,文件存储位置在Minio中 + +![image-20241023093247261](data/images/image-20241023093247261.png) + +### 用户登录日志 + +![image-20241023093317701](data/images/image-20241023093317701.png) + +### 任务执行日志 + +当前设定的定时任务有关,目前有数据库备份,和简单的定时任务示例内容都在这,使用JS对象可视化,数据多时会有些卡顿 + +![image-20241023093407627](data/images/image-20241023093407627.png) + +## 定时任务 + +### 调度任务 + +其实就是定时任务,集成框架quartz,持久化存储任务 + +![image-20241023093546293](data/images/image-20241023093546293.png) + +### 任务调度分组 + +![image-20241023093602223](data/images/image-20241023093602223.png) + +## 多语言管理 + +### 多语言 + +![image-20241023093639866](data/images/image-20241023093639866.png) + +### 多语言类型 + +如果以后还需要其它语言可以在这个地方添加 + +![image-20241023093654135](data/images/image-20241023093654135.png) + +## 其它功能 + +![image-20241023093729543](data/images/image-20241023093729543.png) + +### 账户设置 + +![image-20241023093749870](data/images/image-20241023093749870.png) + +![image-20241023093759347](data/images/image-20241023093759347.png) + +![image-20241023093807425](data/images/image-20241023093807425.png) + +### 数据库事务 + +数据库事务在Springboot中只需要一个注解,通常我们还需要redis事务,在Redis中配置开启即可。 + +![image-20241023094104297](data/images/image-20241023094104297.png) + +### 去除字符串空格 + +在项目中,会统一进行空白字符串去除,配置项也在config文件夹下 + +![image-20241023094247311](data/images/image-20241023094247311.png) + +> 更多配置看这里 +> +> ![image-20241023094311326](data/images/image-20241023094311326.png) + # 动态定时任务 使用`Quartz `数据存储在数据库中持久化存储. @@ -251,3 +485,10 @@ docker run -d \ 9. `usingJobData(JobDataMap jobData, boolean merge)`:添加自定义数据,并指定是否与现有的 `JobDataMap` 合并。 10. `build()`:构建并返回最终的 `JobDetail` 实例。 + +# 展望未来 + +1. 数据库备份时上传到Minio +2. 数据库备份后可恢复 +3. 定时邮件发送参数可在前端配置,动态形式 +4. 首页看板内容 \ No newline at end of file diff --git a/data/images/image-20241023090359575.png b/data/images/image-20241023090359575.png new file mode 100644 index 0000000..fd14166 Binary files /dev/null and b/data/images/image-20241023090359575.png differ diff --git a/data/images/image-20241023090640516.png b/data/images/image-20241023090640516.png new file mode 100644 index 0000000..fe73c0a Binary files /dev/null and b/data/images/image-20241023090640516.png differ diff --git a/data/images/image-20241023091239212.png b/data/images/image-20241023091239212.png new file mode 100644 index 0000000..f496c04 Binary files /dev/null and b/data/images/image-20241023091239212.png differ diff --git a/data/images/image-20241023091310533.png b/data/images/image-20241023091310533.png new file mode 100644 index 0000000..b939571 Binary files /dev/null and b/data/images/image-20241023091310533.png differ diff --git a/data/images/image-20241023091328271.png b/data/images/image-20241023091328271.png new file mode 100644 index 0000000..deeb309 Binary files /dev/null and b/data/images/image-20241023091328271.png differ diff --git a/data/images/image-20241023091503966.png b/data/images/image-20241023091503966.png new file mode 100644 index 0000000..f316544 Binary files /dev/null and b/data/images/image-20241023091503966.png differ diff --git a/data/images/image-20241023091610302.png b/data/images/image-20241023091610302.png new file mode 100644 index 0000000..9986c4e Binary files /dev/null and b/data/images/image-20241023091610302.png differ diff --git a/data/images/image-20241023091904775.png b/data/images/image-20241023091904775.png new file mode 100644 index 0000000..e859dc4 Binary files /dev/null and b/data/images/image-20241023091904775.png differ diff --git a/data/images/image-20241023092027273.png b/data/images/image-20241023092027273.png new file mode 100644 index 0000000..c49d9c3 Binary files /dev/null and b/data/images/image-20241023092027273.png differ diff --git a/data/images/image-20241023092123926.png b/data/images/image-20241023092123926.png new file mode 100644 index 0000000..3716761 Binary files /dev/null and b/data/images/image-20241023092123926.png differ diff --git a/data/images/image-20241023092145274.png b/data/images/image-20241023092145274.png new file mode 100644 index 0000000..ef659d7 Binary files /dev/null and b/data/images/image-20241023092145274.png differ diff --git a/data/images/image-20241023092250382.png b/data/images/image-20241023092250382.png new file mode 100644 index 0000000..a4862ce Binary files /dev/null and b/data/images/image-20241023092250382.png differ diff --git a/data/images/image-20241023092355799.png b/data/images/image-20241023092355799.png new file mode 100644 index 0000000..069bc3f Binary files /dev/null and b/data/images/image-20241023092355799.png differ diff --git a/data/images/image-20241023092439168.png b/data/images/image-20241023092439168.png new file mode 100644 index 0000000..fda75ff Binary files /dev/null and b/data/images/image-20241023092439168.png differ diff --git a/data/images/image-20241023092520931.png b/data/images/image-20241023092520931.png new file mode 100644 index 0000000..11fd9ef Binary files /dev/null and b/data/images/image-20241023092520931.png differ diff --git a/data/images/image-20241023092652996.png b/data/images/image-20241023092652996.png new file mode 100644 index 0000000..23c1a79 Binary files /dev/null and b/data/images/image-20241023092652996.png differ diff --git a/data/images/image-20241023093159928.png b/data/images/image-20241023093159928.png new file mode 100644 index 0000000..28c25c7 Binary files /dev/null and b/data/images/image-20241023093159928.png differ diff --git a/data/images/image-20241023093247261.png b/data/images/image-20241023093247261.png new file mode 100644 index 0000000..3fd2936 Binary files /dev/null and b/data/images/image-20241023093247261.png differ diff --git a/data/images/image-20241023093317701.png b/data/images/image-20241023093317701.png new file mode 100644 index 0000000..dfadc3f Binary files /dev/null and b/data/images/image-20241023093317701.png differ diff --git a/data/images/image-20241023093407627.png b/data/images/image-20241023093407627.png new file mode 100644 index 0000000..db6731b Binary files /dev/null and b/data/images/image-20241023093407627.png differ diff --git a/data/images/image-20241023093546293.png b/data/images/image-20241023093546293.png new file mode 100644 index 0000000..ef2c082 Binary files /dev/null and b/data/images/image-20241023093546293.png differ diff --git a/data/images/image-20241023093602223.png b/data/images/image-20241023093602223.png new file mode 100644 index 0000000..452da79 Binary files /dev/null and b/data/images/image-20241023093602223.png differ diff --git a/data/images/image-20241023093639866.png b/data/images/image-20241023093639866.png new file mode 100644 index 0000000..90ee5b5 Binary files /dev/null and b/data/images/image-20241023093639866.png differ diff --git a/data/images/image-20241023093654135.png b/data/images/image-20241023093654135.png new file mode 100644 index 0000000..46b1710 Binary files /dev/null and b/data/images/image-20241023093654135.png differ diff --git a/data/images/image-20241023093729543.png b/data/images/image-20241023093729543.png new file mode 100644 index 0000000..f0e0bc1 Binary files /dev/null and b/data/images/image-20241023093729543.png differ diff --git a/data/images/image-20241023093749870.png b/data/images/image-20241023093749870.png new file mode 100644 index 0000000..11df91d Binary files /dev/null and b/data/images/image-20241023093749870.png differ diff --git a/data/images/image-20241023093759347.png b/data/images/image-20241023093759347.png new file mode 100644 index 0000000..4d76a4a Binary files /dev/null and b/data/images/image-20241023093759347.png differ diff --git a/data/images/image-20241023093807425.png b/data/images/image-20241023093807425.png new file mode 100644 index 0000000..5b14f9c Binary files /dev/null and b/data/images/image-20241023093807425.png differ diff --git a/data/images/image-20241023094104297.png b/data/images/image-20241023094104297.png new file mode 100644 index 0000000..582c6c5 Binary files /dev/null and b/data/images/image-20241023094104297.png differ diff --git a/data/images/image-20241023094247311.png b/data/images/image-20241023094247311.png new file mode 100644 index 0000000..582c6c5 Binary files /dev/null and b/data/images/image-20241023094247311.png differ diff --git a/data/images/image-20241023094311326.png b/data/images/image-20241023094311326.png new file mode 100644 index 0000000..81c4074 Binary files /dev/null and b/data/images/image-20241023094311326.png differ diff --git a/data/images/image-20241023094711026.png b/data/images/image-20241023094711026.png new file mode 100644 index 0000000..1ddf6ab Binary files /dev/null and b/data/images/image-20241023094711026.png differ