From d6218655285d4cd3db633a5dc3287f4035bcbfa2 Mon Sep 17 00:00:00 2001
From: bunny <1319900154@qq.com>
Date: Thu, 16 May 2024 08:35:15 +0800
Subject: [PATCH 1/3] =?UTF-8?q?feat(=E4=BF=AE=E6=94=B9):=20:lipstick:=20?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A1=B9=E7=9B=AE=E6=A8=A1=E5=9D=97=E5=92=8C?=
=?UTF-8?q?=E4=BE=9D=E8=B5=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 1 +
common/common-result/pom.xml | 7 +-
.../common/result/enums/ResultCodeEnum.java | 5 +-
common/common-utils/pom.xml | 71 ------------
.../constant/CommonMessageConstant.java | 38 -------
.../common/constant/ExceptionConstant.java | 16 ---
.../constant/LocalDateTimeConstant.java | 11 --
.../common/constant/MailMessageConstant.java | 14 ---
.../common/constant/MinioMessageConstant.java | 19 ----
.../common/constant/PasswordConstant.java | 18 ---
.../common/constant/RedisUserConstant.java | 11 --
.../common/constant/SQLAutoFillConstant.java | 14 ---
.../common/constant/SecurityConstant.java | 12 --
.../bunny/common/constant/StatusConstant.java | 14 ---
.../bunny/common/constant/UserConstant.java | 8 --
.../cn/bunny/common/generator/NewCodeGet.java | 84 --------------
.../cn/bunny/common/generator/OldCodeGet.java | 57 ----------
.../properties/SnowflakeProperties.java | 25 ----
common/pom.xml | 9 +-
common/service-utils/pom.xml | 7 +-
.../common/service/config/Knife4jConfig.java | 6 +
.../exception/GlobalExceptionHandler.java | 4 +-
.../bunny/common/service/utils/JwtHelper.java | 13 +--
.../common/service/utils/ResponseUtil.java | 11 +-
.../service/utils/SnowflakeIdGenerator.java | 2 +-
.../security/config/WebSecurityConfig.java | 85 --------------
.../custom/CustomPasswordEncoder.java | 28 -----
.../cn/bunny/security/custom/CustomUser.java | 23 ----
.../filter/TokenAuthenticationFilter.java | 74 ------------
.../security/filter/TokenLoginFilter.java | 80 -------------
.../handelr/SecurityAccessDeniedHandler.java | 23 ----
.../SecurityAuthenticationEntryPoint.java | 39 -------
.../SecurityAuthenticationFailureHandler.java | 26 -----
.../SecurityAuthenticationSuccessHandler.java | 29 -----
.../CustomAuthorizationManagerService.java | 7 --
.../service/CustomUserDetailsService.java | 12 --
.../service-gateway-metrics.log.2024-05-10 | 3 -
...service-gateway-metrics.log.2024-05-10.idx | 0
model/pom.xml | 17 ++-
.../java/cn/bunny/entity/system/Login.java | 14 ---
.../cn/bunny/entity/system/RoleByUser.java | 17 ---
.../java/cn/bunny/entity/system/SysDept.java | 49 --------
.../cn/bunny/entity/system/SysLoginLog.java | 42 -------
.../java/cn/bunny/entity/system/SysMenu.java | 65 -----------
.../java/cn/bunny/entity/system/SysRole.java | 34 ------
.../java/cn/bunny/entity/system/SysUser.java | 71 ------------
.../cn/bunny/entity/system/SysUserinfo.java | 22 ----
.../main/java/cn/bunny/vo/system/LoginVo.java | 32 ++++--
.../main/java/cn/bunny/vo/system/MetaVo.java | 29 -----
.../java/cn/bunny/vo/system/RouterVo.java | 48 --------
.../cn/bunny/vo/system/SysOperLogQueryVo.java | 15 ---
.../cn/bunny/vo/system/SysPostQueryVo.java | 19 ----
.../module/mail/utils/MailSendCheckUtil.java | 2 +-
.../bunny/module/minio/utils/MinioUtil.java | 2 +-
module/module-rabbitMQ/pom.xml | 1 -
.../module-websocket}/pom.xml | 12 +-
.../module}/websocket/WebSocketServer.java | 2 +-
pom.xml | 66 ++++++++++-
server-gateway/pom.xml | 13 ++-
.../service/gateway/GatewayApplication.java | 2 +
.../gateway/controller/IndexController.java | 2 +-
.../src/main/resources/application-dev.yml | 2 +-
.../src/main/resources/application.yml | 24 ++--
.../src/test/java/cn/bunny/AppTest.java | 38 -------
service-client/pom.xml | 22 +++-
service/pom.xml | 8 +-
service/service-main/Dockerfile | 21 ----
service/service-main/pom.xml | 107 ------------------
.../cn/bunny/service/ServiceApplication.java | 22 ----
.../service/aop/annotation/AutoFill.java | 15 ---
.../service/aop/aspect/AutoFillAspect.java | 27 -----
.../service/controller/BaseController.java | 59 ----------
.../service/controller/IndexController.java | 47 --------
.../service/controller/MailController.java | 55 ---------
.../service/controller/SysMenuController.java | 18 ---
.../bunny/service/mapper/SysMenuMapper.java | 16 ---
.../bunny/service/mapper/SysRoleMapper.java | 7 --
.../bunny/service/mapper/SysUserMapper.java | 19 ----
...CustomAuthorizationManagerServiceImpl.java | 36 ------
.../security/CustomUserDetailsService.java | 41 -------
.../bunny/service/service/EmailService.java | 37 ------
.../bunny/service/service/SysMenuService.java | 16 ---
.../bunny/service/service/SysRoleService.java | 8 --
.../bunny/service/service/SysUserService.java | 43 -------
.../service/impl/EmailServiceImpl.java | 98 ----------------
.../service/impl/SysMenuServiceImpl.java | 20 ----
.../service/impl/SysRoleServiceImpl.java | 11 --
.../service/impl/SysUserServiceImpl.java | 91 ---------------
.../cn/bunny/service/task/TemplateTask.java | 14 ---
.../src/main/resources/application-dev.yml | 19 ----
.../src/main/resources/application.yml | 63 -----------
.../src/main/resources/banner.txt | 16 ---
.../src/main/resources/favicon.ico | Bin 17014 -> 0 bytes
.../src/main/resources/logback.xml | 61 ----------
.../main/resources/mapper/SysMenuMapper.xml | 26 -----
.../main/resources/mapper/SysRoleMapper.xml | 5 -
.../main/resources/mapper/SysUserMapper.xml | 5 -
.../cn/bunny/CustomPasswordEncoderTest.java | 27 -----
98 files changed, 193 insertions(+), 2433 deletions(-)
delete mode 100644 common/common-utils/pom.xml
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/constant/CommonMessageConstant.java
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/constant/ExceptionConstant.java
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/constant/LocalDateTimeConstant.java
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/constant/MailMessageConstant.java
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/constant/MinioMessageConstant.java
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/constant/PasswordConstant.java
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/constant/RedisUserConstant.java
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/constant/SQLAutoFillConstant.java
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/constant/SecurityConstant.java
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/constant/StatusConstant.java
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/constant/UserConstant.java
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/generator/NewCodeGet.java
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/generator/OldCodeGet.java
delete mode 100644 common/common-utils/src/main/java/cn/bunny/common/properties/SnowflakeProperties.java
delete mode 100644 common/spring-security/src/main/java/cn/bunny/security/config/WebSecurityConfig.java
delete mode 100644 common/spring-security/src/main/java/cn/bunny/security/custom/CustomPasswordEncoder.java
delete mode 100644 common/spring-security/src/main/java/cn/bunny/security/custom/CustomUser.java
delete mode 100644 common/spring-security/src/main/java/cn/bunny/security/filter/TokenAuthenticationFilter.java
delete mode 100644 common/spring-security/src/main/java/cn/bunny/security/filter/TokenLoginFilter.java
delete mode 100644 common/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAccessDeniedHandler.java
delete mode 100644 common/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationEntryPoint.java
delete mode 100644 common/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationFailureHandler.java
delete mode 100644 common/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationSuccessHandler.java
delete mode 100644 common/spring-security/src/main/java/cn/bunny/security/service/CustomAuthorizationManagerService.java
delete mode 100644 common/spring-security/src/main/java/cn/bunny/security/service/CustomUserDetailsService.java
delete mode 100644 logs/service-gateway/sentinel/service-gateway-metrics.log.2024-05-10
delete mode 100644 logs/service-gateway/sentinel/service-gateway-metrics.log.2024-05-10.idx
delete mode 100644 model/src/main/java/cn/bunny/entity/system/Login.java
delete mode 100644 model/src/main/java/cn/bunny/entity/system/RoleByUser.java
delete mode 100644 model/src/main/java/cn/bunny/entity/system/SysDept.java
delete mode 100644 model/src/main/java/cn/bunny/entity/system/SysLoginLog.java
delete mode 100644 model/src/main/java/cn/bunny/entity/system/SysMenu.java
delete mode 100644 model/src/main/java/cn/bunny/entity/system/SysRole.java
delete mode 100644 model/src/main/java/cn/bunny/entity/system/SysUser.java
delete mode 100644 model/src/main/java/cn/bunny/entity/system/SysUserinfo.java
delete mode 100644 model/src/main/java/cn/bunny/vo/system/MetaVo.java
delete mode 100644 model/src/main/java/cn/bunny/vo/system/RouterVo.java
delete mode 100644 model/src/main/java/cn/bunny/vo/system/SysOperLogQueryVo.java
delete mode 100644 model/src/main/java/cn/bunny/vo/system/SysPostQueryVo.java
rename {common/spring-security => module/module-websocket}/pom.xml (70%)
rename {service/service-main/src/main/java/cn/bunny/service => module/module-websocket/src/main/java/cn/bunny/module}/websocket/WebSocketServer.java (98%)
delete mode 100644 server-gateway/src/test/java/cn/bunny/AppTest.java
delete mode 100644 service/service-main/Dockerfile
delete mode 100644 service/service-main/pom.xml
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/ServiceApplication.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/aop/annotation/AutoFill.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/aop/aspect/AutoFillAspect.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/controller/BaseController.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/controller/IndexController.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/controller/MailController.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/controller/SysMenuController.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/mapper/SysMenuMapper.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/mapper/SysRoleMapper.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/mapper/SysUserMapper.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/security/CustomAuthorizationManagerServiceImpl.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/security/CustomUserDetailsService.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/service/EmailService.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/service/SysMenuService.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/service/SysRoleService.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/service/SysUserService.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/service/impl/EmailServiceImpl.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/service/impl/SysMenuServiceImpl.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/service/impl/SysRoleServiceImpl.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/service/impl/SysUserServiceImpl.java
delete mode 100644 service/service-main/src/main/java/cn/bunny/service/task/TemplateTask.java
delete mode 100644 service/service-main/src/main/resources/application-dev.yml
delete mode 100644 service/service-main/src/main/resources/application.yml
delete mode 100644 service/service-main/src/main/resources/banner.txt
delete mode 100644 service/service-main/src/main/resources/favicon.ico
delete mode 100644 service/service-main/src/main/resources/logback.xml
delete mode 100644 service/service-main/src/main/resources/mapper/SysMenuMapper.xml
delete mode 100644 service/service-main/src/main/resources/mapper/SysRoleMapper.xml
delete mode 100644 service/service-main/src/main/resources/mapper/SysUserMapper.xml
delete mode 100644 service/service-main/src/test/java/cn/bunny/CustomPasswordEncoderTest.java
diff --git a/.gitignore b/.gitignore
index 549e00a..a23d6d0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,4 @@ build/
### VS Code ###
.vscode/
+logs
\ No newline at end of file
diff --git a/common/common-result/pom.xml b/common/common-result/pom.xml
index 436690b..b1d9bc0 100644
--- a/common/common-result/pom.xml
+++ b/common/common-result/pom.xml
@@ -1,4 +1,4 @@
-
4.0.0
@@ -18,6 +18,9 @@
-
+
+ org.projectlombok
+ lombok
+
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/enums/ResultCodeEnum.java b/common/common-result/src/main/java/cn/bunny/common/result/enums/ResultCodeEnum.java
index dc0c7c7..68402cc 100644
--- a/common/common-result/src/main/java/cn/bunny/common/result/enums/ResultCodeEnum.java
+++ b/common/common-result/src/main/java/cn/bunny/common/result/enums/ResultCodeEnum.java
@@ -10,9 +10,11 @@ public enum ResultCodeEnum {
SUCCESS(200, "操作成功"),
SUCCESS_LOGOUT(200, "退出成功"),
FAIL(201, "失败"),
+ USERNAME_NOT_EMPTY(201, "用户名不能为空"),
+ PASSWORD_NOT_EMPTY(201, "密码不能为空"),
SERVICE_ERROR(2012, "服务异常"),
DATA_ERROR(204, "数据异常"),
- LOGIN_MOBLE_ERROR(204, "登录错误"),
+ LOGIN_ERROR(204, "账号或密码错误"),
ILLEGAL_REQUEST(205, "非法请求"),
REPEAT_SUBMIT(206, "重复提交"),
@@ -24,7 +26,6 @@ public enum ResultCodeEnum {
FETCH_ACCESSTOKEN_FAILD(218, "获取accessToken失败"),
FETCH_USERINFO_ERROR(219, "获取用户信息失败"),
-
FAIL_REQUEST_NOT_AUTH(403, "用户未认证"),
FAIL_NO_ACCESS_DENIED(403, "无权访问"),
LOGGED_IN_FROM_ANOTHER_DEVICE(403, "没有权限访问"),
diff --git a/common/common-utils/pom.xml b/common/common-utils/pom.xml
deleted file mode 100644
index 8a8ecaf..0000000
--- a/common/common-utils/pom.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-
- 4.0.0
-
- cn.bunny
- common
- 0.0.1-SNAPSHOT
-
-
- common-utils
- jar
-
- common-utils
- https://maven.apache.org
-
-
- UTF-8
-
-
-
-
- org.apache.httpcomponents
- httpclient
- 4.5.14
-
-
- javax.xml.bind
- jaxb-api
- 2.1
-
-
-
- mysql
- mysql-connector-java
-
-
-
- com.zaxxer
- HikariCP
- 5.1.0
-
-
-
- com.baomidou
- mybatis-plus-spring-boot3-starter
-
-
-
- com.baomidou
- mybatis-plus-generator
- 3.5.6
-
-
- org.apache.velocity
- velocity-engine-core
- 2.3
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/common/common-utils/src/main/java/cn/bunny/common/constant/CommonMessageConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/CommonMessageConstant.java
deleted file mode 100644
index 910d164..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/constant/CommonMessageConstant.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package cn.bunny.common.constant;
-
-import lombok.Data;
-
-/**
- * 信息提示常量类
- */
-@Data
-public class CommonMessageConstant {
- public static final String PASSWORD_ERROR = "密码错误";
- public static final String OLD_PASSWORD_ERROR = "旧密码不匹配";
- public static final String OLD_PASSWORD_SAME_NEW_PASSWORD = "旧密码与新密码相同";
- public static final String ACCOUNT_NOT_FOUND = "账号不存在";
- public static final String ACCOUNT_LOCKED = "账号被锁定";
- public static final String UNKNOWN_ERROR = "未知错误";
- public static final String USER_NOT_LOGIN = "用户未登录";
- public static final String USER_TOKEN_OUT_OF_DATE = "用户登录过期";
- public static final String LOGIN_FAILED = "登录失败";
- public static final String UPLOAD_FAILED = "文件上传失败";
- public static final String PASSWORD_EDIT_FAILED = "密码修改失败";
- public static final String ALREADY_EXISTS = "已存在";
- public static final String REQUEST_NOT_EMPTY = "请求不为空";
- public static final String UPDATE_ID_IS_NOT_EMPTY = "删除id不能为空";
- public static final String DELETE_ID_IS_NOT_EMPTY = "修改id不能为空";
- public static final String MENU_IS_NOT_EXIST = "菜单不存在";
- public static final String SAVE_DTO_IS_NULL = "添加参数不能为空";
- public static final String UPDATE_DTO_IS_NULL = "修改参数不能为空";
- public static final String FIND_ID_IS_NOT_EMPTY = "查询ID不能为空";
- public static final String MESSAGE_CODE_NOT_PASS = "短信验证码未过期";
- public static final String MESSAGE_CODE_UNAUTHORIZED = "短信验证码未授权,请联系管理员";
- public static final String VERIFICATION_CODE_ERROR = "验证码错误";
- public static final String USER_DOES_NOT_EXIST = "用户不存在";
- public static final String USER_DOES_IS_EXIST = "用户已存在";
- public static final String VERIFICATION_CODE_IS_EMPTY = "请先发送验证码";
- public static final String LOGIN_DTO_IS_EMPTY = "登录参数不能为空";
- public static final String TOKEN_IS_EMPTY = "token为空";
- public static final String DATA_IS_EMPTY = "数据为空";
-}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/constant/ExceptionConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/ExceptionConstant.java
deleted file mode 100644
index 64e0094..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/constant/ExceptionConstant.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package cn.bunny.common.constant;
-
-
-import lombok.Data;
-
-@Data
-public class ExceptionConstant {
- public static final String USER_NOT_FOUND = "用户不存在";
- public static final String USERNAME_IS_EMPTY = "用户名不能为空";
- public static final String PASSWORD_ERROR = "密码错误";
- public static final String PASSWORD_IS_EMPTY = "密码不能为空";
- public static final String CAPTCHA_IS_EMPTY = "提交验证码不能为空";
- public static final String KEY_IS_EMPTY = "验证码key不能为空";
- public static final String VERIFICATION_CODE_DOES_NOT_MATCH = "验证码不匹配";
- public static final String VERIFICATION_CODE_IS_EMPTY = "验证码失效或不存在";
-}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/constant/LocalDateTimeConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/LocalDateTimeConstant.java
deleted file mode 100644
index 1494b3c..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/constant/LocalDateTimeConstant.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package cn.bunny.common.constant;
-
-import lombok.Data;
-
-@Data
-public class LocalDateTimeConstant {
- public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
- public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm";
- public static final String DEFAULT_DATE_TIME_SECOND_FORMAT = "yyyy-MM-dd HH:mm:ss";
- public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";
-}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/constant/MailMessageConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/MailMessageConstant.java
deleted file mode 100644
index 458ef48..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/constant/MailMessageConstant.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package cn.bunny.common.constant;
-
-import lombok.Data;
-
-/**
- * 邮箱消息
- */
-@Data
-public class MailMessageConstant {
- public static final String EMPTY_SEND_OBJECT = "空发送对象";
- public static final String ADDRESS_NOT_NULL = "收件人不能为空";
- public static final String TITLE_NOT_NULL = "标题不能为空";
- public static final String SEND_MESSAGE_NOT_NULL = "发送消息不能为空";
-}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/constant/MinioMessageConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/MinioMessageConstant.java
deleted file mode 100644
index b36a35e..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/constant/MinioMessageConstant.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package cn.bunny.common.constant;
-
-import lombok.Data;
-
-@Data
-public class MinioMessageConstant {
- public static final String BUCKET_EXISTS_EXCEPTION = "查询文化部对象失败";
- public static final String DELETE_BUCKET_EXCEPTION = "删除文件对象失败";
- public static final String GET_BUCKET_EXCEPTION = "获取文件信息失败";
- public static final String QUERY_BUCKET_EXCEPTION = "查询文件信息失败";
- public static final String CREATE_BUCKET_EXCEPTION = "创建文件对象失败";
- public static final String UPDATE_BUCKET_EXCEPTION = "更新文件对象失败";
- public static final String COMPOSE_OBJECT_EXCEPTION = "对象错误";
- public static final String COPY_BUCKET_EXCEPTION = "复制文件内容失败";
- public static final String DISABLE_BUCKET_EXCEPTION = "禁用文件失败";
- public static final String ENABLE_BUCKET_EXCEPTION = "启用文件失败";
- public static final String DOWNLOAD_BUCKET_EXCEPTION = "下载文件失败";
- public static final String UPLOAD_BUCKET_EXCEPTION = "上传文件失败";
-}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/constant/PasswordConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/PasswordConstant.java
deleted file mode 100644
index 0633ea0..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/constant/PasswordConstant.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package cn.bunny.common.constant;
-
-import lombok.Data;
-
-/**
- * 密码常量
- */
-@Data
-public class PasswordConstant {
- // 默认密码
- public static final String DEFAULT_PASSWORD = "123456";
- // JWT密码
- public static final String DEFAULT_JWT_PASSWORD = "123456";
- // 默认头像
- public static final String AVTAR = "https://oss.aliyuncs.com/aliyun_id_photo_bucket/default_handsome.jpg";
- // 设置token过期时间
- public static final long TOKEN_EXPIRATION = 365L * 24 * 60 * 60 * 1000;
-}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/constant/RedisUserConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/RedisUserConstant.java
deleted file mode 100644
index ca4b151..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/constant/RedisUserConstant.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package cn.bunny.common.constant;
-
-import lombok.Data;
-
-/**
- * Redis用户前缀设置
- */
-@Data
-public class RedisUserConstant {
- public static final String REDIS_CART_KEY = "user::";
-}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/constant/SQLAutoFillConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/SQLAutoFillConstant.java
deleted file mode 100644
index b9b6205..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/constant/SQLAutoFillConstant.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package cn.bunny.common.constant;
-
-import lombok.Data;
-
-/**
- * 数据库中自动填充字段
- */
-@Data
-public class SQLAutoFillConstant {
- public static final String SET_CREATE_TIME = "setCreateTime";
- public static final String SET_UPDATE_TIME = "setUpdateTime";
- public static final String SET_CREATE_USER = "setCreateUser";
- public static final String SET_UPDATE_USER = "setUpdateUser";
-}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/constant/SecurityConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/SecurityConstant.java
deleted file mode 100644
index da71e65..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/constant/SecurityConstant.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package cn.bunny.common.constant;
-
-import lombok.Data;
-
-import java.util.Arrays;
-import java.util.List;
-
-@Data
-public class SecurityConstant {
- public static String[] annotations = {"/", "/test/**", "/diagram-viewer/**", "/editor-app/**", "/*.html", "/admin/system/index/login", "/favicon.ico", "/swagger-resources/**", "/webjars/**", "/v3/**", "/swagger-ui.html/**", "/doc.html"};
- public static List annotationsList = Arrays.asList(annotations);
-}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/constant/StatusConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/StatusConstant.java
deleted file mode 100644
index d91412f..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/constant/StatusConstant.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package cn.bunny.common.constant;
-
-import lombok.Data;
-
-/**
- * 状态常量,启用或者禁用
- */
-@Data
-public class StatusConstant {
- // 启用为1
- public static final Integer ENABLE = 1;
- // 禁用为0
- public static final Integer DISABLE = 0;
-}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/constant/UserConstant.java b/common/common-utils/src/main/java/cn/bunny/common/constant/UserConstant.java
deleted file mode 100644
index 8d2ee23..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/constant/UserConstant.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package cn.bunny.common.constant;
-
-import lombok.Data;
-
-@Data
-public class UserConstant {
- public static final String USER_AVATAR = "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eoj0hHXhgJNOTSOFsS4uZs8x1ConecaVOB8eIl115xmJZcT4oCicvia7wMEufibKtTLqiaJeanU2Lpg3w/132";
-}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/generator/NewCodeGet.java b/common/common-utils/src/main/java/cn/bunny/common/generator/NewCodeGet.java
deleted file mode 100644
index fb3fb5d..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/generator/NewCodeGet.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package cn.bunny.common.generator;
-
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.generator.FastAutoGenerator;
-import com.baomidou.mybatisplus.generator.config.OutputFile;
-import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
-import org.apache.ibatis.annotations.Mapper;
-
-import java.util.Collections;
-
-public class NewCodeGet {
- // 数据连接
- public static final String sqlHost = "jdbc:mysql://106.15.251.123:3305/guigu-oa?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true";
- // 作者名称
- public static final String author = "Bunny";
- // 公共路径
- public static final String outputDir = "G:\\web项目\\Bunny-Cli\\Java\\java-template\\service";
- // 实体类名称
- public static final String entity = "Bunny";
-
- public static void main(String[] args) {
- Generation("sys_menu");
- }
-
- /**
- * 根据表名生成相应结构代码
- *
- * @param tableName 表名
- */
- public static void Generation(String... tableName) {
- // TODO 修改数据库路径、账户、密码
- FastAutoGenerator.create(sqlHost, "root", "02120212")
- .globalConfig(builder -> {
- // 添加作者名称
- builder.author(author)
- // 启用swagger
- .enableSwagger()
- // 指定输出目录
- .outputDir(outputDir + "/src/main/java");
- })
- .packageConfig(builder -> {
- builder.entity(entity)// 实体类包名
- // TODO 父包名。如果为空,将下面子包名必须写全部, 否则就只需写子包名
- .parent("cn.bunny.service")
- .controller("controller")// 控制层包名
- .mapper("mapper")// mapper层包名
- .service("service")// service层包名
- .serviceImpl("service.impl")// service实现类包名
- // 自定义mapper.xml文件输出目录
- .pathInfo(Collections.singletonMap(OutputFile.xml, outputDir + "/src/main/resources/mapper"));
- })
- .strategyConfig(builder -> {
- // 设置要生成的表名
- builder.addInclude(tableName)
- //.addTablePrefix("sys_")// TODO 设置表前缀过滤
- .entityBuilder()
- .enableLombok()
- .enableChainModel()
- .naming(NamingStrategy.underline_to_camel)// 数据表映射实体命名策略:默认下划线转驼峰underline_to_camel
- .columnNaming(NamingStrategy.underline_to_camel)// 表字段映射实体属性命名规则:默认null,不指定按照naming执行
- .idType(IdType.AUTO)// TODO 添加全局主键类型
- .formatFileName("%s")// 格式化实体名称,%s取消首字母I,
- .mapperBuilder()
- .mapperAnnotation(Mapper.class)// 开启mapper注解
- .enableBaseResultMap()// 启用xml文件中的BaseResultMap 生成
- .enableBaseColumnList()// 启用xml文件中的BaseColumnList
- .formatMapperFileName("%sMapper")// 格式化Dao类名称
- .formatXmlFileName("%sMapper")// 格式化xml文件名称
- .serviceBuilder()
- .formatServiceFileName("%sService")// 格式化 service 接口文件名称
- .formatServiceImplFileName("%sServiceImpl")// 格式化 service 接口文件名称
- .controllerBuilder()
- .enableRestStyle();
- })
- // .injectionConfig(consumer -> {
- // Map customFile = new HashMap<>();
- // // 配置DTO(需要的话)但是需要有能配置Dto的模板引擎,比如freemarker,但是这里我们用的VelocityEngine,因此不多作介绍
- // customFile.put(outputDir, "/src/main/resources/templates/entityDTO.java.ftl");
- // consumer.customFile(customFile);
- // })
- .execute();
- }
-}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/generator/OldCodeGet.java b/common/common-utils/src/main/java/cn/bunny/common/generator/OldCodeGet.java
deleted file mode 100644
index d43819c..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/generator/OldCodeGet.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package cn.bunny.common.generator;
-
-public class OldCodeGet {
- public static void main(String[] args) {
- // // 1、创建代码生成器
- // AutoGenerator mpg = new AutoGenerator();
- //
- // // 2、全局配置
- // // 全局配置
- // GlobalConfig gc = new GlobalConfig();
- // // TODO 需要修改路径名称
- // gc.setOutputDir("F:\\web项目\\Bunny-Cli\\Java\\java-template\\service" + "/src/main/java");
- // gc.setServiceName("%sService"); // 去掉Service接口的首字母I
- // gc.setAuthor("bunny");
- // gc.setOpen(false);
- // mpg.setGlobalConfig(gc);
- //
- // // 3、数据源配置
- // DataSourceConfig dsc = new DataSourceConfig();
- // // TODO 需要修改数据库
- // dsc.setUrl("jdbc:mysql://106.15.251.123:3305/guigu-oa?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true");
- // dsc.setDriverName("com.mysql.cj.jdbc.Driver");
- // dsc.setUsername("root");
- // dsc.setPassword("02120212");
- // dsc.setDbType(DbType.MYSQL);
- // mpg.setDataSource(dsc);
- //
- // // 4、包配置
- // PackageConfig pc = new PackageConfig();
- // pc.setParent("cn.bunny");
- // // TODO 需要修改模块名
- // pc.setModuleName("service");
- // pc.setController("controller");
- // pc.setService("service");
- // pc.setMapper("mapper");
- // mpg.setPackageInfo(pc);
- //
- // // 5、策略配置
- // StrategyConfig strategy = getStrategyConfig();
- // mpg.setStrategy(strategy);
- //
- // // 6、执行
- // mpg.execute();
- // }
- //
- // private static StrategyConfig getStrategyConfig() {
- // StrategyConfig strategy = new StrategyConfig();
- // // TODO 要生成的表
- // strategy.setInclude("sys_menu", "sys_role_menu");
- // strategy.setNaming(NamingStrategy.underline_to_camel);// 数据库表映射到实体的命名策略
- // strategy.setColumnNaming(NamingStrategy.underline_to_camel);// 数据库表字段映射到实体的命名策略
- // strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作
- // strategy.setRestControllerStyle(true); // restful api风格控制器
- // strategy.setControllerMappingHyphenStyle(true); // url中驼峰转连字符
- // return strategy;
- }
-}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/properties/SnowflakeProperties.java b/common/common-utils/src/main/java/cn/bunny/common/properties/SnowflakeProperties.java
deleted file mode 100644
index fe073ad..0000000
--- a/common/common-utils/src/main/java/cn/bunny/common/properties/SnowflakeProperties.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package cn.bunny.common.properties;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-@Component
-@ConfigurationProperties(prefix = "bunny.snowflake")
-@Data
-public class SnowflakeProperties {
- // 数据中心id
- private Long datacenterId;
- // 数据中心id位数
- private Long datacenterBits;
- // 机器id
- private Long workerId;
- // 机器id位数
- private Long workerBits;
- // 序列id所占位数
- private Long sequenceBits;
- // 时间戳起始点(毫秒)
- private Long twepoch;
- // 单次批量生成id的最大数量
- private Integer maxBatchCount;
-}
\ No newline at end of file
diff --git a/common/pom.xml b/common/pom.xml
index 709f207..1971a2b 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -13,16 +13,15 @@
https://maven.apache.org
service-utils
- common-utils
- spring-security
+ common-generator
common-result
- cn.bunny
- model
- 0.0.1-SNAPSHOT
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
+ 2.17.0
io.jsonwebtoken
diff --git a/common/service-utils/pom.xml b/common/service-utils/pom.xml
index b47c877..8e4a6fe 100644
--- a/common/service-utils/pom.xml
+++ b/common/service-utils/pom.xml
@@ -19,7 +19,7 @@
cn.bunny
- common-utils
+ common-generator
0.0.1-SNAPSHOT
@@ -27,6 +27,11 @@
common-result
0.0.1-SNAPSHOT
+
+
+ com.github.xiaoymin
+ knife4j-openapi3-jakarta-spring-boot-starter
+
org.springframework.boot
spring-boot-starter-web
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/config/Knife4jConfig.java b/common/service-utils/src/main/java/cn/bunny/common/service/config/Knife4jConfig.java
index 00ccf95..eee1b94 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/config/Knife4jConfig.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/config/Knife4jConfig.java
@@ -29,6 +29,12 @@ public class Knife4jConfig {
// 管理员相关分类接口
@Bean
public GroupedOpenApi groupedOpenApi() {
+ return GroupedOpenApi.builder().group("前台接口管理").pathsToMatch("/api/**").build();
+ }
+
+ // 管理员相关分类接口
+ @Bean
+ public GroupedOpenApi groupedOpenAdminApi() {
return GroupedOpenApi.builder().group("管理员接口请求").pathsToMatch("/admin/**").build();
}
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java b/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java
index edd996c..34e61cb 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java
@@ -1,8 +1,8 @@
package cn.bunny.common.service.exception;
-import cn.bunny.common.constant.CommonMessageConstant;
-import cn.bunny.common.result.utils.Result;
+import cn.bunny.common.result.constant.CommonMessageConstant;
import cn.bunny.common.result.enums.ResultCodeEnum;
+import cn.bunny.common.result.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/utils/JwtHelper.java b/common/service-utils/src/main/java/cn/bunny/common/service/utils/JwtHelper.java
index 318b6bb..7215eb1 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/utils/JwtHelper.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/utils/JwtHelper.java
@@ -6,13 +6,13 @@ import org.springframework.util.StringUtils;
import java.util.Date;
public class JwtHelper {
- private static final long tokenExpiration = 365L * 24 * 60 * 60 * 1000;
+ private static final long tokenExpiration = 24 * 60 * 60 * 1000;
private static final String tokenSignKey = "Bunny-Java-Template";
- public static String createToken(Long userId, String userName) {
+ public static String createToken(Long userId, String userName, Integer day) {
return Jwts.builder()
.setSubject("Bunny-USER")
- .setExpiration(new Date(System.currentTimeMillis() + tokenExpiration))
+ .setExpiration(new Date(System.currentTimeMillis() + tokenExpiration * day))
.claim("userId", userId)
.claim("userName", userName)
.signWith(SignatureAlgorithm.HS256, tokenSignKey)
@@ -25,8 +25,7 @@ public class JwtHelper {
Jws claimsJws = Jwts.parser().setSigningKey(tokenSignKey).parseClaimsJws(token);
Claims claims = claimsJws.getBody();
- Integer userId = (Integer) claims.get("userId");
- return userId.longValue();
+ return (Long) claims.get("userId");
}
public static String getUserName(String token) {
@@ -42,8 +41,8 @@ public class JwtHelper {
}
public static void main(String[] args) {
- String token = JwtHelper.createToken(7L, "admin");
- System.out.println(token);
+ String token = JwtHelper.createToken(7L, "admin", 7);
+ // token = "eyJhbGciOiJIUzI1NiIsInppcCI6IkdaSVAifQ.H4sIAAAAAAAA_6tWKi5NUrJScirNy6vUDQ12DVLSUUqtKFCyMjQ3MTc0NrYwNddRKi1OLfJMUbKyNDIwNLQwMDAzg4j5JeamAjUbGhtaWhoYGJqaOBQW6iXn5yrVAgCrO9jLWAAAAA.DS1wYprXGoIMrjtUWfDSN9AG5gWoRZ17oAgcvC0kwag";
System.out.println(JwtHelper.getUserId(token));
System.out.println(JwtHelper.getUserName(token));
}
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/utils/ResponseUtil.java b/common/service-utils/src/main/java/cn/bunny/common/service/utils/ResponseUtil.java
index f815119..773eebe 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/utils/ResponseUtil.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/utils/ResponseUtil.java
@@ -2,20 +2,23 @@ package cn.bunny.common.service.utils;
import cn.bunny.common.result.utils.Result;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
import java.io.IOException;
public class ResponseUtil {
- public static void out(HttpServletResponse response, Result r) {
+ public static void out(HttpServletResponse response, Result
+
+
+ cn.hutool
+ hutool-all
+
+
com.alibaba.fastjson2
fastjson2
@@ -36,15 +42,6 @@
com.github.xiaoymin
knife4j-openapi3-jakarta-spring-boot-starter
-
-
- org.springframework.boot
- spring-boot-starter-security
-
-
-
- org.springframework.security
- spring-security-test
-
+
diff --git a/model/src/main/java/cn/bunny/entity/system/Login.java b/model/src/main/java/cn/bunny/entity/system/Login.java
deleted file mode 100644
index 140f575..0000000
--- a/model/src/main/java/cn/bunny/entity/system/Login.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package cn.bunny.entity.system;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@Builder
-@AllArgsConstructor
-@NoArgsConstructor
-public class Login {
- private String token;
-}
diff --git a/model/src/main/java/cn/bunny/entity/system/RoleByUser.java b/model/src/main/java/cn/bunny/entity/system/RoleByUser.java
deleted file mode 100644
index 4b1b929..0000000
--- a/model/src/main/java/cn/bunny/entity/system/RoleByUser.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package cn.bunny.entity.system;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.util.List;
-
-@Data
-@Builder
-@AllArgsConstructor
-@NoArgsConstructor
-public class RoleByUser {
- private List assginRoleList;
- private List allRolesList;
-}
diff --git a/model/src/main/java/cn/bunny/entity/system/SysDept.java b/model/src/main/java/cn/bunny/entity/system/SysDept.java
deleted file mode 100644
index 4565f40..0000000
--- a/model/src/main/java/cn/bunny/entity/system/SysDept.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package cn.bunny.entity.system;
-
-import cn.bunny.entity.base.BaseEntity;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import java.util.List;
-
-@Data
-@Schema(description = "部门")
-@TableName("sys_dept")
-public class SysDept extends BaseEntity {
-
- private static final long serialVersionUID = 1L;
-
- @Schema(description = "部门名称")
- @TableField("name")
- private String name;
-
- @Schema(description = "上级部门id")
- @TableField("parent_id")
- private Long parentId;
-
- @Schema(description = "树结构")
- @TableField("tree_path")
- private String treePath;
-
- @Schema(description = "排序")
- @TableField("sort_value")
- private Integer sortValue;
-
- @Schema(description = "负责人")
- @TableField("leader")
- private String leader;
-
- @Schema(description = "电话")
- @TableField("phone")
- private String phone;
-
- @Schema(description = "状态(1正常 0停用)")
- @TableField("status")
- private Integer status;
-
- @Schema(description = "下级部门")
- @TableField(exist = false)
- private List children;
-}
\ No newline at end of file
diff --git a/model/src/main/java/cn/bunny/entity/system/SysLoginLog.java b/model/src/main/java/cn/bunny/entity/system/SysLoginLog.java
deleted file mode 100644
index 4675fbf..0000000
--- a/model/src/main/java/cn/bunny/entity/system/SysLoginLog.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package cn.bunny.entity.system;
-
-import cn.bunny.entity.base.BaseEntity;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-import java.io.Serial;
-import java.util.Date;
-
-@EqualsAndHashCode(callSuper = true)
-@Data
-@Schema(description = "SysLoginLog")
-@TableName("sys_login_log")
-public class SysLoginLog extends BaseEntity {
-
- @Serial
- private static final long serialVersionUID = 1L;
-
- @Schema(description = "用户账号")
- @TableField("username")
- private String username;
-
- @Schema(description = "登录IP地址")
- @TableField("ipaddr")
- private String ipaddr;
-
- @Schema(description = "登录状态(0成功 1失败)")
- @TableField("status")
- private Integer status;
-
- @Schema(description = "提示信息")
- @TableField("msg")
- private String msg;
-
- @Schema(description = "访问时间")
- @TableField("access_time")
- private Date accessTime;
-
-}
\ No newline at end of file
diff --git a/model/src/main/java/cn/bunny/entity/system/SysMenu.java b/model/src/main/java/cn/bunny/entity/system/SysMenu.java
deleted file mode 100644
index 75e4dde..0000000
--- a/model/src/main/java/cn/bunny/entity/system/SysMenu.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package cn.bunny.entity.system;
-
-import cn.bunny.entity.base.BaseEntity;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-import java.io.Serial;
-import java.util.List;
-
-@EqualsAndHashCode(callSuper = true)
-@Data
-@Schema(description = "菜单")
-@TableName("sys_menu")
-public class SysMenu extends BaseEntity {
-
- @Serial
- private static final long serialVersionUID = 1L;
-
- @Schema(description = "所属上级")
- @TableField("parent_id")
- private Long parentId;
-
- @Schema(description = "名称")
- @TableField("name")
- private String name;
-
- @Schema(description = "类型(1:菜单,2:按钮)")
- @TableField("type")
- private Integer type;
-
- @Schema(description = "路由地址")
- @TableField("path")
- private String path;
-
- @Schema(description = "组件路径")
- @TableField("component")
- private String component;
-
- @Schema(description = "权限标识")
- @TableField("perms")
- private String perms;
-
- @Schema(description = "图标")
- @TableField("icon")
- private String icon;
-
- @Schema(description = "排序")
- @TableField("sort_description")
- private Integer sortdescription;
-
- @Schema(description = "状态(0:禁止,1:正常)")
- @TableField("status")
- private Integer status;
-
- // 下级列表
- @TableField(exist = false)
- private List children;
- // 是否选中
- @TableField(exist = false)
- private boolean isSelect;
-}
-
diff --git a/model/src/main/java/cn/bunny/entity/system/SysRole.java b/model/src/main/java/cn/bunny/entity/system/SysRole.java
deleted file mode 100644
index 28b720d..0000000
--- a/model/src/main/java/cn/bunny/entity/system/SysRole.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package cn.bunny.entity.system;
-
-import cn.bunny.entity.base.BaseEntity;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-import java.io.Serial;
-
-
-@EqualsAndHashCode(callSuper = true)
-@Data
-@Schema(description = "角色")
-@TableName("sys_role")
-public class SysRole extends BaseEntity {
- @Serial
- private static final long serialVersionUID = 1L;
-
- //@NotBlank(message = "角色名称不能为空")
- @Schema(description = "角色名称")
- @TableField("role_name")
- private String roleName;
-
- @Schema(description = "角色编码")
- @TableField("role_code")
- private String roleCode;
-
- @Schema(description = "描述")
- @TableField("description")
- private String description;
-}
-
diff --git a/model/src/main/java/cn/bunny/entity/system/SysUser.java b/model/src/main/java/cn/bunny/entity/system/SysUser.java
deleted file mode 100644
index 1000b92..0000000
--- a/model/src/main/java/cn/bunny/entity/system/SysUser.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package cn.bunny.entity.system;
-
-import cn.bunny.entity.base.BaseEntity;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-import java.io.Serial;
-import java.util.List;
-
-@EqualsAndHashCode(callSuper = true)
-@Data
-@Schema(description = "用户")
-@TableName("sys_user")
-public class SysUser extends BaseEntity {
-
- @Serial
- private static final long serialVersionUID = 1L;
-
- @Schema(description = "用户名")
- @TableField("username")
- private String username;
-
- @Schema(description = "密码")
- @TableField("password")
- private String password;
-
- @Schema(description = "姓名")
- @TableField("name")
- private String name;
-
- @Schema(description = "手机")
- @TableField("phone")
- private String phone;
-
- @Schema(description = "头像地址")
- @TableField("head_url")
- private String headUrl;
-
- @Schema(description = "部门id")
- @TableField("dept_id")
- private Long deptId;
-
- @Schema(description = "岗位id")
- @TableField("post_id")
- private Long postId;
-
- @Schema(description = "描述")
- @TableField("description")
- private String description;
-
- @Schema(description = "openId")
- @TableField("open_id")
- private String openId;
-
- @Schema(description = "状态(1:正常 0:停用)")
- @TableField("status")
- private Integer status;
-
- @TableField(exist = false)
- private List roleList;
- // 岗位
- @TableField(exist = false)
- private String postName;
- // 部门
- @TableField(exist = false)
- private String deptName;
-}
-
diff --git a/model/src/main/java/cn/bunny/entity/system/SysUserinfo.java b/model/src/main/java/cn/bunny/entity/system/SysUserinfo.java
deleted file mode 100644
index 731524f..0000000
--- a/model/src/main/java/cn/bunny/entity/system/SysUserinfo.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package cn.bunny.entity.system;
-
-import cn.bunny.vo.system.RouterVo;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.util.HashSet;
-import java.util.List;
-
-@Data
-@Builder
-@AllArgsConstructor
-@NoArgsConstructor
-public class SysUserinfo {
- private HashSet roles;
- private String name;
- private String avatar;
- private List buttons;
- private List routers;
-}
diff --git a/model/src/main/java/cn/bunny/vo/system/LoginVo.java b/model/src/main/java/cn/bunny/vo/system/LoginVo.java
index 1630ed7..e884fc7 100644
--- a/model/src/main/java/cn/bunny/vo/system/LoginVo.java
+++ b/model/src/main/java/cn/bunny/vo/system/LoginVo.java
@@ -1,26 +1,34 @@
package cn.bunny.vo.system;
-
+import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
+import java.time.LocalDateTime;
+
/**
- * 登录对象
+ * 用户登录返回内容
*/
@Data
-@Builder
@AllArgsConstructor
@NoArgsConstructor
+@Builder
public class LoginVo {
- /**
- * 手机号
- */
- private String username;
-
- /**
- * 密码
- */
- private String password;
+ private String userId;
+ private String nickName;
+ private String email;
+ private Integer sex;
+ private String personDescription;
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime joinTime;
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime lastLoginTime;
+ private String lastLoginIp;
+ private String lastLoginIpAddress;
+ private Integer totalIntegral;
+ private Integer currentIntegral;
+ private Byte status;
+ private String token;
}
diff --git a/model/src/main/java/cn/bunny/vo/system/MetaVo.java b/model/src/main/java/cn/bunny/vo/system/MetaVo.java
deleted file mode 100644
index 9e9b567..0000000
--- a/model/src/main/java/cn/bunny/vo/system/MetaVo.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package cn.bunny.vo.system;
-
-import lombok.Data;
-
-/**
- * 路由显示信息
- */
-@Data
-public class MetaVo {
- /**
- * 设置该路由在侧边栏和面包屑中展示的名字
- */
- private String title;
-
- /**
- * 设置该路由的图标,对应路径src/assets/icons/svg
- */
- private String icon;
-
- public MetaVo() {
- }
-
- public MetaVo(String title, String icon) {
- this.title = title;
- this.icon = icon;
- }
-
-}
-
diff --git a/model/src/main/java/cn/bunny/vo/system/RouterVo.java b/model/src/main/java/cn/bunny/vo/system/RouterVo.java
deleted file mode 100644
index 97f63dc..0000000
--- a/model/src/main/java/cn/bunny/vo/system/RouterVo.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package cn.bunny.vo.system;
-
-import lombok.Data;
-
-import java.util.List;
-
-/**
- * 路由配置信息
- */
-@Data
-public class RouterVo {
- /**
- * 路由名字
- */
- // private String name;
-
- /**
- * 路由地址
- */
- private String path;
-
- /**
- * 是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现
- */
- private boolean hidden;
-
- /**
- * 组件地址
- */
- private String component;
-
- /**
- * 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
- */
- private Boolean alwaysShow;
-
- /**
- * 其他元素
- */
- private MetaVo meta;
-
- /**
- * 子路由
- */
- private List children;
-
-
-}
diff --git a/model/src/main/java/cn/bunny/vo/system/SysOperLogQueryVo.java b/model/src/main/java/cn/bunny/vo/system/SysOperLogQueryVo.java
deleted file mode 100644
index ee61375..0000000
--- a/model/src/main/java/cn/bunny/vo/system/SysOperLogQueryVo.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package cn.bunny.vo.system;
-
-import lombok.Data;
-
-@Data
-public class SysOperLogQueryVo {
-
- private String title;
- private String operName;
-
- private String createTimeBegin;
- private String createTimeEnd;
-
-}
-
diff --git a/model/src/main/java/cn/bunny/vo/system/SysPostQueryVo.java b/model/src/main/java/cn/bunny/vo/system/SysPostQueryVo.java
deleted file mode 100644
index d57396a..0000000
--- a/model/src/main/java/cn/bunny/vo/system/SysPostQueryVo.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package cn.bunny.vo.system;
-
-import lombok.Data;
-
-@Data
-public class SysPostQueryVo {
-
- //@ApiModelProperty(value = "岗位编码")
- private String postCode;
-
- //@ApiModelProperty(value = "岗位名称")
- private String name;
-
- //@ApiModelProperty(value = "状态(1正常 0停用)")
- private Boolean status;
-
-
-}
-
diff --git a/module/module-mail/src/main/java/cn/bunny/module/mail/utils/MailSendCheckUtil.java b/module/module-mail/src/main/java/cn/bunny/module/mail/utils/MailSendCheckUtil.java
index 6ac37b5..4d2de49 100644
--- a/module/module-mail/src/main/java/cn/bunny/module/mail/utils/MailSendCheckUtil.java
+++ b/module/module-mail/src/main/java/cn/bunny/module/mail/utils/MailSendCheckUtil.java
@@ -1,6 +1,6 @@
package cn.bunny.module.mail.utils;
-import cn.bunny.common.constant.MailMessageConstant;
+import cn.bunny.common.result.constant.MailMessageConstant;
import cn.bunny.common.service.utils.EmptyUtil;
import cn.bunny.entity.email.EmailSend;
diff --git a/module/module-minio/src/main/java/cn/bunny/module/minio/utils/MinioUtil.java b/module/module-minio/src/main/java/cn/bunny/module/minio/utils/MinioUtil.java
index 41eb90f..f60fa1c 100644
--- a/module/module-minio/src/main/java/cn/bunny/module/minio/utils/MinioUtil.java
+++ b/module/module-minio/src/main/java/cn/bunny/module/minio/utils/MinioUtil.java
@@ -1,6 +1,6 @@
package cn.bunny.module.minio.utils;
-import cn.bunny.common.constant.MinioMessageConstant;
+import cn.bunny.common.result.constant.MinioMessageConstant;
import cn.bunny.common.service.exception.BunnyException;
import io.minio.*;
import io.minio.messages.*;
diff --git a/module/module-rabbitMQ/pom.xml b/module/module-rabbitMQ/pom.xml
index 29884a1..e949a2f 100644
--- a/module/module-rabbitMQ/pom.xml
+++ b/module/module-rabbitMQ/pom.xml
@@ -29,7 +29,6 @@
com.fasterxml.jackson.dataformat
jackson-dataformat-xml
- 2.16.0-rc1
diff --git a/common/spring-security/pom.xml b/module/module-websocket/pom.xml
similarity index 70%
rename from common/spring-security/pom.xml
rename to module/module-websocket/pom.xml
index bcaa7a1..e3b9b40 100644
--- a/common/spring-security/pom.xml
+++ b/module/module-websocket/pom.xml
@@ -3,14 +3,14 @@
4.0.0
cn.bunny
- common
+ module
0.0.1-SNAPSHOT
- spring-security
+ module-websocket
jar
- spring-security
+ module-websocket
https://maven.apache.org
@@ -18,10 +18,10 @@
+
- cn.bunny
- service-utils
- 0.0.1-SNAPSHOT
+ org.springframework.boot
+ spring-boot-starter-websocket
diff --git a/service/service-main/src/main/java/cn/bunny/service/websocket/WebSocketServer.java b/module/module-websocket/src/main/java/cn/bunny/module/websocket/WebSocketServer.java
similarity index 98%
rename from service/service-main/src/main/java/cn/bunny/service/websocket/WebSocketServer.java
rename to module/module-websocket/src/main/java/cn/bunny/module/websocket/WebSocketServer.java
index d528711..2d84cc6 100644
--- a/service/service-main/src/main/java/cn/bunny/service/websocket/WebSocketServer.java
+++ b/module/module-websocket/src/main/java/cn/bunny/module/websocket/WebSocketServer.java
@@ -1,4 +1,4 @@
-package cn.bunny.service.websocket;
+package cn.bunny.module.websocket;
import jakarta.websocket.OnClose;
import jakarta.websocket.OnMessage;
diff --git a/pom.xml b/pom.xml
index c6bfcbb..64fa9da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,5 @@
-
4.0.0
@@ -30,6 +30,7 @@
22
22
21
+ 3.8.1
3.5.6
8.0.30
4.5.0
@@ -39,10 +40,22 @@
0.9.1
3.3.3
2.10.1
- 1.9.21
+ 1.9.21
+ 2023.0.1
+ 2.16.0-rc1
+ 2023.0.1.0
+ 2023.0.0.0-RC1
+ 4.1.2
+ 6.1.0
+
+
+ junit
+ junit
+ ${junit.version}
+
com.baomidou
@@ -83,7 +96,7 @@
cn.hutool
hutool-all
- 5.8.25
+ 5.8.27
@@ -101,19 +114,62 @@
org.aspectj
aspectjrt
- ${aspectj}
+ ${aspectj.version}
org.aspectj
aspectjweaver
- ${aspectj}
+ ${aspectj.version}
joda-time
joda-time
${jodatime.version}
+
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-xml
+ ${jackson-dataformat.version}
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${cloud.version}
+ pom
+ import
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ ${alibaba.version}
+ pom
+ import
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+ ${discovery.version}
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+ ${loadbalancer.version}
+
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
+ 2.12.3
+
+
+ com.github.pagehelper
+ pagehelper
+ ${pagehelper.version}
+
diff --git a/server-gateway/pom.xml b/server-gateway/pom.xml
index d60d984..9efc13e 100644
--- a/server-gateway/pom.xml
+++ b/server-gateway/pom.xml
@@ -1,4 +1,4 @@
-
4.0.0
@@ -21,6 +21,17 @@
+
+ cn.bunny
+ common-result
+ 0.0.1-SNAPSHOT
+
+
+ com.baomidou
+ mybatis-plus-spring-boot3-starter
+
+
+
org.springframework.cloud
diff --git a/server-gateway/src/main/java/cn/bunny/service/gateway/GatewayApplication.java b/server-gateway/src/main/java/cn/bunny/service/gateway/GatewayApplication.java
index a45d16e..7f27648 100644
--- a/server-gateway/src/main/java/cn/bunny/service/gateway/GatewayApplication.java
+++ b/server-gateway/src/main/java/cn/bunny/service/gateway/GatewayApplication.java
@@ -4,8 +4,10 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
+import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
+@EnableScheduling// 定时任务
@ComponentScan("cn.bunny")
@Slf4j
public class GatewayApplication {
diff --git a/server-gateway/src/main/java/cn/bunny/service/gateway/controller/IndexController.java b/server-gateway/src/main/java/cn/bunny/service/gateway/controller/IndexController.java
index 1f232cd..4936f98 100644
--- a/server-gateway/src/main/java/cn/bunny/service/gateway/controller/IndexController.java
+++ b/server-gateway/src/main/java/cn/bunny/service/gateway/controller/IndexController.java
@@ -1,6 +1,6 @@
package cn.bunny.service.gateway.controller;
-import com.alibaba.nacos.api.model.v2.Result;
+import cn.bunny.common.result.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
diff --git a/server-gateway/src/main/resources/application-dev.yml b/server-gateway/src/main/resources/application-dev.yml
index e1f8308..25ba079 100644
--- a/server-gateway/src/main/resources/application-dev.yml
+++ b/server-gateway/src/main/resources/application-dev.yml
@@ -2,7 +2,7 @@ bunny:
nacos:
server-addr: z-bunny.cn:8848
discovery:
- namespace: spzx
+ namespace: bunnyBBS
redis:
host: 47.120.65.66
diff --git a/server-gateway/src/main/resources/application.yml b/server-gateway/src/main/resources/application.yml
index f9b812f..88a1647 100644
--- a/server-gateway/src/main/resources/application.yml
+++ b/server-gateway/src/main/resources/application.yml
@@ -1,14 +1,13 @@
server:
- port: 8500
+ port: 8800
spring:
profiles:
active: dev
application:
name: service-gateway
-# main:
-# web-application-type: reactive
- # allow-bean-definition-overriding: true
-
+ main:
+ web-application-type: reactive
+ allow-bean-definition-overriding: true
cloud:
sentinel:
log:
@@ -24,11 +23,16 @@ spring:
locator:
enabled: true
# 路由
-# routes:
-# - id: service-product
-# uri: lb://service-product
-# predicates:
-# - Path=/*/product/**
+ routes:
+ - id: service-web
+ uri: lb://service-web
+ predicates:
+ - Path=/api/**
+ - id: service-admin
+ uri: lb://service-admin
+ predicates:
+ - Path=/admin/**
+
data:
redis:
host: ${bunny.redis.host}
diff --git a/server-gateway/src/test/java/cn/bunny/AppTest.java b/server-gateway/src/test/java/cn/bunny/AppTest.java
deleted file mode 100644
index 34b54ff..0000000
--- a/server-gateway/src/test/java/cn/bunny/AppTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package cn.bunny;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Unit test for simple App.
- */
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
- /**
- * Rigourous Test :-)
- */
- public void testApp()
- {
- assertTrue( true );
- }
-}
diff --git a/service-client/pom.xml b/service-client/pom.xml
index cc8e314..55bac23 100644
--- a/service-client/pom.xml
+++ b/service-client/pom.xml
@@ -1,4 +1,4 @@
-
4.0.0
@@ -18,6 +18,26 @@
+
+ cn.bunny
+ model
+ 0.0.1-SNAPSHOT
+
+
+ cn.bunny
+ common-result
+ 0.0.1-SNAPSHOT
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+
+ org.springframework.cloud
+ spring-cloud-loadbalancer
+
diff --git a/service/pom.xml b/service/pom.xml
index e96729f..d3d3c9d 100644
--- a/service/pom.xml
+++ b/service/pom.xml
@@ -12,19 +12,19 @@
service
https://maven.apache.org
- service-main
+ service-web
+ service-admin
UTF-8
-
+
-
+
junit
junit
- 3.8.1
diff --git a/service/service-main/Dockerfile b/service/service-main/Dockerfile
deleted file mode 100644
index 447a2bc..0000000
--- a/service/service-main/Dockerfile
+++ /dev/null
@@ -1,21 +0,0 @@
-FROM openjdk:21
-MAINTAINER bunny
-
-#系统编码
-ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
-
-# 设置时区,构建镜像时执行的命令
-RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
-RUN echo "Asia/Shanghai" > /etc/timezone
-
-# 设定工作目录
-WORKDIR /home/bunny
-
-# 复制jar包
-COPY target/*.jar /home/bunny/app.jar
-
-#启动容器时的进程
-ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
-
-#暴露 8800 端口
-EXPOSE 8800
\ No newline at end of file
diff --git a/service/service-main/pom.xml b/service/service-main/pom.xml
deleted file mode 100644
index 61996d4..0000000
--- a/service/service-main/pom.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-
- 4.0.0
-
- cn.bunny
- service
- 0.0.1-SNAPSHOT
-
-
- service-main
- jar
-
- service-main
- https://maven.apache.org
-
-
- UTF-8
- 192.168.3.98:1100
- 192.168.3.98:2375
- bunny-service
-
-
-
-
- cn.bunny
- spring-security
- 0.0.1-SNAPSHOT
-
-
-
- cn.bunny
- service-utils
- 0.0.1-SNAPSHOT
-
-
- cn.bunny
- module-mail
- 0.0.1-SNAPSHOT
-
-
- cn.bunny
- module-minio
- 0.0.1-SNAPSHOT
-
-
-
- org.springframework.boot
- spring-boot-starter-websocket
-
-
-
- org.aspectj
- aspectjrt
-
-
- org.aspectj
- aspectjweaver
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- true
-
-
-
- com.spotify
- docker-maven-plugin
- 1.2.2
-
-
-
- build-image
-
- package
-
- build
- push
-
-
-
-
- harbor
- http://${docker.repostory}
-
- http://${docker.host}
-
-
- ${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
-
-
- ${project.basedir}
-
- false
-
-
-
-
-
diff --git a/service/service-main/src/main/java/cn/bunny/service/ServiceApplication.java b/service/service-main/src/main/java/cn/bunny/service/ServiceApplication.java
deleted file mode 100644
index 9ad3a84..0000000
--- a/service/service-main/src/main/java/cn/bunny/service/ServiceApplication.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package cn.bunny.service;
-
-import lombok.extern.slf4j.Slf4j;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.scheduling.annotation.EnableScheduling;
-
-@ComponentScan(basePackages = {"cn.bunny"})
-@MapperScan("cn.bunny.service.mapper")
-@EnableScheduling// 定时任务
-@EnableCaching// 开启缓存注解
-@SpringBootApplication
-@Slf4j
-public class ServiceApplication {
- public static void main(String[] args) {
- log.info("ServiceApplication启动...");
- SpringApplication.run(ServiceApplication.class, args);
- }
-}
diff --git a/service/service-main/src/main/java/cn/bunny/service/aop/annotation/AutoFill.java b/service/service-main/src/main/java/cn/bunny/service/aop/annotation/AutoFill.java
deleted file mode 100644
index 8c26d32..0000000
--- a/service/service-main/src/main/java/cn/bunny/service/aop/annotation/AutoFill.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package cn.bunny.service.aop.annotation;
-
-import cn.bunny.enums.OperationType;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface AutoFill {
- // 数据库操作类型
- OperationType value();
-}
diff --git a/service/service-main/src/main/java/cn/bunny/service/aop/aspect/AutoFillAspect.java b/service/service-main/src/main/java/cn/bunny/service/aop/aspect/AutoFillAspect.java
deleted file mode 100644
index 7d2fc45..0000000
--- a/service/service-main/src/main/java/cn/bunny/service/aop/aspect/AutoFillAspect.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package cn.bunny.service.aop.aspect;
-
-import lombok.extern.slf4j.Slf4j;
-import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Before;
-import org.aspectj.lang.annotation.Pointcut;
-import org.springframework.stereotype.Component;
-
-@Aspect
-@Component
-@Slf4j
-public class AutoFillAspect {
- @Pointcut("execution(* cn.bunny.service.*.*(..))")
- public void autoFillPointcut() {
- }
-
- /**
- * 之前操作
- *
- * @param joinPoint 参数
- */
- @Before("autoFillPointcut()")
- public void autoFill(JoinPoint joinPoint) {
- log.info("开始进行自动填充");
- }
-}
diff --git a/service/service-main/src/main/java/cn/bunny/service/controller/BaseController.java b/service/service-main/src/main/java/cn/bunny/service/controller/BaseController.java
deleted file mode 100644
index c383e52..0000000
--- a/service/service-main/src/main/java/cn/bunny/service/controller/BaseController.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package cn.bunny.service.controller;
-
-import cn.bunny.common.result.utils.Result;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.core.context.SecurityContext;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.core.session.SessionInformation;
-import org.springframework.security.core.session.SessionRegistry;
-import org.springframework.security.core.userdetails.User;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
-
-@Tag(name = "后台登录管理")
-@RestController
-@RequestMapping("/")
-public class BaseController {
- @Autowired
- private SessionRegistry sessionRegistry;
-
- @GetMapping()
- public String index() {
- return "欢迎访问";
- }
-
- @Operation(summary = "Security上下文对象", description = "Security上下文对象")
- @GetMapping("/test/getSecurityHolder")
- public Result getSecurityHolder() {
- SecurityContext context = SecurityContextHolder.getContext();
- return Result.success(context);
- }
-
- @Operation(summary = "当前所有登录的用户", description = "当前所有登录的用户")
- @GetMapping("/test/getAllUserLogin")
- public Result getAllUserLogin() {
- return Result.success(sessionRegistry.getAllPrincipals());
- }
-
- @Operation(summary = "剔除下线", description = "剔除下线")
- @GetMapping("/test/killOut")
- public Result killOut(String userId) {
- List allPrincipals = sessionRegistry.getAllPrincipals();
- for (Object allPrincipal : allPrincipals) {
- // 获取当前所有已经登录session会话:未失效的session
- List allSessions = sessionRegistry.getAllSessions(allPrincipal, false);
- User user = (User) allPrincipals;
-
- // 如果用户名匹配将这个用户下线
- if (user.getUsername().equals(userId)) {
- allSessions.forEach(SessionInformation::expireNow);
- }
- }
- return Result.success();
- }
-}
diff --git a/service/service-main/src/main/java/cn/bunny/service/controller/IndexController.java b/service/service-main/src/main/java/cn/bunny/service/controller/IndexController.java
deleted file mode 100644
index dfaa2dc..0000000
--- a/service/service-main/src/main/java/cn/bunny/service/controller/IndexController.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package cn.bunny.service.controller;
-
-import cn.bunny.common.result.utils.Result;
-import cn.bunny.entity.system.Login;
-import cn.bunny.entity.system.SysUserinfo;
-import cn.bunny.service.service.SysUserService;
-import cn.bunny.vo.system.LoginVo;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import jakarta.servlet.http.HttpServletRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.Map;
-
-/**
- *
- * 后台登录登出
- *
- */
-@Tag(name = "后台登录管理")
-@RestController
-@RequestMapping("/admin/system/index")
-public class IndexController {
- @Autowired
- private SysUserService sysUserService;
-
- @Operation(summary = "登录", description = "登录")
- @PostMapping("login")
- public Result login(@RequestBody LoginVo loginVo) {
- Login login = sysUserService.login(loginVo);
- return Result.success(login);
- }
-
- @Operation(summary = "获取用户信息", description = "获取用户信息")
- @GetMapping("info")
- public Result info(HttpServletRequest request) {
- SysUserinfo userinfo = sysUserService.getUserinfo(request);
- return Result.success(userinfo);
- }
-
- @Operation(summary = "退出", description = "退出")
- @GetMapping("logout")
- public Result
-
- org.apache.httpcomponents
- httpclient
- 4.5.14
-
javax.xml.bind
jaxb-api
2.1
+
+
+ org.apache.velocity
+ velocity-engine-core
+
+
+ org.apache.velocity.tools
+ velocity-tools-generic
+
mysql
@@ -54,11 +58,6 @@
mybatis-plus-generator
3.5.6
-
- org.apache.velocity
- velocity-engine-core
- 2.3
-
diff --git a/common/common-generator/src/main/java/cn/bunny/common/generator/NewCodeGet.java b/common/common-generator/src/main/java/cn/bunny/common/generator/NewCodeGet.java
index 5ec7256..27d0fe9 100644
--- a/common/common-generator/src/main/java/cn/bunny/common/generator/NewCodeGet.java
+++ b/common/common-generator/src/main/java/cn/bunny/common/generator/NewCodeGet.java
@@ -1,6 +1,5 @@
package cn.bunny.common.generator;
-
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
@@ -15,12 +14,12 @@ public class NewCodeGet {
// 作者名称
public static final String author = "Bunny";
// 公共路径
- public static final String outputDir = "F:\\web项目\\PC\\BunnyNote\\bunny-server\\service\\service-admin";
+ public static final String outputDir = "F:\\web项目\\PC\\BunnyNote\\BunnyBBS-server\\service\\service-web";
// 实体类名称
public static final String entity = "Bunny";
public static void main(String[] args) {
- Generation("email_users");
+ Generation("article");
}
/**
@@ -42,7 +41,7 @@ public class NewCodeGet {
.packageConfig(builder -> {
builder.entity(entity)// 实体类包名
// TODO 父包名。如果为空,将下面子包名必须写全部, 否则就只需写子包名
- .parent("cn.bunny.service.admin")
+ .parent("cn.bunny.service.web")
.controller("controller")// 控制层包名
.mapper("mapper")// mapper层包名
.service("service")// service层包名
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/constant/CommonMessageConstant.java b/common/common-result/src/main/java/cn/bunny/common/result/constant/CommonMessageConstant.java
deleted file mode 100644
index 9f1a1be..0000000
--- a/common/common-result/src/main/java/cn/bunny/common/result/constant/CommonMessageConstant.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package cn.bunny.common.result.constant;
-
-import lombok.Data;
-
-/**
- * 信息提示常量类
- */
-@Data
-public class CommonMessageConstant {
- public static final String PASSWORD_ERROR = "密码错误";
- public static final String OLD_PASSWORD_ERROR = "旧密码不匹配";
- public static final String OLD_PASSWORD_SAME_NEW_PASSWORD = "旧密码与新密码相同";
- public static final String ACCOUNT_NOT_FOUND = "账号不存在";
- public static final String ACCOUNT_LOCKED = "账号被锁定";
- public static final String UNKNOWN_ERROR = "未知错误";
- public static final String USER_NOT_LOGIN = "用户未登录";
- public static final String USER_TOKEN_OUT_OF_DATE = "用户登录过期";
- public static final String LOGIN_FAILED = "登录失败";
- public static final String UPLOAD_FAILED = "文件上传失败";
- public static final String PASSWORD_EDIT_FAILED = "密码修改失败";
- public static final String ALREADY_EXISTS = "已存在";
- public static final String REQUEST_NOT_EMPTY = "请求不为空";
- public static final String UPDATE_ID_IS_NOT_EMPTY = "删除id不能为空";
- public static final String DELETE_ID_IS_NOT_EMPTY = "修改id不能为空";
- public static final String MENU_IS_NOT_EXIST = "菜单不存在";
- public static final String SAVE_DTO_IS_NULL = "添加参数不能为空";
- public static final String UPDATE_DTO_IS_NULL = "修改参数不能为空";
- public static final String FIND_ID_IS_NOT_EMPTY = "查询ID不能为空";
- public static final String MESSAGE_CODE_NOT_PASS = "短信验证码未过期";
- public static final String MESSAGE_CODE_UNAUTHORIZED = "短信验证码未授权,请联系管理员";
- public static final String VERIFICATION_CODE_ERROR = "验证码错误";
- public static final String USER_DOES_NOT_EXIST = "用户不存在";
- public static final String USER_DOES_IS_EXIST = "用户已存在";
- public static final String VERIFICATION_CODE_IS_EMPTY = "请先发送验证码";
- public static final String LOGIN_DTO_IS_EMPTY = "登录参数不能为空";
- public static final String TOKEN_IS_EMPTY = "token为空";
- public static final String DATA_IS_EMPTY = "数据为空";
- public static final String USERNAME_NOT_EMPTY = "用户名不能为空";
- public static final String PASSWORD_NOT_EMPTY = "密码不能为空";
- public static final String SERVER_ERROR = "密码不能为空";
-}
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/constant/ExceptionConstant.java b/common/common-result/src/main/java/cn/bunny/common/result/constant/ExceptionConstant.java
deleted file mode 100644
index 7a8c533..0000000
--- a/common/common-result/src/main/java/cn/bunny/common/result/constant/ExceptionConstant.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package cn.bunny.common.result.constant;
-
-
-import lombok.Data;
-
-@Data
-public class ExceptionConstant {
- public static final String USER_NOT_FOUND = "用户不存在";
- public static final String USERNAME_IS_EMPTY = "用户名不能为空";
- public static final String PASSWORD_ERROR = "密码错误";
- public static final String PASSWORD_IS_EMPTY = "密码不能为空";
- public static final String CAPTCHA_IS_EMPTY = "提交验证码不能为空";
- public static final String KEY_IS_EMPTY = "验证码key不能为空";
- public static final String VERIFICATION_CODE_DOES_NOT_MATCH = "验证码不匹配";
- public static final String VERIFICATION_CODE_IS_EMPTY = "验证码失效或不存在";
-}
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/constant/PasswordConstant.java b/common/common-result/src/main/java/cn/bunny/common/result/constant/PasswordConstant.java
deleted file mode 100644
index 86109f3..0000000
--- a/common/common-result/src/main/java/cn/bunny/common/result/constant/PasswordConstant.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package cn.bunny.common.result.constant;
-
-import lombok.Data;
-
-/**
- * 密码常量
- */
-@Data
-public class PasswordConstant {
- // 默认密码
- public static final String DEFAULT_PASSWORD = "123456";
- // JWT密码
- public static final String DEFAULT_JWT_PASSWORD = "123456";
- // 默认头像
- public static final String AVTAR = "https://oss.aliyuncs.com/aliyun_id_photo_bucket/default_handsome.jpg";
- // 设置token过期时间
- public static final long TOKEN_EXPIRATION = 365L * 24 * 60 * 60 * 1000;
-}
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/constant/RedisUserConstant.java b/common/common-result/src/main/java/cn/bunny/common/result/constant/RedisUserConstant.java
deleted file mode 100644
index b2e70ff..0000000
--- a/common/common-result/src/main/java/cn/bunny/common/result/constant/RedisUserConstant.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package cn.bunny.common.result.constant;
-
-import lombok.Data;
-
-/**
- * Redis用户前缀设置
- */
-@Data
-public class RedisUserConstant {
- public static final String REDIS_CART_KEY = "user::";
-}
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/enums/ResultCodeEnum.java b/common/common-result/src/main/java/cn/bunny/common/result/enums/ResultCodeEnum.java
deleted file mode 100644
index 68402cc..0000000
--- a/common/common-result/src/main/java/cn/bunny/common/result/enums/ResultCodeEnum.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package cn.bunny.common.result.enums;
-
-import lombok.Getter;
-
-/**
- * 统一返回结果状态信息类
- */
-@Getter
-public enum ResultCodeEnum {
- SUCCESS(200, "操作成功"),
- SUCCESS_LOGOUT(200, "退出成功"),
- FAIL(201, "失败"),
- USERNAME_NOT_EMPTY(201, "用户名不能为空"),
- PASSWORD_NOT_EMPTY(201, "密码不能为空"),
- SERVICE_ERROR(2012, "服务异常"),
- DATA_ERROR(204, "数据异常"),
- LOGIN_ERROR(204, "账号或密码错误"),
- ILLEGAL_REQUEST(205, "非法请求"),
- REPEAT_SUBMIT(206, "重复提交"),
-
- LOGIN_AUTH(208, "未登陆"),
- PERMISSION(209, "没有权限"),
-
- URL_ENCODE_ERROR(216, "URL编码失败"),
- ILLEGAL_CALLBACK_REQUEST_ERROR(217, "非法回调请求"),
- FETCH_ACCESSTOKEN_FAILD(218, "获取accessToken失败"),
- FETCH_USERINFO_ERROR(219, "获取用户信息失败"),
-
- FAIL_REQUEST_NOT_AUTH(403, "用户未认证"),
- FAIL_NO_ACCESS_DENIED(403, "无权访问"),
- LOGGED_IN_FROM_ANOTHER_DEVICE(403, "没有权限访问"),
- THE_SAME_USER_HAS_LOGGED_IN(403, "相同用户已登录"),
- SESSION_EXPIRATION(403, "会话过期");
-
-
- private final Integer code;
-
- private final String message;
-
- ResultCodeEnum(Integer code, String message) {
- this.code = code;
- this.message = message;
- }
-}
\ No newline at end of file
diff --git a/common/common-result/pom.xml b/common/common-utils/pom.xml
similarity index 77%
rename from common/common-result/pom.xml
rename to common/common-utils/pom.xml
index b1d9bc0..f832c59 100644
--- a/common/common-result/pom.xml
+++ b/common/common-utils/pom.xml
@@ -7,10 +7,10 @@
0.0.1-SNAPSHOT
- common-result
+ common-utils
jar
- common-result
+ common-utils
https://maven.apache.org
@@ -19,8 +19,9 @@
- org.projectlombok
- lombok
+ cn.bunny
+ model
+ 0.0.1-SNAPSHOT
diff --git a/common/common-utils/src/main/java/cn/bunny/common/utils/CommentUtil.java b/common/common-utils/src/main/java/cn/bunny/common/utils/CommentUtil.java
new file mode 100644
index 0000000..b733f66
--- /dev/null
+++ b/common/common-utils/src/main/java/cn/bunny/common/utils/CommentUtil.java
@@ -0,0 +1,51 @@
+package cn.bunny.common.utils;
+
+import cn.bunny.vo.system.comment.CommentVo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CommentUtil {
+ /**
+ * 构建树型结构
+ *
+ * @param commentList 评论列表
+ * @return 结构列表
+ */
+ public static List buildTree(List commentList) {
+ // 构建树形结构
+ List tree = new ArrayList<>();
+ // 遍历评论列表
+ for (CommentVo comment : commentList) {
+ // 找到顶级评论(没有父评论)
+ if (comment.getPCommentId() == 0) {
+ // 递归构建子评论
+ comment.setChildren(getChildren(comment.getId(), commentList));
+ tree.add(comment);
+ }
+ }
+ return tree;
+ }
+
+ /**
+ * 递归获取子评论
+ *
+ * @param commentId 当前评论ID
+ * @param commentList 评论列表
+ * @return 子评论列表
+ */
+ private static List getChildren(Long commentId, List commentList) {
+ List children = new ArrayList<>();
+
+ // 遍历评论列表
+ for (CommentVo comment : commentList) {
+ // 找到当前评论的子评论
+ if (Long.valueOf(comment.getPCommentId()).equals(commentId)) {
+ // 递归构建子评论的子评论
+ comment.setChildren(getChildren(comment.getId(), commentList));
+ children.add(comment);
+ }
+ }
+ return children;
+ }
+}
diff --git a/common/common-utils/src/main/java/cn/bunny/common/utils/FileUtil.java b/common/common-utils/src/main/java/cn/bunny/common/utils/FileUtil.java
new file mode 100644
index 0000000..739253c
--- /dev/null
+++ b/common/common-utils/src/main/java/cn/bunny/common/utils/FileUtil.java
@@ -0,0 +1,25 @@
+package cn.bunny.common.utils;
+
+public class FileUtil {
+ public static String getSize(Long fileSize) {
+ double fileSizeInKB = fileSize / 1024.00;
+ double fileSizeInMB = fileSizeInKB / 1024;
+ double fileSizeInGB = fileSizeInMB / 1024;
+
+ String size;
+ if (fileSizeInGB >= 1) {
+ fileSizeInGB = Double.parseDouble(String.format("%.2f", fileSizeInGB));
+ size = fileSizeInGB + "GB";
+ } else if (fileSizeInMB >= 1) {
+ fileSizeInMB = Double.parseDouble(String.format("%.2f", fileSizeInMB));
+ size = fileSizeInMB + "MB";
+ } else if (fileSizeInKB >= 1) {
+ fileSizeInKB = Double.parseDouble(String.format("%.2f", fileSizeInKB));
+ size = fileSizeInKB + "KB";
+ } else {
+ size = fileSize + "B";
+ }
+
+ return size;
+ }
+}
diff --git a/common/pom.xml b/common/pom.xml
index 1971a2b..19d4c57 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -3,7 +3,7 @@
4.0.0
cn.bunny
- bunny-template-mirror-server
+ bunny-mirror-server
0.0.1-SNAPSHOT
@@ -14,14 +14,13 @@
service-utils
common-generator
- common-result
+ common-utils
com.fasterxml.jackson.datatype
jackson-datatype-jsr310
- 2.17.0
io.jsonwebtoken
diff --git a/common/service-utils/pom.xml b/common/service-utils/pom.xml
index 8e4a6fe..3a326b2 100644
--- a/common/service-utils/pom.xml
+++ b/common/service-utils/pom.xml
@@ -19,13 +19,14 @@
cn.bunny
- common-generator
+ model
0.0.1-SNAPSHOT
+
- cn.bunny
- common-result
- 0.0.1-SNAPSHOT
+ org.apache.httpcomponents
+ httpclient
+ 4.5.14
@@ -47,5 +48,10 @@
redisson
3.26.1
+
+
+ com.github.pagehelper
+ pagehelper
+
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java b/common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java
index 86bdd5c..013c778 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import com.github.pagehelper.PageInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -23,7 +24,9 @@ public class MybatisPlusConfig {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 分页插件
- interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+ PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
+ paginationInnerInterceptor.setMaxLimit(100L);// ? 设置最大分页为100
+ interceptor.addInnerInterceptor(paginationInnerInterceptor);
// 乐观锁
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
// 防止全表删除
@@ -31,4 +34,9 @@ public class MybatisPlusConfig {
return interceptor;
}
+
+ @Bean// pagehelper分页插件需要配的拦截器
+ public PageInterceptor pageInterceptor() {
+ return new PageInterceptor();
+ }
}
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/config/RedisConfiguration.java b/common/service-utils/src/main/java/cn/bunny/common/service/config/RedisConfiguration.java
index 72cce70..1b5c8d7 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/config/RedisConfiguration.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/config/RedisConfiguration.java
@@ -63,14 +63,12 @@ public class RedisConfiguration {
log.info("RedisConfiguration===>解决cache(@Cacheable)把数据缓存到redis中的value是乱码问题");
// 配置序列化
- RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
- config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()))
+ RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
+ .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()))
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jsonRedisSerializer()))
- .entryTtl(Duration.ofDays(365));
+ .entryTtl(Duration.ofDays(30));
- RedisCacheManager cacheManager = RedisCacheManager.builder(factory)
- .cacheDefaults(config).build();
- return cacheManager;
+ return RedisCacheManager.builder(factory).cacheDefaults(config).build();
}
/**
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/context/BaseContext.java b/common/service-utils/src/main/java/cn/bunny/common/service/context/BaseContext.java
index 2910d37..1a01c70 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/context/BaseContext.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/context/BaseContext.java
@@ -3,8 +3,8 @@ package cn.bunny.common.service.context;
public class BaseContext {
private static final ThreadLocal userId = new ThreadLocal<>();
private static final ThreadLocal username = new ThreadLocal();
- private static final ThreadLocal wareId = new ThreadLocal<>();
private static final ThreadLocal adminId = new ThreadLocal<>();
+ private static final ThreadLocal adminName = new ThreadLocal<>();
// 用户id相关
public static Long getUserId() {
@@ -15,10 +15,6 @@ public class BaseContext {
userId.set(_userId);
}
- public static void removeUserId() {
- userId.remove();
- }
-
public static String getUsername() {
return username.get();
}
@@ -27,6 +23,11 @@ public class BaseContext {
username.set(_username);
}
+ public static void removeUser() {
+ username.remove();
+ userId.remove();
+ }
+
// adminId 相关
public static Long getAdminId() {
return adminId.get();
@@ -36,7 +37,16 @@ public class BaseContext {
adminId.set(_adminId);
}
- public static void removeAdminId() {
+ public static String getAdminName() {
+ return adminName.get();
+ }
+
+ public static void setAdminName(String _adminName) {
+ adminName.set(_adminName);
+ }
+
+ public static void removeAdmin() {
+ adminName.remove();
adminId.remove();
}
}
\ No newline at end of file
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/exception/BunnyException.java b/common/service-utils/src/main/java/cn/bunny/common/service/exception/BunnyException.java
index c755c16..1012971 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/exception/BunnyException.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/exception/BunnyException.java
@@ -1,6 +1,6 @@
package cn.bunny.common.service.exception;
-import cn.bunny.common.result.enums.ResultCodeEnum;
+import cn.bunny.result.ResultCodeEnum;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java b/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java
index 34e61cb..345d29b 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java
@@ -1,8 +1,9 @@
package cn.bunny.common.service.exception;
-import cn.bunny.common.result.constant.CommonMessageConstant;
-import cn.bunny.common.result.enums.ResultCodeEnum;
-import cn.bunny.common.result.utils.Result;
+
+import cn.bunny.result.Result;
+import cn.bunny.result.ResultCodeEnum;
+import cn.bunny.result.constant.ExceptionConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -58,7 +59,7 @@ public class GlobalExceptionHandler {
public Result error(AccessDeniedException exception) throws AccessDeniedException {
log.error("GlobalExceptionHandler===>spring security异常:{}", exception.getMessage());
- return Result.error(ResultCodeEnum.PERMISSION);
+ return Result.error(ResultCodeEnum.SERVICE_ERROR);
}
// 处理SQL异常
@@ -72,10 +73,10 @@ public class GlobalExceptionHandler {
// 截取用户名
String username = message.split(" ")[2];
// 错误信息
- String errorMessage = username + CommonMessageConstant.ALREADY_EXISTS;
+ String errorMessage = username + ExceptionConstant.ALREADY_USER_Exception;
return Result.error(errorMessage);
} else {
- return Result.error(CommonMessageConstant.UNKNOWN_ERROR);
+ return Result.error(ExceptionConstant.UNKNOWN_Exception);
}
}
}
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/utils/JwtHelper.java b/common/service-utils/src/main/java/cn/bunny/common/service/utils/JwtHelper.java
index 7215eb1..cbce3e2 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/utils/JwtHelper.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/utils/JwtHelper.java
@@ -25,10 +25,11 @@ public class JwtHelper {
Jws claimsJws = Jwts.parser().setSigningKey(tokenSignKey).parseClaimsJws(token);
Claims claims = claimsJws.getBody();
- return (Long) claims.get("userId");
+
+ return Long.valueOf(String.valueOf(claims.get("userId")));
}
- public static String getUserName(String token) {
+ public static String getUsername(String token) {
if (!StringUtils.hasText(token)) return "";
Jws claimsJws = Jwts.parser().setSigningKey(tokenSignKey).parseClaimsJws(token);
@@ -44,6 +45,6 @@ public class JwtHelper {
String token = JwtHelper.createToken(7L, "admin", 7);
// token = "eyJhbGciOiJIUzI1NiIsInppcCI6IkdaSVAifQ.H4sIAAAAAAAA_6tWKi5NUrJScirNy6vUDQ12DVLSUUqtKFCyMjQ3MTc0NrYwNddRKi1OLfJMUbKyNDIwNLQwMDAzg4j5JeamAjUbGhtaWhoYGJqaOBQW6iXn5yrVAgCrO9jLWAAAAA.DS1wYprXGoIMrjtUWfDSN9AG5gWoRZ17oAgcvC0kwag";
System.out.println(JwtHelper.getUserId(token));
- System.out.println(JwtHelper.getUserName(token));
+ System.out.println(JwtHelper.getUsername(token));
}
}
\ No newline at end of file
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/utils/ResponseUtil.java b/common/service-utils/src/main/java/cn/bunny/common/service/utils/ResponseUtil.java
index 773eebe..2f3f1f2 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/utils/ResponseUtil.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/utils/ResponseUtil.java
@@ -1,6 +1,6 @@
package cn.bunny.common.service.utils;
-import cn.bunny.common.result.utils.Result;
+import cn.bunny.result.Result;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import jakarta.servlet.http.HttpServletResponse;
diff --git a/model/pom.xml b/model/pom.xml
index 31dcd47..4fff05a 100644
--- a/model/pom.xml
+++ b/model/pom.xml
@@ -3,7 +3,7 @@
4.0.0
cn.bunny
- bunny-template-mirror-server
+ bunny-mirror-server
0.0.1-SNAPSHOT
@@ -42,6 +42,12 @@
com.github.xiaoymin
knife4j-openapi3-jakarta-spring-boot-starter
+
+
+ io.swagger
+ swagger-annotations
+ 1.6.14
+
diff --git a/model/src/main/java/cn/bunny/dto/article/LoadArticleListDto.java b/model/src/main/java/cn/bunny/dto/article/LoadArticleListDto.java
new file mode 100644
index 0000000..c3b5e3b
--- /dev/null
+++ b/model/src/main/java/cn/bunny/dto/article/LoadArticleListDto.java
@@ -0,0 +1,22 @@
+package cn.bunny.dto.article;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Objects;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class LoadArticleListDto {
+ private Integer pBoardId;
+ private Integer boardId;
+ private Integer orderType = 1;
+
+ public void getOrderType(Integer orderType) {
+ this.orderType = Objects.requireNonNullElse(orderType, 1);
+ }
+}
diff --git a/model/src/main/java/cn/bunny/dto/article/LoadUserArticleDto.java b/model/src/main/java/cn/bunny/dto/article/LoadUserArticleDto.java
new file mode 100644
index 0000000..a644f4f
--- /dev/null
+++ b/model/src/main/java/cn/bunny/dto/article/LoadUserArticleDto.java
@@ -0,0 +1,15 @@
+package cn.bunny.dto.article;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class LoadUserArticleDto {
+ private Long userId;
+ private Integer type;
+}
diff --git a/model/src/main/java/cn/bunny/dto/common/CommentPostDto.java b/model/src/main/java/cn/bunny/dto/common/CommentPostDto.java
new file mode 100644
index 0000000..18a0ec4
--- /dev/null
+++ b/model/src/main/java/cn/bunny/dto/common/CommentPostDto.java
@@ -0,0 +1,19 @@
+package cn.bunny.dto.common;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.web.multipart.MultipartFile;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class CommentPostDto {
+ private String articleId;
+ private Integer pCommentId;
+ private String content;
+ private MultipartFile image;
+ private Long replyUserId;
+}
diff --git a/model/src/main/java/cn/bunny/dto/common/CommentQueryDto.java b/model/src/main/java/cn/bunny/dto/common/CommentQueryDto.java
new file mode 100644
index 0000000..2ad59bc
--- /dev/null
+++ b/model/src/main/java/cn/bunny/dto/common/CommentQueryDto.java
@@ -0,0 +1,16 @@
+package cn.bunny.dto.common;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class CommentQueryDto {
+ private String articleId;
+ // time 时间查询、goods 点赞数量
+ private String orderType;
+}
diff --git a/model/src/main/java/cn/bunny/dto/common/QueryTopTypeDto.java b/model/src/main/java/cn/bunny/dto/common/QueryTopTypeDto.java
new file mode 100644
index 0000000..843a9de
--- /dev/null
+++ b/model/src/main/java/cn/bunny/dto/common/QueryTopTypeDto.java
@@ -0,0 +1,15 @@
+package cn.bunny.dto.common;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class QueryTopTypeDto {
+ private Long commentId;
+ private Integer topType;
+}
diff --git a/model/src/main/java/cn/bunny/dto/email/EmailTemplateDto.java b/model/src/main/java/cn/bunny/dto/email/EmailTemplateDto.java
new file mode 100644
index 0000000..734a1c0
--- /dev/null
+++ b/model/src/main/java/cn/bunny/dto/email/EmailTemplateDto.java
@@ -0,0 +1,21 @@
+package cn.bunny.dto.email;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class EmailTemplateDto {
+ // 模板名称
+ private String templateName;
+ // 主题
+ private String subject;
+ // 邮件内容
+ private String body;
+ // 邮件类型
+ private String type;
+}
diff --git a/model/src/main/java/cn/bunny/dto/email/EmailUsersDto.java b/model/src/main/java/cn/bunny/dto/email/EmailUsersDto.java
new file mode 100644
index 0000000..be3b1b4
--- /dev/null
+++ b/model/src/main/java/cn/bunny/dto/email/EmailUsersDto.java
@@ -0,0 +1,30 @@
+package cn.bunny.dto.email;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 添加邮箱用户
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class EmailUsersDto {
+ // 修改时需要传
+ private Long id;
+ // 邮箱
+ private String email;
+ // 密码
+ private String password;
+ // SMTP服务器
+ private String host;
+ // 端口号
+ private Integer port;
+ // 邮箱协议
+ private Integer smtpAgreement;
+ // 是否为默认邮件
+ private Boolean isDefault;
+}
diff --git a/model/src/main/java/cn/bunny/dto/LoginDto.java b/model/src/main/java/cn/bunny/dto/user/LoginDto.java
similarity index 73%
rename from model/src/main/java/cn/bunny/dto/LoginDto.java
rename to model/src/main/java/cn/bunny/dto/user/LoginDto.java
index c4073d3..1f4213b 100644
--- a/model/src/main/java/cn/bunny/dto/LoginDto.java
+++ b/model/src/main/java/cn/bunny/dto/user/LoginDto.java
@@ -1,4 +1,4 @@
-package cn.bunny.dto;
+package cn.bunny.dto.user;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -10,7 +10,10 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@Builder
public class LoginDto {
+ // 用户名
private String username;
// 密码
private String password;
+ // 邮箱验证码
+ private String emailCode;
}
diff --git a/model/src/main/java/cn/bunny/dto/user/RegisterDto.java b/model/src/main/java/cn/bunny/dto/user/RegisterDto.java
new file mode 100644
index 0000000..5a15b4d
--- /dev/null
+++ b/model/src/main/java/cn/bunny/dto/user/RegisterDto.java
@@ -0,0 +1,17 @@
+package cn.bunny.dto.user;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class RegisterDto {
+ private String email;
+ private String nickName;
+ private String password;
+ private String code;
+}
diff --git a/model/src/main/java/cn/bunny/dto/user/ResetPwdDto.java b/model/src/main/java/cn/bunny/dto/user/ResetPwdDto.java
new file mode 100644
index 0000000..490dbbc
--- /dev/null
+++ b/model/src/main/java/cn/bunny/dto/user/ResetPwdDto.java
@@ -0,0 +1,16 @@
+package cn.bunny.dto.user;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class ResetPwdDto {
+ private String email;
+ private String password;
+ private String emailCode;
+}
diff --git a/model/src/main/java/cn/bunny/dto/user/UserInfoDto.java b/model/src/main/java/cn/bunny/dto/user/UserInfoDto.java
new file mode 100644
index 0000000..4bbbc79
--- /dev/null
+++ b/model/src/main/java/cn/bunny/dto/user/UserInfoDto.java
@@ -0,0 +1,22 @@
+package cn.bunny.dto.user;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * 修改用户信息
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class UserInfoDto {
+ private String nickName;
+ private String password;
+ private MultipartFile avatar;
+ private Integer sex;
+ private String personDescription;
+}
diff --git a/model/src/main/java/cn/bunny/dto/user/UserIntegralRecordDto.java b/model/src/main/java/cn/bunny/dto/user/UserIntegralRecordDto.java
new file mode 100644
index 0000000..8320e0a
--- /dev/null
+++ b/model/src/main/java/cn/bunny/dto/user/UserIntegralRecordDto.java
@@ -0,0 +1,15 @@
+package cn.bunny.dto.user;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class UserIntegralRecordDto {
+ private String startDate;
+ private String endDate;
+}
diff --git a/model/src/main/java/cn/bunny/dto/user/UserMessageDto.java b/model/src/main/java/cn/bunny/dto/user/UserMessageDto.java
new file mode 100644
index 0000000..575bd73
--- /dev/null
+++ b/model/src/main/java/cn/bunny/dto/user/UserMessageDto.java
@@ -0,0 +1,14 @@
+package cn.bunny.dto.user;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class UserMessageDto {
+ private String type;
+}
diff --git a/model/src/main/java/cn/bunny/entity/base/BaseEntity.java b/model/src/main/java/cn/bunny/entity/base/BaseEntity.java
index 505cfcd..451c19b 100644
--- a/model/src/main/java/cn/bunny/entity/base/BaseEntity.java
+++ b/model/src/main/java/cn/bunny/entity/base/BaseEntity.java
@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
-import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@@ -15,19 +15,26 @@ import java.util.Map;
@Data
public class BaseEntity implements Serializable {
- @TableId(type = IdType.ASSIGN_ID)
- @Schema(description = "唯一标识")
+ @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @ApiModelProperty("唯一标识")
private Long id;
@TableField("create_time")
+ @ApiModelProperty("创建时间")
private Date createTime;
@TableField("update_time")
+ @ApiModelProperty("更新时间")
private Date updateTime;
+ @TableField("update_user")
+ @ApiModelProperty("操作用户ID")
+ private Long updateUser;
+
@TableLogic
@TableField("is_deleted")
- private Integer isDeleted;
+ @ApiModelProperty("是否被删除")
+ private Boolean isDeleted;
@TableField(exist = false)
private Map param = new HashMap<>();
diff --git a/model/src/main/java/cn/bunny/entity/system/User.java b/model/src/main/java/cn/bunny/entity/system/User.java
deleted file mode 100644
index c03718a..0000000
--- a/model/src/main/java/cn/bunny/entity/system/User.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package cn.bunny.entity.system;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.experimental.Accessors;
-
-import java.io.Serializable;
-import java.time.LocalDateTime;
-
-/**
- *
- * 用户信息
- *
- *
- * @author Bunny
- * @since 2024-05-13
- */
-@Getter
-@Setter
-@Accessors(chain = true)
-@Schema(description = "用户信息")
-public class User implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @Schema(description = "用户ID")
- @TableId(value = "user_id", type = IdType.AUTO)
- private String userId;
-
- @Schema(description = "昵称")
- private String nickName;
-
- @Schema(description = "邮箱")
- private String email;
-
- @Schema(description = "密码")
- private String password;
-
- @Schema(description = "0:女 1:男")
- private Integer sex;
-
- @Schema(description = "个人描述")
- private String personDescription;
-
- @Schema(description = "加入时间")
- private LocalDateTime joinTime;
-
- @Schema(description = "最后登录时间")
- private LocalDateTime lastLoginTime;
-
- @Schema(description = "最后登录IP")
- private String lastLoginIp;
-
- @Schema(description = "最后登录ip地址")
- private String lastLoginIpAddress;
-
- @Schema(description = "积分")
- private Integer totalIntegral;
-
- @Schema(description = "当前积分")
- private Integer currentIntegral;
-
- @Schema(description = "0:禁用 1:正常")
- private Byte status;
-}
diff --git a/model/src/main/java/cn/bunny/entity/system/UserIntegralRecord.java b/model/src/main/java/cn/bunny/entity/system/UserIntegralRecord.java
deleted file mode 100644
index ac5ea9c..0000000
--- a/model/src/main/java/cn/bunny/entity/system/UserIntegralRecord.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package cn.bunny.entity.system;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.experimental.Accessors;
-
-import java.io.Serializable;
-import java.time.LocalDateTime;
-
-/**
- *
- * 用户积分记录表
- *
- *
- * @author Bunny
- * @since 2024-05-13
- */
-@Getter
-@Setter
-@Accessors(chain = true)
-@TableName("user_integral_record")
-@Schema(description = "用户积分记录表")
-public class UserIntegralRecord implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @Schema(description = "记录ID")
- @TableId(value = "record_id", type = IdType.AUTO)
- private Integer recordId;
-
- @Schema(description = "用户ID")
- private String userId;
-
- @Schema(description = "操作类型")
- private Byte operType;
-
- @Schema(description = "积分")
- private Integer integral;
-
- @Schema(description = "创建时间")
- private LocalDateTime createTime;
-}
diff --git a/model/src/main/java/cn/bunny/entity/system/admin/AdminPower.java b/model/src/main/java/cn/bunny/entity/system/admin/AdminPower.java
new file mode 100644
index 0000000..2544ab8
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/admin/AdminPower.java
@@ -0,0 +1,58 @@
+package cn.bunny.entity.system.admin;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ *
+ *
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-18
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@TableName("admin_power")
+@ApiModel(value = "AdminPower对象", description = "")
+public class AdminPower implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("权限ID")
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ @ApiModelProperty("权限名称")
+ private String powerName;
+
+ @ApiModelProperty("权限编码")
+ private String powerCode;
+
+ @ApiModelProperty("描述")
+ private String description;
+
+ @ApiModelProperty("创建时间")
+ private LocalDateTime createTime;
+
+ @ApiModelProperty("更新时间")
+ private LocalDateTime updateTime;
+
+ @ApiModelProperty("更新用户")
+ private String updateUser;
+
+ @ApiModelProperty("是否删除,0-未删除,1-已删除")
+ private Byte isDelete;
+}
diff --git a/model/src/main/java/cn/bunny/entity/system/UserRole.java b/model/src/main/java/cn/bunny/entity/system/admin/AdminRole.java
similarity index 53%
rename from model/src/main/java/cn/bunny/entity/system/UserRole.java
rename to model/src/main/java/cn/bunny/entity/system/admin/AdminRole.java
index c1ba58c..59c36f4 100644
--- a/model/src/main/java/cn/bunny/entity/system/UserRole.java
+++ b/model/src/main/java/cn/bunny/entity/system/admin/AdminRole.java
@@ -1,9 +1,10 @@
-package cn.bunny.entity.system;
+package cn.bunny.entity.system.admin;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@@ -17,31 +18,38 @@ import java.time.LocalDateTime;
*
*
* @author Bunny
- * @since 2024-05-13
+ * @since 2024-05-18
*/
@Getter
@Setter
@Accessors(chain = true)
-@TableName("user_role")
-@Schema(description = "UserRole对象")
-public class UserRole implements Serializable {
+@TableName("admin_role")
+@ApiModel(value = "AdminRole对象", description = "")
+public class AdminRole implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private String id;
- private String userId;
-
+ @ApiModelProperty("角色名称")
private String roleName;
+ @ApiModelProperty("描述")
private String description;
+ @ApiModelProperty("角色代码")
private String roleCode;
- @Schema(description = "创建时间")
+ @ApiModelProperty("创建时间")
private LocalDateTime createTime;
- @Schema(description = "更新时间")
+ @ApiModelProperty("更新时间")
private LocalDateTime updateTime;
+
+ @ApiModelProperty("操作用户")
+ private String updateUser;
+
+ @ApiModelProperty("是否删除")
+ private Byte isDeleted;
}
diff --git a/model/src/main/java/cn/bunny/entity/system/admin/AdminRolePower.java b/model/src/main/java/cn/bunny/entity/system/admin/AdminRolePower.java
new file mode 100644
index 0000000..26370de
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/admin/AdminRolePower.java
@@ -0,0 +1,56 @@
+package cn.bunny.entity.system.admin;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ *
+ *
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-18
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@TableName("admin_role_power")
+@ApiModel(value = "AdminRolePower对象", description = "")
+public class AdminRolePower implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("ID")
+ @TableId(value = "id", type = IdType.AUTO)
+ private String id;
+
+ @ApiModelProperty("角色id")
+ private String roleId;
+
+ @ApiModelProperty("权限id")
+ private String powerId;
+
+ @ApiModelProperty("描述")
+ private String description;
+
+ @ApiModelProperty("创建时间")
+ private LocalDateTime createTime;
+
+ @ApiModelProperty("更新时间")
+ private LocalDateTime updateTime;
+
+ @ApiModelProperty("更新用户")
+ private String updateUser;
+
+ @ApiModelProperty("是否删除,0-未删除,1-已删除")
+ private Byte isDelete;
+}
diff --git a/model/src/main/java/cn/bunny/entity/system/admin/AdminUserRole.java b/model/src/main/java/cn/bunny/entity/system/admin/AdminUserRole.java
new file mode 100644
index 0000000..78f954f
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/admin/AdminUserRole.java
@@ -0,0 +1,56 @@
+package cn.bunny.entity.system.admin;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ *
+ *
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-18
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@TableName("admin_user_role")
+@ApiModel(value = "AdminUserRole对象", description = "")
+public class AdminUserRole implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("ID")
+ @TableId(value = "id", type = IdType.AUTO)
+ private String id;
+
+ @ApiModelProperty("用户id")
+ private String userId;
+
+ @ApiModelProperty("角色id")
+ private String roleId;
+
+ @ApiModelProperty("描述")
+ private String description;
+
+ @ApiModelProperty("创建时间")
+ private LocalDateTime createTime;
+
+ @ApiModelProperty("更新时间")
+ private LocalDateTime updateTime;
+
+ @ApiModelProperty("更新用户")
+ private String updateUser;
+
+ @ApiModelProperty("是否删除,0-未删除,1-已删除")
+ private Byte isDelete;
+}
diff --git a/model/src/main/java/cn/bunny/entity/system/admin/auth/AuthUserRole.java b/model/src/main/java/cn/bunny/entity/system/admin/auth/AuthUserRole.java
new file mode 100644
index 0000000..f1b3794
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/admin/auth/AuthUserRole.java
@@ -0,0 +1,21 @@
+package cn.bunny.entity.system.admin.auth;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class AuthUserRole {
+ // 用户id
+ private Long userId;
+ // 角色id
+ private Long roleId;
+ // 角色代码
+ private String roleCode;
+ // 描述
+ private String roleDescription;
+}
diff --git a/model/src/main/java/cn/bunny/entity/system/article/Article.java b/model/src/main/java/cn/bunny/entity/system/article/Article.java
new file mode 100644
index 0000000..fe9f84d
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/article/Article.java
@@ -0,0 +1,83 @@
+package cn.bunny.entity.system.article;
+
+import cn.bunny.entity.base.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ *
+ * 文章信息
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-17
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@ApiModel(value = "Article对象", description = "文章信息")
+public class Article extends BaseEntity implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("板块ID")
+ private Integer boardId;
+
+ @ApiModelProperty("板块名称")
+ private String boardName;
+
+ @ApiModelProperty("父级板块ID")
+ private Integer pBoardId;
+
+ @ApiModelProperty("父板块名称")
+ private String pBoardName;
+
+ @ApiModelProperty("用户ID")
+ private Long userId;
+
+ @ApiModelProperty("昵称")
+ private String nickName;
+
+ @ApiModelProperty("最后登录ip地址")
+ private String userIpAddress;
+
+ @ApiModelProperty("标题")
+ private String title;
+
+ @ApiModelProperty("封面")
+ private String cover;
+
+ @ApiModelProperty("内容")
+ private String content;
+
+ @ApiModelProperty("0:富文本编辑器 1:markdown编辑器")
+ private Byte editorType;
+
+ @ApiModelProperty("摘要")
+ private String summary;
+
+ @ApiModelProperty("阅读数量")
+ private Integer readCount;
+
+ @ApiModelProperty("点赞数")
+ private Integer goodCount;
+
+ @ApiModelProperty("评论数")
+ private Integer commentCount;
+
+ @ApiModelProperty("0未置顶 1:已置顶")
+ private Byte topType;
+
+ @ApiModelProperty("0:没有附件 1:有附件")
+ private Byte attachmentType;
+
+ @ApiModelProperty("-1已删除 0:待审核 1:已审核 ")
+ private Byte status;
+}
diff --git a/model/src/main/java/cn/bunny/entity/system/article/ForumComment.java b/model/src/main/java/cn/bunny/entity/system/article/ForumComment.java
new file mode 100644
index 0000000..bb3b0ff
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/article/ForumComment.java
@@ -0,0 +1,67 @@
+package cn.bunny.entity.system.article;
+
+import cn.bunny.entity.base.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ *
+ * 评论
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-17
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@TableName("forum_comment")
+@ApiModel(value = "ForumComment对象", description = "评论")
+public class ForumComment extends BaseEntity implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("父级评论ID")
+ private Long pCommentId;
+
+ @ApiModelProperty("文章ID")
+ private String articleId;
+
+ @ApiModelProperty("回复内容")
+ private String content;
+
+ @ApiModelProperty("图片")
+ private String imgPath;
+
+ @ApiModelProperty("用户ID")
+ private Long userId;
+
+ @ApiModelProperty("昵称")
+ private String nickName;
+
+ @ApiModelProperty("用户ip地址")
+ private String userIpAddress;
+
+ @ApiModelProperty("回复人ID")
+ private Long replyUserId;
+
+ @ApiModelProperty("回复人昵称")
+ private String replyNickName;
+
+ @ApiModelProperty("0:未置顶 1:置顶")
+ private Integer topType;
+
+ @ApiModelProperty("good数量")
+ private Integer goodCount;
+
+ @ApiModelProperty("0:待审核 1:已审核")
+ private Integer status;
+}
diff --git a/model/src/main/java/cn/bunny/entity/system/article/IntegralRecord.java b/model/src/main/java/cn/bunny/entity/system/article/IntegralRecord.java
new file mode 100644
index 0000000..b88f1e8
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/article/IntegralRecord.java
@@ -0,0 +1,40 @@
+package cn.bunny.entity.system.article;
+
+import cn.bunny.entity.base.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ *
+ * 用户积分记录表
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-17
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@TableName("integral_record")
+@ApiModel(value = "IntegralRecord对象", description = "用户积分记录表")
+public class IntegralRecord extends BaseEntity implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("用户ID")
+ private Long userId;
+
+ @ApiModelProperty("操作类型")
+ private Byte operType;
+
+ @ApiModelProperty("积分")
+ private Integer integral;
+}
diff --git a/model/src/main/java/cn/bunny/entity/system/article/LikeRecord.java b/model/src/main/java/cn/bunny/entity/system/article/LikeRecord.java
new file mode 100644
index 0000000..8d27cb9
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/article/LikeRecord.java
@@ -0,0 +1,43 @@
+package cn.bunny.entity.system.article;
+
+import cn.bunny.entity.base.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ *
+ * 点赞记录
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-17
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@TableName("like_record")
+@ApiModel(value = "LikeRecord对象", description = "点赞记录")
+public class LikeRecord extends BaseEntity implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("操作类型0:文章点赞 1:评论点赞")
+ private Byte opType;
+
+ @ApiModelProperty("主体ID")
+ private String objectId;
+
+ @ApiModelProperty("用户ID")
+ private Long userId;
+
+ @ApiModelProperty("主体作者ID")
+ private Long authorUserId;
+}
diff --git a/model/src/main/java/cn/bunny/entity/system/board/ForumBoard.java b/model/src/main/java/cn/bunny/entity/system/board/ForumBoard.java
new file mode 100644
index 0000000..0fad48c
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/board/ForumBoard.java
@@ -0,0 +1,49 @@
+package cn.bunny.entity.system.board;
+
+import cn.bunny.entity.base.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ *
+ * 文章板块信息
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-19
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@TableName("forum_board")
+@ApiModel(value = "ForumBoard对象", description = "文章板块信息")
+public class ForumBoard extends BaseEntity implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("父级板块ID")
+ private Long parentId;
+
+ @ApiModelProperty("板块名")
+ private String boardName;
+
+ @ApiModelProperty("封面")
+ private String cover;
+
+ @ApiModelProperty("描述")
+ private String boardDesc;
+
+ @ApiModelProperty("排序")
+ private Integer sort;
+
+ @ApiModelProperty("0:只允许管理员发帖 1:任何人可以发帖")
+ private Boolean postType;
+}
diff --git a/model/src/main/java/cn/bunny/entity/email/EmailSend.java b/model/src/main/java/cn/bunny/entity/system/email/EmailSend.java
similarity index 93%
rename from model/src/main/java/cn/bunny/entity/email/EmailSend.java
rename to model/src/main/java/cn/bunny/entity/system/email/EmailSend.java
index d3e69b7..1d2e779 100644
--- a/model/src/main/java/cn/bunny/entity/email/EmailSend.java
+++ b/model/src/main/java/cn/bunny/entity/system/email/EmailSend.java
@@ -1,4 +1,4 @@
-package cn.bunny.entity.email;
+package cn.bunny.entity.system.email;
import lombok.AllArgsConstructor;
import lombok.Builder;
diff --git a/model/src/main/java/cn/bunny/entity/email/EmailSendInit.java b/model/src/main/java/cn/bunny/entity/system/email/EmailSendInit.java
similarity index 90%
rename from model/src/main/java/cn/bunny/entity/email/EmailSendInit.java
rename to model/src/main/java/cn/bunny/entity/system/email/EmailSendInit.java
index acd6fb2..d2b3aa1 100644
--- a/model/src/main/java/cn/bunny/entity/email/EmailSendInit.java
+++ b/model/src/main/java/cn/bunny/entity/system/email/EmailSendInit.java
@@ -1,4 +1,4 @@
-package cn.bunny.entity.email;
+package cn.bunny.entity.system.email;
import lombok.AllArgsConstructor;
import lombok.Builder;
diff --git a/model/src/main/java/cn/bunny/entity/system/email/EmailTemplate.java b/model/src/main/java/cn/bunny/entity/system/email/EmailTemplate.java
new file mode 100644
index 0000000..18cb9c2
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/email/EmailTemplate.java
@@ -0,0 +1,42 @@
+package cn.bunny.entity.system.email;
+
+import cn.bunny.entity.base.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ *
+ *
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-19
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@TableName("email_template")
+@ApiModel(value = "EmailTemplate对象", description = "邮件模板")
+public class EmailTemplate extends BaseEntity implements Serializable {
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("模板名称")
+ private String templateName;
+
+ @ApiModelProperty("主题")
+ private String subject;
+
+ @ApiModelProperty("邮件内容")
+ private String body;
+
+ @ApiModelProperty("邮件类型")
+ private String type;
+}
diff --git a/model/src/main/java/cn/bunny/entity/system/email/EmailUsers.java b/model/src/main/java/cn/bunny/entity/system/email/EmailUsers.java
new file mode 100644
index 0000000..def87bb
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/email/EmailUsers.java
@@ -0,0 +1,49 @@
+package cn.bunny.entity.system.email;
+
+import cn.bunny.entity.base.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ *
+ * 邮箱发送表
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-17
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@TableName("email_users")
+@ApiModel(value = "EmailUsers对象", description = "邮箱发送表")
+public class EmailUsers extends BaseEntity implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("邮箱")
+ private String email;
+
+ @ApiModelProperty("密码")
+ private String password;
+
+ @ApiModelProperty("Host地址")
+ private String host;
+
+ @ApiModelProperty("端口号")
+ private Integer port;
+
+ @ApiModelProperty("邮箱协议")
+ private String smtpAgreement;
+
+ @ApiModelProperty("是否为默认邮件")
+ private Integer isDefault;
+}
diff --git a/model/src/main/java/cn/bunny/entity/system/file/Files.java b/model/src/main/java/cn/bunny/entity/system/file/Files.java
new file mode 100644
index 0000000..2597bb2
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/file/Files.java
@@ -0,0 +1,50 @@
+package cn.bunny.entity.system.file;
+
+import cn.bunny.entity.base.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ *
+ * 用于存储文件信息的数据表
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-17
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@ApiModel(value = "Files对象", description = "用于存储文件信息的数据表")
+public class Files extends BaseEntity implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("文章ID")
+ private Long articleId;
+
+ @ApiModelProperty("文件的名称")
+ private String filename;
+
+ @ApiModelProperty("文件在服务器上的存储路径")
+ private String filepath;
+
+ @ApiModelProperty("文件的大小,以字节为单位")
+ private Long fileSize;
+
+ @ApiModelProperty("文件的MIME类型")
+ private String fileType;
+
+ @ApiModelProperty("创建用户")
+ private Long createUser;
+
+ @ApiModelProperty("下载次数")
+ private Integer downloadCount;
+}
diff --git a/model/src/main/java/cn/bunny/entity/system/user/User.java b/model/src/main/java/cn/bunny/entity/system/user/User.java
new file mode 100644
index 0000000..33c086d
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/user/User.java
@@ -0,0 +1,61 @@
+package cn.bunny.entity.system.user;
+
+import cn.bunny.entity.base.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ *
+ * 用户信息
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-17
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "User对象", description = "用户信息")
+public class User extends BaseEntity implements Serializable {
+ @Serial
+ private static final long serialVersionUID = 1L;
+ @ApiModelProperty("昵称")
+ private String nickName;
+ @ApiModelProperty("邮箱")
+ private String email;
+ @ApiModelProperty("密码")
+ private String password;
+ @ApiModelProperty("头像")
+ private String avatar;
+ @ApiModelProperty("0:女 1:男")
+ private Byte sex;
+ @ApiModelProperty("个人描述")
+ private String personDescription;
+ @ApiModelProperty("加入时间")
+ private LocalDateTime joinTime;
+
+ @ApiModelProperty("最后登录时间")
+ private LocalDateTime lastLoginTime;
+
+ @ApiModelProperty("最后登录IP")
+ private String lastLoginIp;
+
+ @ApiModelProperty("最后登录ip地址")
+ private String lastLoginIpAddress;
+
+ @ApiModelProperty("积分")
+ private Integer totalIntegral;
+
+ @ApiModelProperty("当前积分")
+ private Integer currentIntegral;
+
+ @ApiModelProperty("0:禁用 1:正常")
+ private Byte status;
+}
diff --git a/model/src/main/java/cn/bunny/entity/system/user/UserMessage.java b/model/src/main/java/cn/bunny/entity/system/user/UserMessage.java
new file mode 100644
index 0000000..faa6cdf
--- /dev/null
+++ b/model/src/main/java/cn/bunny/entity/system/user/UserMessage.java
@@ -0,0 +1,58 @@
+package cn.bunny.entity.system.user;
+
+import cn.bunny.entity.base.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ *
+ * 用户消息
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-17
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@TableName("user_message")
+@ApiModel(value = "UserMessage对象", description = "用户消息")
+public class UserMessage extends BaseEntity implements Serializable {
+
+ @Serial
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("接收人用户ID")
+ private Long receivedUserId;
+
+ @ApiModelProperty("文章ID")
+ private String articleId;
+
+ @ApiModelProperty("文章标题")
+ private String articleTitle;
+
+ @ApiModelProperty("评论ID")
+ private Integer commentId;
+
+ @ApiModelProperty("发送人用户ID")
+ private Long sendUserId;
+
+ @ApiModelProperty("发送人昵称")
+ private String sendNickName;
+
+ @ApiModelProperty("sys:系统消息 reply:评论 likePost:文章点赞 likeComment:评论点赞 attachment:附件下载")
+ private String messageType;
+
+ @ApiModelProperty("消息内容")
+ private String messageContent;
+
+ @ApiModelProperty("1:未读 2:已读")
+ private Byte status;
+}
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/utils/Result.java b/model/src/main/java/cn/bunny/result/Result.java
similarity index 96%
rename from common/common-result/src/main/java/cn/bunny/common/result/utils/Result.java
rename to model/src/main/java/cn/bunny/result/Result.java
index 80c8119..6484684 100644
--- a/common/common-result/src/main/java/cn/bunny/common/result/utils/Result.java
+++ b/model/src/main/java/cn/bunny/result/Result.java
@@ -1,6 +1,5 @@
-package cn.bunny.common.result.utils;
+package cn.bunny.result;
-import cn.bunny.common.result.enums.ResultCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -64,7 +63,7 @@ public class Result {
* @return Result
*/
public static Result success() {
- return Result.success(null, ResultCodeEnum.SUCCESS);
+ return success(null, ResultCodeEnum.SUCCESS);
}
/**
diff --git a/model/src/main/java/cn/bunny/result/ResultCodeEnum.java b/model/src/main/java/cn/bunny/result/ResultCodeEnum.java
new file mode 100644
index 0000000..d391b55
--- /dev/null
+++ b/model/src/main/java/cn/bunny/result/ResultCodeEnum.java
@@ -0,0 +1,54 @@
+package cn.bunny.result;
+
+import lombok.Getter;
+
+/**
+ * 统一返回结果状态信息类
+ */
+@Getter
+public enum ResultCodeEnum {
+ // 成功操作 200
+ SUCCESS(200, "操作成功"),
+ SUCCESS_LOGOUT(200, "退出成功"),
+ EMAIL_CODE_REFRESH(200, "邮箱验证码已刷新"),
+ // 验证错误 201
+ USERNAME_NOT_EMPTY(201, "用户名不能为空"),
+ PASSWORD_NOT_EMPTY(201, "密码不能为空"),
+ EMAIL_CODE_NOT_EMPTY(201, "邮箱验证码不能为空"),
+ SEND_EMAIL_CODE_NOT_EMPTY(201, "请先发送邮箱验证码"),
+ EMAIL_CODE_NOT_MATCHING(201, "邮箱验证码不匹配"),
+ LOGIN_ERROR(201, "账号或密码错误"),
+ LOGIN_ERROR_USERNAME_PASSWORD_NOT_EMPTY(201, "登录信息不能为空"),
+ // 数据相关 206
+ ILLEGAL_REQUEST(206, "非法请求"),
+ REPEAT_SUBMIT(206, "重复提交"),
+ DATA_ERROR(206, "数据异常"),
+ // 身份过期 208
+ LOGIN_AUTH(208, "请先登陆"),
+ AUTHENTICATION_EXPIRED(208, "身份验证过期"),
+ SESSION_EXPIRATION(208, "会话过期"),
+ // 封禁 209
+ FAIL_NO_ACCESS_DENIED_USER_LOCKED(209, "该账户被封禁"),
+ THE_SAME_USER_HAS_LOGGED_IN(209, "相同用户已登录"),
+ // 提示错误
+ URL_ENCODE_ERROR(216, "URL编码失败"),
+ ILLEGAL_CALLBACK_REQUEST_ERROR(217, "非法回调请求"),
+ FETCH_USERINFO_ERROR(219, "获取用户信息失败"),
+ // 无权访问 403
+ FAIL_REQUEST_NOT_AUTH(403, "用户未认证"),
+ FAIL_NO_ACCESS_DENIED(403, "无权访问"),
+ FAIL_NO_ACCESS_DENIED_USER_OFFLINE(403, "用户强制下线"),
+ LOGGED_IN_FROM_ANOTHER_DEVICE(403, "没有权限访问"),
+ // 系统错误 500
+ SERVICE_ERROR(500, "服务异常"),
+ FAIL(500, "失败"),
+ ;
+
+ private final Integer code;
+ private final String message;
+
+ ResultCodeEnum(Integer code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+}
\ No newline at end of file
diff --git a/model/src/main/java/cn/bunny/result/constant/ExceptionConstant.java b/model/src/main/java/cn/bunny/result/constant/ExceptionConstant.java
new file mode 100644
index 0000000..7662b0e
--- /dev/null
+++ b/model/src/main/java/cn/bunny/result/constant/ExceptionConstant.java
@@ -0,0 +1,52 @@
+package cn.bunny.result.constant;
+
+import lombok.Data;
+
+
+@Data
+public class ExceptionConstant {
+ public static final String UNKNOWN_Exception = "未知错误";
+ public static final String TOKEN_IS_EMPTY = "token为空";
+ public static final String DATA_IS_EMPTY = "数据为空";
+ public static final String REQUEST_DATA_NOT_EMPTY_Exception = "请求参数为空";
+ public static final String UPDATE_DTO_IS_NULL_Exception = "修改参数为空";
+ public static final String ADD_DATA_IS_EMPTY_Exception = "添加数据为空";
+ public static final String DELETE_ID_IS_NOT_EMPTY_Exception = "删除id不能为空";
+ // 文章操作相关
+ public static final String DO_LIKE_COMMENT_NOT_EXIST = "点赞内容不存在";
+ public static final String REPLY_USER_EMPTY_EXCEPTION = "回复的用户不存在";
+ public static final String REPLY_USER_ID_EMPTY_EXCEPTION = "回复的用户不能为空";
+ public static final String MENU_IS_NOT_EXIST_Exception = "菜单不存在";
+ public static final String POST_COMMENT_EMPTY_Exception = "评论内容不能为空";
+ public static final String ARTICLE_ID_NOT_EMPTY_Exception = "文章id不能为空";
+ public static final String UPDATE_ID_IS_NOT_EMPTY_Exception = "修改id不能为空";
+ public static final String CANNOT_TOP_OTHER_USER = "不能操作此内容";
+ public static final String ARTICLE_NOT_FOUND_EXCEPTION = "文章未找到";
+ // 登录相关
+ public static final String USER_TOKEN_OUT_OF_DATE_Exception = "用户登录过期";
+ public static final String LOGIN_DTO_IS_EMPTY_Exception = "登录参数不能为空";
+ public static final String LOGIN_FAILED_Exception = "登录失败";
+ // 账号相关
+ public static final String ACCOUNT_NOT_FOUND_Exception = "账号不存在";
+ public static final String ACCOUNT_LOCKED_Exception = "账号被锁定";
+ // 用户相关
+ public static final String USER_NOT_LOGIN_Exception = "用户未登录";
+ public static final String USERNAME_IS_EMPTY_Exception = "用户名不能为空";
+ public static final String ALREADY_USER_Exception = "用户已存在";
+ public static final String USER_NOT_FOUND_Exception = "用户不存在";
+ // 密码相关
+ public static final String PASSWORD_Exception = "密码错误";
+ public static final String PASSWORD_NOT_EMPTY_Exception = "密码不能为空";
+ public static final String OLD_PASSWORD_Exception = "旧密码不匹配";
+ public static final String PASSWORD_EDIT_Exception = "密码修改失败";
+ public static final String OLD_PASSWORD_SAME_NEW_PASSWORD_Exception = "旧密码与新密码相同";
+ // 验证码错误
+ public static final String PLEASE_SEND_EMAIL_CODE_Exception = "请先发送验证码";
+ public static final String MESSAGE_CODE_NOT_PASS_Exception = "短信验证码未过期";
+ public static final String MESSAGE_CODE_UNAUTHORIZED_Exception = "短信验证码未授权,请联系管理员";
+ public static final String VERIFICATION_CODE_ERROR_Exception = "验证码错误";
+ public static final String CAPTCHA_IS_EMPTY_Exception = "验证码不能为空";
+ public static final String KEY_IS_EMPTY_Exception = "验证码key不能为空";
+ public static final String VERIFICATION_CODE_DOES_NOT_MATCH_Exception = "验证码不匹配";
+ public static final String VERIFICATION_CODE_IS_EMPTY_Exception = "验证码失效或不存在";
+}
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/constant/MinioMessageConstant.java b/model/src/main/java/cn/bunny/result/constant/FileMessageConstant.java
similarity index 76%
rename from common/common-result/src/main/java/cn/bunny/common/result/constant/MinioMessageConstant.java
rename to model/src/main/java/cn/bunny/result/constant/FileMessageConstant.java
index f2aee77..db799c7 100644
--- a/common/common-result/src/main/java/cn/bunny/common/result/constant/MinioMessageConstant.java
+++ b/model/src/main/java/cn/bunny/result/constant/FileMessageConstant.java
@@ -1,11 +1,15 @@
-package cn.bunny.common.result.constant;
+package cn.bunny.result.constant;
import lombok.Data;
@Data
-public class MinioMessageConstant {
+public class FileMessageConstant {
+ public static final String DOWNLOAD_BUCKET_EXCEPTION = "下载文件失败";
+ public static final String FILE_UPLOAD_EXCEPTION = "文件上传失败";
public static final String BUCKET_EXISTS_EXCEPTION = "查询文化部对象失败";
public static final String DELETE_BUCKET_EXCEPTION = "删除文件对象失败";
+ public static final String FILE_IS_EMPTY = "文件信息为空";
+ public static final String FILE_IS_NOT_EXITS = "文件信息为空";
public static final String GET_BUCKET_EXCEPTION = "获取文件信息失败";
public static final String QUERY_BUCKET_EXCEPTION = "查询文件信息失败";
public static final String CREATE_BUCKET_EXCEPTION = "创建文件对象失败";
@@ -14,6 +18,4 @@ public class MinioMessageConstant {
public static final String COPY_BUCKET_EXCEPTION = "复制文件内容失败";
public static final String DISABLE_BUCKET_EXCEPTION = "禁用文件失败";
public static final String ENABLE_BUCKET_EXCEPTION = "启用文件失败";
- public static final String DOWNLOAD_BUCKET_EXCEPTION = "下载文件失败";
- public static final String UPLOAD_BUCKET_EXCEPTION = "上传文件失败";
}
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/constant/LocalDateTimeConstant.java b/model/src/main/java/cn/bunny/result/constant/LocalDateTimeConstant.java
similarity index 89%
rename from common/common-result/src/main/java/cn/bunny/common/result/constant/LocalDateTimeConstant.java
rename to model/src/main/java/cn/bunny/result/constant/LocalDateTimeConstant.java
index ee3c13e..b0c4d40 100644
--- a/common/common-result/src/main/java/cn/bunny/common/result/constant/LocalDateTimeConstant.java
+++ b/model/src/main/java/cn/bunny/result/constant/LocalDateTimeConstant.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.result.constant;
+package cn.bunny.result.constant;
import lombok.Data;
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/constant/MailMessageConstant.java b/model/src/main/java/cn/bunny/result/constant/MailMessageConstant.java
similarity index 77%
rename from common/common-result/src/main/java/cn/bunny/common/result/constant/MailMessageConstant.java
rename to model/src/main/java/cn/bunny/result/constant/MailMessageConstant.java
index 202d7ba..c2410ac 100644
--- a/common/common-result/src/main/java/cn/bunny/common/result/constant/MailMessageConstant.java
+++ b/model/src/main/java/cn/bunny/result/constant/MailMessageConstant.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.result.constant;
+package cn.bunny.result.constant;
import lombok.Data;
@@ -11,4 +11,5 @@ public class MailMessageConstant {
public static final String ADDRESS_NOT_NULL = "收件人不能为空";
public static final String TITLE_NOT_NULL = "标题不能为空";
public static final String SEND_MESSAGE_NOT_NULL = "发送消息不能为空";
+ public static final String EMAIL_CONFIG_NOT_FOUND = "邮箱配置为空";
}
diff --git a/model/src/main/java/cn/bunny/result/constant/RedisUserConstant.java b/model/src/main/java/cn/bunny/result/constant/RedisUserConstant.java
new file mode 100644
index 0000000..9772191
--- /dev/null
+++ b/model/src/main/java/cn/bunny/result/constant/RedisUserConstant.java
@@ -0,0 +1,67 @@
+package cn.bunny.result.constant;
+
+import lombok.Data;
+
+/**
+ * Redis用户前缀设置
+ */
+@Data
+public class RedisUserConstant {
+ // 管理员用户
+ public static final String ADMIN_LOGIN_INFO_PREFIX = "ADMIN::LOGIN_INFO::";
+ public static final String ADMIN_EMAIL_CODE_PREFIX = "ADMIN::EMAIL_CODE::";
+ // 普通用户
+ public static final String USER_LOGIN_INFO_PREFIX = "USER::LOGIN_INFO::";
+ public static final String USER_EMAIL_CODE_PREFIX = "USER::EMAIL_CODE::";
+ public static final String USER_DO_LIKE_PREFIX = "USER::doLike::";
+
+ /**
+ * * 管理员用户登录信息
+ *
+ * @param adminUser 管理员用户
+ * @return 登录信息key
+ */
+ public static String getAdminLoginInfoPrefix(String adminUser) {
+ return ADMIN_LOGIN_INFO_PREFIX + adminUser;
+ }
+
+ /**
+ * * 管理员用户邮箱验证码
+ *
+ * @param adminUser 管理员用户
+ * @return 管理员用户邮箱验证码key
+ */
+ public static String getAdminUserEmailCodePrefix(String adminUser) {
+ return ADMIN_EMAIL_CODE_PREFIX + adminUser;
+ }
+
+ /**
+ * * 用户登录信息
+ *
+ * @param user 用户名
+ * @return 登录信息key
+ */
+ public static String getUserLoginInfoPrefix(String user) {
+ return USER_LOGIN_INFO_PREFIX + user;
+ }
+
+ /**
+ * * 用户邮箱验证码
+ *
+ * @param user 用户名
+ * @return 用户邮箱验证码key
+ */
+ public static String getUserEmailCodePrefix(String user) {
+ return USER_EMAIL_CODE_PREFIX + user;
+ }
+
+ /**
+ * * 用户点赞操作
+ *
+ * @param user 用户名
+ * @return 用户点赞key
+ */
+ public static String getUserDoLikePrefix(String user) {
+ return USER_DO_LIKE_PREFIX + user;
+ }
+}
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/constant/SQLAutoFillConstant.java b/model/src/main/java/cn/bunny/result/constant/SQLAutoFillConstant.java
similarity index 90%
rename from common/common-result/src/main/java/cn/bunny/common/result/constant/SQLAutoFillConstant.java
rename to model/src/main/java/cn/bunny/result/constant/SQLAutoFillConstant.java
index 07614cd..6b09482 100644
--- a/common/common-result/src/main/java/cn/bunny/common/result/constant/SQLAutoFillConstant.java
+++ b/model/src/main/java/cn/bunny/result/constant/SQLAutoFillConstant.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.result.constant;
+package cn.bunny.result.constant;
import lombok.Data;
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/constant/SecurityConstant.java b/model/src/main/java/cn/bunny/result/constant/SecurityConstant.java
similarity index 52%
rename from common/common-result/src/main/java/cn/bunny/common/result/constant/SecurityConstant.java
rename to model/src/main/java/cn/bunny/result/constant/SecurityConstant.java
index b0df3f3..a26c0b4 100644
--- a/common/common-result/src/main/java/cn/bunny/common/result/constant/SecurityConstant.java
+++ b/model/src/main/java/cn/bunny/result/constant/SecurityConstant.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.result.constant;
+package cn.bunny.result.constant;
import lombok.Data;
@@ -7,6 +7,7 @@ import java.util.List;
@Data
public class SecurityConstant {
- public static String[] annotations = {"/", "/test/**", "/diagram-viewer/**", "/editor-app/**", "/*.html", "/admin/system/index/login", "/favicon.ico", "/swagger-resources/**", "/webjars/**", "/v3/**", "/swagger-ui.html/**", "/doc.html"};
+ public static String[] annotations = {"/", "/test/**", "/diagram-viewer/**", "/editor-app/**", "/*.html",
+ "/*/*/noAuth/**", "/*/noAuth/**", "/favicon.ico", "/swagger-resources/**", "/webjars/**", "/v3/**", "/swagger-ui.html/**", "/doc.html"};
public static List annotationsList = Arrays.asList(annotations);
}
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/constant/StatusConstant.java b/model/src/main/java/cn/bunny/result/constant/StatusConstant.java
similarity index 84%
rename from common/common-result/src/main/java/cn/bunny/common/result/constant/StatusConstant.java
rename to model/src/main/java/cn/bunny/result/constant/StatusConstant.java
index e8e8372..c530625 100644
--- a/common/common-result/src/main/java/cn/bunny/common/result/constant/StatusConstant.java
+++ b/model/src/main/java/cn/bunny/result/constant/StatusConstant.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.result.constant;
+package cn.bunny.result.constant;
import lombok.Data;
diff --git a/common/common-result/src/main/java/cn/bunny/common/result/constant/UserConstant.java b/model/src/main/java/cn/bunny/result/constant/UserConstant.java
similarity index 85%
rename from common/common-result/src/main/java/cn/bunny/common/result/constant/UserConstant.java
rename to model/src/main/java/cn/bunny/result/constant/UserConstant.java
index 3e57b10..d9f4832 100644
--- a/common/common-result/src/main/java/cn/bunny/common/result/constant/UserConstant.java
+++ b/model/src/main/java/cn/bunny/result/constant/UserConstant.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.result.constant;
+package cn.bunny.result.constant;
import lombok.Data;
diff --git a/model/src/main/java/cn/bunny/tree/AbstractTreeNode.java b/model/src/main/java/cn/bunny/tree/AbstractTreeNode.java
new file mode 100644
index 0000000..d5e7770
--- /dev/null
+++ b/model/src/main/java/cn/bunny/tree/AbstractTreeNode.java
@@ -0,0 +1,11 @@
+package cn.bunny.tree;
+
+import java.util.List;
+
+public interface AbstractTreeNode {
+ Long getId();
+
+ Long getParentId();
+
+ void setChildren(List extends AbstractTreeNode> children);
+}
diff --git a/model/src/main/java/cn/bunny/tree/TreeBuilder.java b/model/src/main/java/cn/bunny/tree/TreeBuilder.java
new file mode 100644
index 0000000..f85d419
--- /dev/null
+++ b/model/src/main/java/cn/bunny/tree/TreeBuilder.java
@@ -0,0 +1,29 @@
+package cn.bunny.tree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TreeBuilder {
+
+ public List buildTree(List nodeList) {
+ List tree = new ArrayList<>();
+ for (T node : nodeList) {
+ if (node.getParentId() == 0) {
+ node.setChildren(getChildren(node.getId(), nodeList));
+ tree.add(node);
+ }
+ }
+ return tree;
+ }
+
+ private List getChildren(Long nodeId, List nodeList) {
+ List children = new ArrayList<>();
+ for (T node : nodeList) {
+ if (node.getParentId().equals(nodeId)) {
+ node.setChildren(getChildren(node.getId(), nodeList));
+ children.add(node);
+ }
+ }
+ return children;
+ }
+}
diff --git a/model/src/main/java/cn/bunny/vo/email/EmailTemplateVo.java b/model/src/main/java/cn/bunny/vo/email/EmailTemplateVo.java
new file mode 100644
index 0000000..8cc34d0
--- /dev/null
+++ b/model/src/main/java/cn/bunny/vo/email/EmailTemplateVo.java
@@ -0,0 +1,19 @@
+package cn.bunny.vo.email;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class EmailTemplateVo {
+ // 模板名称
+ private String templateName;
+ // 主题
+ private String subject;
+ // 邮件内容
+ private String body;
+}
\ No newline at end of file
diff --git a/model/src/main/java/cn/bunny/vo/file/FileInfoVo.java b/model/src/main/java/cn/bunny/vo/file/FileInfoVo.java
new file mode 100644
index 0000000..349ccb1
--- /dev/null
+++ b/model/src/main/java/cn/bunny/vo/file/FileInfoVo.java
@@ -0,0 +1,32 @@
+package cn.bunny.vo.file;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 返回文件信息
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class FileInfoVo {
+ private Long id;
+ // 文章Id
+ private Long articleId;
+ // 文件的名称
+ private String filename;
+ // 文件在服务器上的存储路径
+ private String filepath;
+ // 文件的大小,以字节为单位
+ private Long fileSize;
+ // 文件大小
+ private String size;
+ // 文件的MIME类型
+ private String fileType;
+ // 上传人昵称
+ private String uploadNickname;
+ private Integer downloadCount;
+}
diff --git a/model/src/main/java/cn/bunny/vo/page/PageResult.java b/model/src/main/java/cn/bunny/vo/page/PageResult.java
new file mode 100644
index 0000000..feb66b2
--- /dev/null
+++ b/model/src/main/java/cn/bunny/vo/page/PageResult.java
@@ -0,0 +1,27 @@
+package cn.bunny.vo.page;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 封装分页查询结果
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class PageResult implements Serializable {
+ // 当前页
+ private Integer pageNo;
+ // 每页记录数
+ private Integer pageSize;
+ // 总记录数
+ private long total;
+ // 当前页数据集合
+ private List list;
+}
\ No newline at end of file
diff --git a/model/src/main/java/cn/bunny/vo/system/LoginVo.java b/model/src/main/java/cn/bunny/vo/system/LoginVo.java
deleted file mode 100644
index e884fc7..0000000
--- a/model/src/main/java/cn/bunny/vo/system/LoginVo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package cn.bunny.vo.system;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.time.LocalDateTime;
-
-/**
- * 用户登录返回内容
- */
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-@Builder
-public class LoginVo {
- private String userId;
- private String nickName;
- private String email;
- private Integer sex;
- private String personDescription;
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private LocalDateTime joinTime;
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private LocalDateTime lastLoginTime;
- private String lastLoginIp;
- private String lastLoginIpAddress;
- private Integer totalIntegral;
- private Integer currentIntegral;
- private Byte status;
- private String token;
-}
diff --git a/model/src/main/java/cn/bunny/vo/system/article/ForumArticleVo.java b/model/src/main/java/cn/bunny/vo/system/article/ForumArticleVo.java
new file mode 100644
index 0000000..6caaf01
--- /dev/null
+++ b/model/src/main/java/cn/bunny/vo/system/article/ForumArticleVo.java
@@ -0,0 +1,70 @@
+package cn.bunny.vo.system.article;
+
+import cn.bunny.vo.file.FileInfoVo;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class ForumArticleVo {
+ // 文章ID
+ private Long id;
+ // 板块ID
+ private Integer boardId;
+ // 父级板块ID
+ private Integer pBoardId;
+ // 板块名称
+ private String boardName;
+ // 父板块名称
+ private String pBoardName;
+ // 用户ID
+ private String userId;
+ // 昵称
+ private String nickName;
+ // 最后登录ip地址
+ private String userIpAddress;
+ // 标题
+ private String title;
+ // 封面
+ private String cover;
+ // 内容
+ private String content;
+ // 0:富文本编辑器 1:markdown编辑器
+ private Byte editorType;
+ // 摘要
+ private String summary;
+ // 发布时间
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @JsonSerialize(using = LocalDateTimeSerializer.class)
+ @JsonDeserialize(using = LocalDateTimeDeserializer.class)
+ private String createTime;
+ // 最后更新时间
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @JsonSerialize(using = LocalDateTimeSerializer.class)
+ @JsonDeserialize(using = LocalDateTimeDeserializer.class)
+ private String updateTime;
+ // 阅读数量
+ private Integer readCount;
+ // 点赞数
+ private Integer goodCount;
+ // 评论数
+ private Integer commentCount;
+ // 0未置顶 1:已置顶
+ private Byte topType;
+ // 0:没有附件 1:有附件
+ private Byte attachmentType;
+ // -1已删除 0:待审核 1:已审核
+ private Byte status;
+ private List fileInfo;
+}
diff --git a/model/src/main/java/cn/bunny/vo/system/board/ForumBoardVo.java b/model/src/main/java/cn/bunny/vo/system/board/ForumBoardVo.java
new file mode 100644
index 0000000..66c79e0
--- /dev/null
+++ b/model/src/main/java/cn/bunny/vo/system/board/ForumBoardVo.java
@@ -0,0 +1,29 @@
+package cn.bunny.vo.system.board;
+
+import cn.bunny.tree.AbstractTreeNode;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class ForumBoardVo implements AbstractTreeNode {
+ private Long id;
+ // 父级板块ID
+ private Long parentId;
+ // 板块名
+ private String boardName;
+ // 封面
+ private String cover;
+ // 描述
+ private String boardDesc;
+ // 排序
+ private Integer sort;
+ // 0:只允许管理员发帖 1:任何人可以发帖
+ private Boolean postType;
+ private List children;
+
+ @Override
+ public void setChildren(List extends AbstractTreeNode> children) {
+ this.children = (List) children;
+ }
+}
diff --git a/model/src/main/java/cn/bunny/vo/system/comment/CommentVo.java b/model/src/main/java/cn/bunny/vo/system/comment/CommentVo.java
new file mode 100644
index 0000000..46585af
--- /dev/null
+++ b/model/src/main/java/cn/bunny/vo/system/comment/CommentVo.java
@@ -0,0 +1,53 @@
+package cn.bunny.vo.system.comment;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class CommentVo {
+ // 评论ID
+ private Long id;
+ // 父级评论ID
+ private Integer pCommentId;
+ // 文章ID
+ private String articleId;
+ // 回复内容
+ private String content;
+ // 图片
+ private String imgPath;
+ // 用户ID
+ private Long userId;
+ // 昵称
+ private String nickName;
+ // 用户ip地址
+ private String userIpAddress;
+ // 回复人ID
+ private Long replyUserId;
+ // 回复人昵称
+ private String replyNickName;
+ // 0:未置顶 1:置顶
+ private Byte topType;
+ // 发布时间
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @JsonSerialize(using = LocalDateTimeSerializer.class)
+ @JsonDeserialize(using = LocalDateTimeDeserializer.class)
+ private LocalDateTime postTime;
+ // good数量
+ private Integer goodCount;
+ // 0:待审核 1:已审核
+ private Byte status;
+ private List children;
+}
diff --git a/model/src/main/java/cn/bunny/vo/system/login/LoginVo.java b/model/src/main/java/cn/bunny/vo/system/login/LoginVo.java
new file mode 100644
index 0000000..9bda0ae
--- /dev/null
+++ b/model/src/main/java/cn/bunny/vo/system/login/LoginVo.java
@@ -0,0 +1,48 @@
+package cn.bunny.vo.system.login;
+
+import cn.bunny.result.constant.LocalDateTimeConstant;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * 用户登录返回内容
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class LoginVo {
+ private Long id;
+ private String nickName;
+ private String email;
+ private String password;
+ private String avatar;
+ private Byte sex;
+ private String personDescription;
+ @JsonFormat(pattern = LocalDateTimeConstant.DEFAULT_DATE_TIME_SECOND_FORMAT)
+ @JsonSerialize(using = LocalDateTimeSerializer.class)
+ @JsonDeserialize(using = LocalDateTimeDeserializer.class)
+ private LocalDateTime joinTime;
+ @JsonFormat(pattern = LocalDateTimeConstant.DEFAULT_DATE_TIME_SECOND_FORMAT)
+ @JsonSerialize(using = LocalDateTimeSerializer.class)
+ @JsonDeserialize(using = LocalDateTimeDeserializer.class)
+ private LocalDateTime lastLoginTime;
+ private String lastLoginIp;
+ private String lastLoginIpAddress;
+ private Integer totalIntegral;
+ private Integer currentIntegral;
+ private Byte status;
+ private String token;
+ private List roleList;
+ private List powerList;
+}
diff --git a/model/src/main/java/cn/bunny/vo/system/ValidateCodeVo.java b/model/src/main/java/cn/bunny/vo/system/login/ValidateCodeVo.java
similarity index 93%
rename from model/src/main/java/cn/bunny/vo/system/ValidateCodeVo.java
rename to model/src/main/java/cn/bunny/vo/system/login/ValidateCodeVo.java
index b01b14f..21c7ae4 100644
--- a/model/src/main/java/cn/bunny/vo/system/ValidateCodeVo.java
+++ b/model/src/main/java/cn/bunny/vo/system/login/ValidateCodeVo.java
@@ -1,4 +1,4 @@
-package cn.bunny.vo.system;
+package cn.bunny.vo.system.login;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
diff --git a/model/src/main/java/cn/bunny/vo/system/user/UserInfoVo.java b/model/src/main/java/cn/bunny/vo/system/user/UserInfoVo.java
new file mode 100644
index 0000000..fa60a87
--- /dev/null
+++ b/model/src/main/java/cn/bunny/vo/system/user/UserInfoVo.java
@@ -0,0 +1,43 @@
+package cn.bunny.vo.system.user;
+
+import cn.bunny.result.constant.LocalDateTimeConstant;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDateTime;
+
+/**
+ * 获取用户信息返回参数
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class UserInfoVo {
+ private Long userId;
+ private String nickName;
+ private String email;
+ private String avatar;
+ private Byte sex;
+ private String personDescription;
+ @JsonFormat(pattern = LocalDateTimeConstant.DEFAULT_DATE_TIME_SECOND_FORMAT)
+ @JsonSerialize(using = LocalDateTimeSerializer.class)
+ @JsonDeserialize(using = LocalDateTimeDeserializer.class)
+ private LocalDateTime joinTime;
+ @JsonFormat(pattern = LocalDateTimeConstant.DEFAULT_DATE_TIME_SECOND_FORMAT)
+ @JsonSerialize(using = LocalDateTimeSerializer.class)
+ @JsonDeserialize(using = LocalDateTimeDeserializer.class)
+ private LocalDateTime lastLoginTime;
+ private String lastLoginIp;
+ private String lastLoginIpAddress;
+ private Integer totalIntegral;
+ private Integer currentIntegral;
+ private Byte status;
+}
diff --git a/model/src/main/java/cn/bunny/vo/system/user/UserIntegralRecordVo.java b/model/src/main/java/cn/bunny/vo/system/user/UserIntegralRecordVo.java
new file mode 100644
index 0000000..9c33f60
--- /dev/null
+++ b/model/src/main/java/cn/bunny/vo/system/user/UserIntegralRecordVo.java
@@ -0,0 +1,33 @@
+package cn.bunny.vo.system.user;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDateTime;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class UserIntegralRecordVo {
+ // 记录ID
+ private Integer recordId;
+ // 用户ID
+ private String userId;
+ // 操作类型
+ private Byte operType;
+ // 积分
+ private Integer integral;
+ // 创建时间
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @JsonSerialize(using = LocalDateTimeSerializer.class)
+ @JsonDeserialize(using = LocalDateTimeDeserializer.class)
+ private LocalDateTime createTime;
+}
diff --git a/model/src/main/java/cn/bunny/vo/system/user/UserMessageCountVo.java b/model/src/main/java/cn/bunny/vo/system/user/UserMessageCountVo.java
new file mode 100644
index 0000000..f0baa0c
--- /dev/null
+++ b/model/src/main/java/cn/bunny/vo/system/user/UserMessageCountVo.java
@@ -0,0 +1,19 @@
+package cn.bunny.vo.system.user;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class UserMessageCountVo {
+ private Integer total;
+ private Integer sys;
+ private Integer reply;
+ private Integer likePost;
+ private Integer likeComment;
+}
diff --git a/model/src/main/java/cn/bunny/vo/system/user/UserMessageVo.java b/model/src/main/java/cn/bunny/vo/system/user/UserMessageVo.java
new file mode 100644
index 0000000..44c5da9
--- /dev/null
+++ b/model/src/main/java/cn/bunny/vo/system/user/UserMessageVo.java
@@ -0,0 +1,43 @@
+package cn.bunny.vo.system.user;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDateTime;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class UserMessageVo {
+ // 自增ID
+ private Integer messageId;
+ // 接收人用户ID
+ private String receivedUserId;
+ // 文章ID
+ private String articleId;
+ // 文章标题
+ private String articleTitle;
+ // 评论ID
+ private Integer commentId;
+ // 发送人用户ID
+ private String sendUserId;
+ // 发送人昵称
+ private String sendNickName;
+ // sys:系统消息 reply:评论 likePost:文章点赞 likeComment:评论点赞 attachment:附件下载
+ private String messageType;
+ // 消息内容
+ private String messageContent;
+ // 创建时间
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ @JsonSerialize(using = LocalDateTimeSerializer.class)
+ @JsonDeserialize(using = LocalDateTimeDeserializer.class)
+ private LocalDateTime createTime;
+}
diff --git a/module/module-mail/pom.xml b/module/module-mail/pom.xml
index d8f5634..90242e5 100644
--- a/module/module-mail/pom.xml
+++ b/module/module-mail/pom.xml
@@ -18,11 +18,6 @@
-
- cn.bunny
- service-utils
- 0.0.1-SNAPSHOT
-
org.springframework.boot
spring-boot-starter-mail
diff --git a/module/module-mail/src/main/java/cn/bunny/module/mail/utils/MailSendCheckUtil.java b/module/module-mail/src/main/java/cn/bunny/module/mail/utils/MailSendCheckUtil.java
index 4d2de49..6829253 100644
--- a/module/module-mail/src/main/java/cn/bunny/module/mail/utils/MailSendCheckUtil.java
+++ b/module/module-mail/src/main/java/cn/bunny/module/mail/utils/MailSendCheckUtil.java
@@ -1,8 +1,8 @@
package cn.bunny.module.mail.utils;
-import cn.bunny.common.result.constant.MailMessageConstant;
import cn.bunny.common.service.utils.EmptyUtil;
-import cn.bunny.entity.email.EmailSend;
+import cn.bunny.entity.system.email.EmailSend;
+import cn.bunny.result.constant.MailMessageConstant;
public class MailSendCheckUtil {
/**
diff --git a/module/module-mail/src/main/java/cn/bunny/module/mail/utils/MailSenderUtil.java b/module/module-mail/src/main/java/cn/bunny/module/mail/utils/MailSenderUtil.java
index 130c79e..0975c97 100644
--- a/module/module-mail/src/main/java/cn/bunny/module/mail/utils/MailSenderUtil.java
+++ b/module/module-mail/src/main/java/cn/bunny/module/mail/utils/MailSenderUtil.java
@@ -1,7 +1,7 @@
package cn.bunny.module.mail.utils;
-import cn.bunny.entity.email.EmailSend;
-import cn.bunny.entity.email.EmailSendInit;
+import cn.bunny.entity.system.email.EmailSend;
+import cn.bunny.entity.system.email.EmailSendInit;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.MimeMessage;
import org.springframework.mail.SimpleMailMessage;
@@ -63,7 +63,7 @@ public class MailSenderUtil {
// 发送邮件
javaMailSender.send(message);
}
-
+
/**
* 发送邮件-简单
*
diff --git a/module/module-minio/pom.xml b/module/module-minio/pom.xml
index 8e812f7..cdc48fe 100644
--- a/module/module-minio/pom.xml
+++ b/module/module-minio/pom.xml
@@ -18,11 +18,6 @@
-
- cn.bunny
- service-utils
- 0.0.1-SNAPSHOT
-
io.minio
diff --git a/module/module-minio/src/main/java/cn/bunny/module/minio/utils/MinioUtil.java b/module/module-minio/src/main/java/cn/bunny/module/minio/utils/MinioUtil.java
index f60fa1c..8fc332d 100644
--- a/module/module-minio/src/main/java/cn/bunny/module/minio/utils/MinioUtil.java
+++ b/module/module-minio/src/main/java/cn/bunny/module/minio/utils/MinioUtil.java
@@ -1,6 +1,6 @@
package cn.bunny.module.minio.utils;
-import cn.bunny.common.result.constant.MinioMessageConstant;
+import cn.bunny.result.constant.FileMessageConstant;
import cn.bunny.common.service.exception.BunnyException;
import io.minio.*;
import io.minio.messages.*;
@@ -37,7 +37,7 @@ public class MinioUtil {
log.error("判断桶是否存在 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
}
- throw new BunnyException(MinioMessageConstant.BUCKET_EXISTS_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.BUCKET_EXISTS_EXCEPTION);
}
/**
@@ -53,7 +53,7 @@ public class MinioUtil {
log.error("删除桶的加密配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
}
- throw new BunnyException(MinioMessageConstant.DELETE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DELETE_BUCKET_EXCEPTION);
}
/**
@@ -68,7 +68,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("删除桶的生命周期配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DELETE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DELETE_BUCKET_EXCEPTION);
}
}
@@ -84,7 +84,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("删除桶的加密配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DELETE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DELETE_BUCKET_EXCEPTION);
}
}
@@ -100,7 +100,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("删除桶的加密配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DELETE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DELETE_BUCKET_EXCEPTION);
}
}
@@ -116,7 +116,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("删除桶的桶复制配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DELETE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DELETE_BUCKET_EXCEPTION);
}
}
@@ -132,7 +132,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("删除桶的桶复制配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DELETE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DELETE_BUCKET_EXCEPTION);
}
}
@@ -148,7 +148,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("删除桶中的对象锁配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DELETE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DELETE_BUCKET_EXCEPTION);
}
}
@@ -167,7 +167,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("获取存储桶的加密配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.GET_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.GET_BUCKET_EXCEPTION);
}
return conf;
@@ -187,7 +187,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("获取存储桶的生命周期配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.GET_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.GET_BUCKET_EXCEPTION);
}
return lifecycle;
@@ -208,7 +208,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("获取存储桶的通知配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.GET_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.GET_BUCKET_EXCEPTION);
}
return configuration;
@@ -229,7 +229,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("获取桶的桶策略配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.GET_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.GET_BUCKET_EXCEPTION);
}
return config;
@@ -250,7 +250,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("获取桶复制参数 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.GET_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.GET_BUCKET_EXCEPTION);
}
return configuration;
@@ -271,7 +271,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("获取存储桶的标签 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.GET_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.GET_BUCKET_EXCEPTION);
}
return tags;
}
@@ -291,7 +291,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("获取存储桶的版本控制配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.GET_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.GET_BUCKET_EXCEPTION);
}
return configuration;
@@ -311,7 +311,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("获取存储桶中的对象锁配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.GET_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.GET_BUCKET_EXCEPTION);
}
return configuration;
@@ -331,7 +331,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("列出所有桶的桶信息 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.QUERY_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.QUERY_BUCKET_EXCEPTION);
}
return buckets;
@@ -349,7 +349,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("创建桶 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.CREATE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.CREATE_BUCKET_EXCEPTION);
}
}
@@ -365,7 +365,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("创建桶 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.CREATE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.CREATE_BUCKET_EXCEPTION);
}
}
@@ -381,7 +381,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("创建桶 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.CREATE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.CREATE_BUCKET_EXCEPTION);
}
}
@@ -397,7 +397,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("删除桶 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DELETE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DELETE_BUCKET_EXCEPTION);
}
}
@@ -414,7 +414,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("设置桶的加密配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.UPDATE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.UPDATE_BUCKET_EXCEPTION);
}
}
@@ -431,7 +431,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("查看桶策略 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.UPDATE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.UPDATE_BUCKET_EXCEPTION);
}
}
@@ -449,7 +449,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("设置桶复制参数 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.UPDATE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.UPDATE_BUCKET_EXCEPTION);
}
}
@@ -466,7 +466,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("设置/修改桶标签 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.UPDATE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.UPDATE_BUCKET_EXCEPTION);
}
}
@@ -484,7 +484,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("设置桶的版本配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.UPDATE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.UPDATE_BUCKET_EXCEPTION);
}
}
@@ -501,7 +501,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("对象对象锁定配置 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.UPDATE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.UPDATE_BUCKET_EXCEPTION);
}
}
@@ -519,7 +519,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("组合对象 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.COMPOSE_OBJECT_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.COMPOSE_OBJECT_EXCEPTION);
}
}
@@ -542,7 +542,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("组合对象 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.COMPOSE_OBJECT_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.COMPOSE_OBJECT_EXCEPTION);
}
}
@@ -567,7 +567,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("组合对象 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.COMPOSE_OBJECT_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.COMPOSE_OBJECT_EXCEPTION);
}
}
@@ -590,7 +590,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("复制另一个桶中文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.COPY_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.COPY_BUCKET_EXCEPTION);
}
}
@@ -615,7 +615,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("复制另一个桶中文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.COPY_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.COPY_BUCKET_EXCEPTION);
}
}
@@ -641,7 +641,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("复制另一个桶中文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.COPY_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.COPY_BUCKET_EXCEPTION);
}
}
@@ -658,7 +658,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("删除对象的标记 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DELETE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DELETE_BUCKET_EXCEPTION);
}
}
@@ -675,7 +675,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("禁用对象 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DISABLE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DISABLE_BUCKET_EXCEPTION);
}
}
@@ -692,7 +692,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("禁用对象 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.ENABLE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.ENABLE_BUCKET_EXCEPTION);
}
}
@@ -710,7 +710,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("获取文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.GET_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.GET_BUCKET_EXCEPTION);
}
}
@@ -728,7 +728,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("下载文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DOWNLOAD_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DOWNLOAD_BUCKET_EXCEPTION);
}
}
@@ -747,7 +747,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("下载文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DOWNLOAD_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DOWNLOAD_BUCKET_EXCEPTION);
}
}
@@ -767,7 +767,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("获取对象保留 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DOWNLOAD_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DOWNLOAD_BUCKET_EXCEPTION);
}
}
@@ -786,7 +786,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("获取对象标签 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.GET_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.GET_BUCKET_EXCEPTION);
}
}
@@ -805,7 +805,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("上传文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.UPLOAD_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.FILE_UPLOAD_EXCEPTION);
}
}
@@ -825,7 +825,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("上传文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.UPLOAD_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.FILE_UPLOAD_EXCEPTION);
}
}
@@ -848,7 +848,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("上传文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.UPLOAD_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.FILE_UPLOAD_EXCEPTION);
}
}
@@ -865,7 +865,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("删除文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DELETE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DELETE_BUCKET_EXCEPTION);
}
}
@@ -883,7 +883,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("删除文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DELETE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DELETE_BUCKET_EXCEPTION);
}
}
@@ -901,7 +901,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("删除文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DELETE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DELETE_BUCKET_EXCEPTION);
}
}
@@ -918,7 +918,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("上传多文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.UPLOAD_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.FILE_UPLOAD_EXCEPTION);
}
}
@@ -937,7 +937,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("删除文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.UPDATE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.UPDATE_BUCKET_EXCEPTION);
}
}
@@ -955,7 +955,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("删除文件 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.UPDATE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.UPDATE_BUCKET_EXCEPTION);
}
}
@@ -976,7 +976,7 @@ public class MinioUtil {
} catch (Exception exception) {
log.error("获取对象状态 ------ 失败消息:{}", exception.getLocalizedMessage());
exception.getStackTrace();
- throw new BunnyException(MinioMessageConstant.DELETE_BUCKET_EXCEPTION);
+ throw new BunnyException(FileMessageConstant.DELETE_BUCKET_EXCEPTION);
}
}
}
\ No newline at end of file
diff --git a/module/module-rabbitMQ/pom.xml b/module/module-rabbitMQ/pom.xml
index e949a2f..29884a1 100644
--- a/module/module-rabbitMQ/pom.xml
+++ b/module/module-rabbitMQ/pom.xml
@@ -29,6 +29,7 @@
com.fasterxml.jackson.dataformat
jackson-dataformat-xml
+ 2.16.0-rc1
diff --git a/module/module-task/pom.xml b/module/module-task/pom.xml
new file mode 100644
index 0000000..3ab04f3
--- /dev/null
+++ b/module/module-task/pom.xml
@@ -0,0 +1,23 @@
+
+ 4.0.0
+
+ cn.bunny
+ module
+ 0.0.1-SNAPSHOT
+
+
+ module-task
+ jar
+
+ module-task
+ https://maven.apache.org
+
+
+ UTF-8
+
+
+
+
+
+
diff --git a/module/module-task/src/main/java/cn/bunny/module/task/TemplateTask.java b/module/module-task/src/main/java/cn/bunny/module/task/TemplateTask.java
new file mode 100644
index 0000000..2dbf0b7
--- /dev/null
+++ b/module/module-task/src/main/java/cn/bunny/module/task/TemplateTask.java
@@ -0,0 +1,14 @@
+package cn.bunny.module.task;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+@Component
+@Slf4j
+public class TemplateTask {
+ @Scheduled(cron = "0/1 5 * * * ?")
+ public void templateTask() {
+ log.info("定时任务执行...");
+ }
+}
diff --git a/module/module-websocket/src/main/java/cn/bunny/module/websocket/config/WebSocketConfiguration.java b/module/module-websocket/src/main/java/cn/bunny/module/websocket/config/WebSocketConfiguration.java
new file mode 100644
index 0000000..8df905f
--- /dev/null
+++ b/module/module-websocket/src/main/java/cn/bunny/module/websocket/config/WebSocketConfiguration.java
@@ -0,0 +1,13 @@
+package cn.bunny.module.websocket.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.socket.server.standard.ServerEndpointExporter;
+
+@Configuration
+public class WebSocketConfiguration {
+ @Bean
+ public ServerEndpointExporter endpointExporter() {
+ return new ServerEndpointExporter();
+ }
+}
diff --git a/module/pom.xml b/module/pom.xml
index bfd01e7..2804f9c 100644
--- a/module/pom.xml
+++ b/module/pom.xml
@@ -3,7 +3,7 @@
4.0.0
cn.bunny
- bunny-template-mirror-server
+ bunny-mirror-server
0.0.1-SNAPSHOT
@@ -16,6 +16,8 @@
module-minio
module-mail
module-rabbitMQ
+ module-websocket
+ module-task
@@ -25,8 +27,8 @@
cn.bunny
- model
+ service-utils
0.0.1-SNAPSHOT
-
+
\ No newline at end of file
diff --git a/module/spring-security/pom.xml b/module/spring-security/pom.xml
index 03d252d..070d1de 100644
--- a/module/spring-security/pom.xml
+++ b/module/spring-security/pom.xml
@@ -18,11 +18,6 @@
-
- cn.bunny
- service-utils
- 0.0.1-SNAPSHOT
-
org.springframework.boot
diff --git a/module/spring-security/src/main/java/cn/bunny/security/config/WebSecurityConfig.java b/module/spring-security/src/main/java/cn/bunny/security/config/WebSecurityConfig.java
index 64cb2f1..5899405 100644
--- a/module/spring-security/src/main/java/cn/bunny/security/config/WebSecurityConfig.java
+++ b/module/spring-security/src/main/java/cn/bunny/security/config/WebSecurityConfig.java
@@ -1,6 +1,5 @@
package cn.bunny.security.config;
-import cn.bunny.common.result.constant.SecurityConstant;
import cn.bunny.security.custom.CustomPasswordEncoder;
import cn.bunny.security.filter.TokenAuthenticationFilter;
import cn.bunny.security.filter.TokenLoginFilterService;
@@ -16,6 +15,7 @@ import org.springframework.security.config.annotation.authentication.configurati
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.core.session.SessionRegistry;
import org.springframework.security.core.session.SessionRegistryImpl;
@@ -27,13 +27,15 @@ import org.springframework.security.web.util.matcher.RegexRequestMatcher;
@EnableWebSecurity
@EnableMethodSecurity
public class WebSecurityConfig {
-
@Autowired
private RedisTemplate redisTemplate;
+ // 自定义用户接口
@Autowired
private CustomUserDetailsService customUserDetailsService;
+ // 自定义密码加密器
@Autowired
private CustomPasswordEncoder customPasswordEncoder;
+ // 自定义验证码
@Autowired
private CustomAuthorizationManagerService customAuthorizationManager;
@Autowired
@@ -57,8 +59,6 @@ public class WebSecurityConfig {
// 前后端分离不需要---记住我,e -> e.rememberMeParameter("rememberBunny").rememberMeCookieName("rememberBunny").key("BunnyKey")
.rememberMe(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(authorize -> {
- // 如果访问路径有下面的,不需要访问权限
- authorize.requestMatchers(SecurityConstant.annotations).permitAll();
// 有样式文件,不需要访问权限
authorize.requestMatchers(RegexRequestMatcher.regexMatcher("^\\S*[css|js]$")).permitAll();
// 上面都不是需要鉴权访问
@@ -70,9 +70,10 @@ public class WebSecurityConfig {
// 没有权限访问
exception.accessDeniedHandler(new SecurityAccessDeniedHandler());
})
- // 自定义过滤器
- .addFilterBefore(new TokenAuthenticationFilter(redisTemplate), UsernamePasswordAuthenticationFilter.class)
- .addFilterAt(new TokenLoginFilterService(authenticationConfiguration, redisTemplate, customUserDetailsService), UsernamePasswordAuthenticationFilter.class)
+ // 登录验证过滤器
+ .addFilterBefore(new TokenLoginFilterService(authenticationConfiguration, redisTemplate, customUserDetailsService), UsernamePasswordAuthenticationFilter.class)
+ // 其它权限鉴权过滤器
+ .addFilterAt(new TokenAuthenticationFilter(redisTemplate), UsernamePasswordAuthenticationFilter.class)
// 自定义密码加密器和用户登录
.passwordManagement(customPasswordEncoder).userDetailsService(customUserDetailsService);
@@ -83,4 +84,12 @@ public class WebSecurityConfig {
public SessionRegistry sessionRegistry() {
return new SessionRegistryImpl();
}
+
+ // 排出鉴定路径
+ @Bean
+ public WebSecurityCustomizer webSecurityCustomizer() {
+ String[] annotations = {"/", "/test/**", "/diagram-viewer/**", "/editor-app/**", "/*.html",
+ "/*/*/noAuth/**", "/*/noAuth/**", "/favicon.ico", "/swagger-resources/**", "/webjars/**", "/v3/**", "/swagger-ui.html/**", "/doc.html"};
+ return web -> web.ignoring().requestMatchers(annotations);
+ }
}
diff --git a/module/spring-security/src/main/java/cn/bunny/security/custom/CustomUser.java b/module/spring-security/src/main/java/cn/bunny/security/custom/CustomUser.java
index 92bb32d..296d5a1 100644
--- a/module/spring-security/src/main/java/cn/bunny/security/custom/CustomUser.java
+++ b/module/spring-security/src/main/java/cn/bunny/security/custom/CustomUser.java
@@ -13,9 +13,9 @@ import java.util.Collection;
@Getter
@Setter
public class CustomUser extends User {
- private cn.bunny.entity.system.User user;
+ private cn.bunny.entity.system.user.User user;
- public CustomUser(cn.bunny.entity.system.User user, Collection extends GrantedAuthority> authorities) {
+ public CustomUser(cn.bunny.entity.system.user.User user, Collection extends GrantedAuthority> authorities) {
super(user.getEmail(), user.getPassword(), authorities);
this.user = user;
}
diff --git a/module/spring-security/src/main/java/cn/bunny/security/filter/TokenAuthenticationFilter.java b/module/spring-security/src/main/java/cn/bunny/security/filter/TokenAuthenticationFilter.java
index dea5c18..bea057b 100644
--- a/module/spring-security/src/main/java/cn/bunny/security/filter/TokenAuthenticationFilter.java
+++ b/module/spring-security/src/main/java/cn/bunny/security/filter/TokenAuthenticationFilter.java
@@ -1,7 +1,13 @@
package cn.bunny.security.filter;
import cn.bunny.common.service.context.BaseContext;
+import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.utils.JwtHelper;
+import cn.bunny.common.service.utils.ResponseUtil;
+import cn.bunny.result.Result;
+import cn.bunny.result.ResultCodeEnum;
+import cn.bunny.result.constant.RedisUserConstant;
+import cn.bunny.vo.system.login.LoginVo;
import com.alibaba.fastjson2.JSON;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
@@ -17,7 +23,6 @@ import org.springframework.web.filter.OncePerRequestFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
public class TokenAuthenticationFilter extends OncePerRequestFilter {
private final RedisTemplate redisTemplate;
@@ -27,7 +32,7 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
}
@Override
- protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
+ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException, BunnyException {
String token = request.getHeader("token");
// login请求就没token,直接放行,因为后边有其他的过滤器
@@ -36,39 +41,51 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
return;
}
+ // 如果想让这个用户下线,清空Redis这个用户值,返回未登录,判断Redis是否有这个用户
+ // 如果想让这个用户锁定,清空Redis值并在数据库中设置status值为1
+ String userName = JwtHelper.getUsername(token);
+ Object usernameObject = redisTemplate.opsForValue().get(RedisUserConstant.getUserLoginInfoPrefix(userName));
+ if (usernameObject == null) {
+ Result error = Result.error(ResultCodeEnum.LOGIN_AUTH);
+ ResponseUtil.out(response, error);
+ return;
+ }
+
+ // 获取Redis中登录信息
+ LoginVo loginVo = JSON.parseObject(JSON.toJSONString(usernameObject), LoginVo.class);
// 如果是登录接口,直接放行
UsernamePasswordAuthenticationToken authentication = getAuthentication(request);
- SecurityContextHolder.getContext().setAuthentication(authentication);
+ if (authentication != null) {
+ // 设置用户详细信息
+ authentication.setDetails(loginVo.getPersonDescription());
+ SecurityContextHolder.getContext().setAuthentication(authentication);
+ }
+
chain.doFilter(request, response);
}
private UsernamePasswordAuthenticationToken getAuthentication(HttpServletRequest request) {
// 请求头是否有token
String token = request.getHeader("token");
- if (StringUtils.hasText(token)) {
- String username = JwtHelper.getUserName(token);
- if (StringUtils.hasText(username)) {
- // 当前用户信息放到ThreadLocal里面
- BaseContext.setUserId(JwtHelper.getUserId(token));
- BaseContext.setUsername(username);
+ String username = RedisUserConstant.getAdminLoginInfoPrefix(JwtHelper.getUsername(token));
+ List authList = new ArrayList<>();
+ if (!StringUtils.hasText(username)) return null;
- // 通过username从redis获取权限数据
- String authString = (String) redisTemplate.opsForValue().get(username);
- // 把redis获取字符串权限数据转换要求集合类型 List
- if (StringUtils.hasText(authString)) {
- List maplist = JSON.parseArray(authString, Map.class);
- System.out.println(maplist);
- List authList = new ArrayList<>();
- for (Map map : maplist) {
- String authority = (String) map.get("authority");
- authList.add(new SimpleGrantedAuthority(authority));
- }
- return new UsernamePasswordAuthenticationToken(username, null, authList);
- } else {
- return new UsernamePasswordAuthenticationToken(username, null, new ArrayList<>());
- }
- }
+ // 当前用户信息放到ThreadLocal里面
+ BaseContext.setAdminId(JwtHelper.getUserId(token));
+ BaseContext.setAdminName(username);
+
+ // 通过username从redis获取权限数据
+ Object UserObject = redisTemplate.opsForValue().get(username);
+ // 把redis获取字符串权限数据转换要求集合类型 List
+ if (UserObject != null) {
+ LoginVo loginVo = JSON.parseObject(JSON.toJSONString(UserObject), LoginVo.class);
+ List roleList = loginVo.getRoleList();
+ roleList.forEach(role -> authList.add(new SimpleGrantedAuthority(role)));
+
+ return new UsernamePasswordAuthenticationToken(username, null, authList);
+ } else {
+ return new UsernamePasswordAuthenticationToken(username, null, new ArrayList<>());
}
- return null;
}
}
diff --git a/module/spring-security/src/main/java/cn/bunny/security/filter/TokenLoginFilterService.java b/module/spring-security/src/main/java/cn/bunny/security/filter/TokenLoginFilterService.java
index 314d4e3..9eadac3 100644
--- a/module/spring-security/src/main/java/cn/bunny/security/filter/TokenLoginFilterService.java
+++ b/module/spring-security/src/main/java/cn/bunny/security/filter/TokenLoginFilterService.java
@@ -1,19 +1,21 @@
package cn.bunny.security.filter;
-import cn.bunny.common.result.enums.ResultCodeEnum;
-import cn.bunny.common.result.utils.Result;
import cn.bunny.common.service.utils.ResponseUtil;
-import cn.bunny.dto.LoginDto;
+import cn.bunny.dto.user.LoginDto;
+import cn.bunny.result.Result;
+import cn.bunny.result.ResultCodeEnum;
+import cn.bunny.result.constant.RedisUserConstant;
import cn.bunny.security.handelr.SecurityAuthenticationFailureHandler;
import cn.bunny.security.handelr.SecurityAuthenticationSuccessHandler;
import cn.bunny.security.service.CustomUserDetailsService;
-import cn.bunny.vo.system.LoginVo;
+import cn.bunny.vo.system.login.LoginVo;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.FilterChain;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
import org.springframework.security.core.Authentication;
@@ -23,53 +25,106 @@ import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.util.StringUtils;
import java.io.IOException;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
/**
+ * * UsernamePasswordAuthenticationFilter
+ * * 也可以在这里添加验证码、短信等的验证
* 由于SpringSecurity的登录只能是表单形式 并且用户名密码需要时username、password,可以通过继承 UsernamePasswordAuthenticationFilter 获取登录请求的参数
* 再去设置到 UsernamePasswordAuthenticationToken 中 来改变请求传参方式、参数名等 或者也可以在登录的时候加入其他参数等等
- * 也可以在这里添加验证码、短信等的验证
*/
public class TokenLoginFilterService extends UsernamePasswordAuthenticationFilter {
private final RedisTemplate redisTemplate;
private final CustomUserDetailsService customUserDetailsService;
private LoginDto loginDto;
- // 构造方法
+ // 依赖注入
public TokenLoginFilterService(AuthenticationConfiguration authenticationConfiguration, RedisTemplate redisTemplate, CustomUserDetailsService customUserDetailsService) throws Exception {
this.setAuthenticationSuccessHandler(new SecurityAuthenticationSuccessHandler());
this.setAuthenticationFailureHandler(new SecurityAuthenticationFailureHandler());
this.setPostOnly(false);
- // 指定登录接口及提交方式,可以指定任意路径
- this.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher("/*/login", "POST"));
+ // ? 指定登录接口及提交方式,可以指定任意路径
+ this.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher("/*/login", HttpMethod.POST.name()));
this.setAuthenticationManager(authenticationConfiguration.getAuthenticationManager());
+ // 依赖注入
this.redisTemplate = redisTemplate;
this.customUserDetailsService = customUserDetailsService;
}
- // 登录认证
- // 获取输入的用户名和密码,调用方法认证
+ /**
+ * * 登录认证,获取输入的用户名和密码,调用方法认证
+ * 接受前端login登录参数
+ * 在这里可以设置短信验证登录
+ */
+ @Override
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
try {
// 获取用户信息
loginDto = new ObjectMapper().readValue(request.getInputStream(), LoginDto.class);
- // 封装对象
+
+ // 登录验证码判断
+ String username = loginDto.getUsername();
+ String emailCode = loginDto.getEmailCode().toLowerCase();
+ String redisEmailCode = (String) redisTemplate.opsForValue().get(RedisUserConstant.getAdminUserEmailCodePrefix(username));
+
+ // 如果不存在验证码
+ if (!StringUtils.hasText(emailCode)) {
+ ResponseUtil.out(response, Result.error(ResultCodeEnum.EMAIL_CODE_NOT_EMPTY));
+ return null;
+ }
+ if (!StringUtils.hasText(redisEmailCode)) {
+ ResponseUtil.out(response, Result.error(ResultCodeEnum.SEND_EMAIL_CODE_NOT_EMPTY));
+ return null;
+ }
+ // 验证码不匹配
+ if (!Objects.equals(redisEmailCode.toLowerCase(), emailCode)) {
+ ResponseUtil.out(response, Result.error(ResultCodeEnum.EMAIL_CODE_NOT_MATCHING));
+ return null;
+ }
+
+ // 封装对象,将用户名密码传入
Authentication authenticationToken = new UsernamePasswordAuthenticationToken(loginDto.getUsername(), loginDto.getPassword());
- // 调用方法
return this.getAuthenticationManager().authenticate(authenticationToken);
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new RuntimeException(e.getLocalizedMessage());
}
}
- // 认证成功调用方法
+ /**
+ * * 认证成功调用方法
+ * 返回登录成功后的信息
+ */
+ @Override
protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication auth) {
+ // 封装返回对象
+ LoginVo loginVo = customUserDetailsService.login(loginDto);
+
+ // 判断用户是否被锁定
+ if (loginVo.getStatus() == 1) {
+ ResponseUtil.out(response, Result.error(ResultCodeEnum.FAIL_NO_ACCESS_DENIED_USER_LOCKED));
+ return;
+ }
+
+ // 将值存入Redis中
+ redisTemplate.opsForValue().set(RedisUserConstant.getAdminLoginInfoPrefix(loginVo.getEmail()), loginVo, 15, TimeUnit.DAYS);
+ // 将Redis中验证码删除
+ redisTemplate.delete(RedisUserConstant.getAdminUserEmailCodePrefix(loginVo.getEmail()));
// 返回登录信息
- LoginVo login = customUserDetailsService.login(loginDto);
- ResponseUtil.out(response, Result.success(login));
+ ResponseUtil.out(response, Result.success(loginVo));
}
- // 认证失败调用方法
+ /**
+ * * 认证失败调用方法,失败判断
+ * 1. 是否包含用户名
+ * 2. 是否包含密码
+ */
+ @Override
protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, AuthenticationException failed) {
+ // 账号和密码不能为空
+ if (loginDto == null) {
+ ResponseUtil.out(response, Result.error(ResultCodeEnum.LOGIN_ERROR_USERNAME_PASSWORD_NOT_EMPTY));
+ }
// 用户名为空
if (!StringUtils.hasText(loginDto.getUsername())) {
ResponseUtil.out(response, Result.error(ResultCodeEnum.USERNAME_NOT_EMPTY));
@@ -78,7 +133,7 @@ public class TokenLoginFilterService extends UsernamePasswordAuthenticationFilte
if (!StringUtils.hasText(loginDto.getPassword())) {
ResponseUtil.out(response, Result.error(ResultCodeEnum.PASSWORD_NOT_EMPTY));
}
- // 抛出异常
+ // 抛出异常,账号或密码错误
ResponseUtil.out(response, Result.error(null, ResultCodeEnum.LOGIN_ERROR));
}
}
diff --git a/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAccessDeniedHandler.java b/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAccessDeniedHandler.java
index c4ffb54..b14a8d7 100644
--- a/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAccessDeniedHandler.java
+++ b/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAccessDeniedHandler.java
@@ -1,7 +1,7 @@
package cn.bunny.security.handelr;
-import cn.bunny.common.result.enums.ResultCodeEnum;
-import cn.bunny.common.result.utils.Result;
+import cn.bunny.result.Result;
+import cn.bunny.result.ResultCodeEnum;
import com.alibaba.fastjson2.JSON;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
diff --git a/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationEntryPoint.java b/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationEntryPoint.java
index 8fd92c3..cd82558 100644
--- a/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationEntryPoint.java
+++ b/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationEntryPoint.java
@@ -1,8 +1,8 @@
package cn.bunny.security.handelr;
-import cn.bunny.common.result.utils.Result;
-import cn.bunny.common.result.enums.ResultCodeEnum;
-import com.alibaba.fastjson2.JSON;
+import cn.bunny.common.service.utils.ResponseUtil;
+import cn.bunny.result.Result;
+import cn.bunny.result.ResultCodeEnum;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
@@ -24,16 +24,14 @@ public class SecurityAuthenticationEntryPoint implements AuthenticationEntryPoin
Result result;
if (token == null) {
- result = Result.error(new Object(), ResultCodeEnum.LOGIN_AUTH);
+ result = Result.error(ResultCodeEnum.LOGIN_AUTH);
log.info("请求未登录接口:{},用户id:{}", message, null);
} else {
- result = Result.error(new Object(), ResultCodeEnum.LOGGED_IN_FROM_ANOTHER_DEVICE);
+ result = Result.error(ResultCodeEnum.LOGGED_IN_FROM_ANOTHER_DEVICE);
log.info("请求未授权接口:{},用户id:{}", message, token);
}
-
// 返回响应
- response.setContentType("application/json;charset=UTF-8");
- response.getWriter().println(JSON.toJSON(result));
+ ResponseUtil.out(response, result);
}
}
diff --git a/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationFailureHandler.java b/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationFailureHandler.java
index 34c21f6..e48ad49 100644
--- a/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationFailureHandler.java
+++ b/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationFailureHandler.java
@@ -1,6 +1,6 @@
package cn.bunny.security.handelr;
-import cn.bunny.common.result.utils.Result;
+import cn.bunny.result.Result;
import com.alibaba.fastjson2.JSON;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
diff --git a/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationSuccessHandler.java b/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationSuccessHandler.java
index 8642721..e5bd0fd 100644
--- a/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationSuccessHandler.java
+++ b/module/spring-security/src/main/java/cn/bunny/security/handelr/SecurityAuthenticationSuccessHandler.java
@@ -1,6 +1,6 @@
package cn.bunny.security.handelr;
-import cn.bunny.common.result.utils.Result;
+import cn.bunny.result.Result;
import com.alibaba.fastjson2.JSON;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
diff --git a/module/spring-security/src/main/java/cn/bunny/security/service/CustomUserDetailsService.java b/module/spring-security/src/main/java/cn/bunny/security/service/CustomUserDetailsService.java
index 4db2d85..7cf5b4e 100644
--- a/module/spring-security/src/main/java/cn/bunny/security/service/CustomUserDetailsService.java
+++ b/module/spring-security/src/main/java/cn/bunny/security/service/CustomUserDetailsService.java
@@ -1,7 +1,7 @@
package cn.bunny.security.service;
-import cn.bunny.dto.LoginDto;
-import cn.bunny.vo.system.LoginVo;
+import cn.bunny.dto.user.LoginDto;
+import cn.bunny.vo.system.login.LoginVo;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
diff --git a/pom.xml b/pom.xml
index 64fa9da..96c519e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
cn.bunny
- bunny-template-mirror-server
+ bunny-mirror-server
0.0.1-SNAPSHOT
pom
bunny-mirror-server
@@ -47,6 +47,8 @@
2023.0.0.0-RC1
4.1.2
6.1.0
+ 2.3
+ 3.1
@@ -56,6 +58,17 @@
junit
${junit.version}
+
+
+ org.apache.velocity
+ velocity-engine-core
+ ${velocity.version}
+
+
+ org.apache.velocity.tools
+ velocity-tools-generic
+ ${velocity-tools.version}
+
com.baomidou
diff --git a/server-gateway/pom.xml b/server-gateway/pom.xml
index 9efc13e..8d1d521 100644
--- a/server-gateway/pom.xml
+++ b/server-gateway/pom.xml
@@ -3,7 +3,7 @@
4.0.0
cn.bunny
- bunny-template-mirror-server
+ bunny-mirror-server
0.0.1-SNAPSHOT
@@ -21,17 +21,6 @@
-
- cn.bunny
- common-result
- 0.0.1-SNAPSHOT
-
-
- com.baomidou
- mybatis-plus-spring-boot3-starter
-
-
-
org.springframework.cloud
@@ -42,20 +31,24 @@
org.projectlombok
lombok
-
org.springframework.cloud
spring-cloud-starter-loadbalancer
4.1.2
-
com.alibaba.cloud
spring-cloud-starter-alibaba-nacos-discovery
2023.0.0.0-RC1
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-sentinel
+ 2023.0.1.0
+
@@ -63,11 +56,5 @@
-
-
- com.alibaba.cloud
- spring-cloud-starter-alibaba-sentinel
- 2023.0.1.0
-
diff --git a/server-gateway/src/main/java/cn/bunny/service/gateway/controller/IndexController.java b/server-gateway/src/main/java/cn/bunny/service/gateway/controller/IndexController.java
index 4936f98..6922ee4 100644
--- a/server-gateway/src/main/java/cn/bunny/service/gateway/controller/IndexController.java
+++ b/server-gateway/src/main/java/cn/bunny/service/gateway/controller/IndexController.java
@@ -1,6 +1,5 @@
package cn.bunny.service.gateway.controller;
-import cn.bunny.common.result.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -11,7 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
public class IndexController {
@GetMapping()
- public Result index() {
- return Result.success("欢迎访问。。。");
+ public String index() {
+ return "欢迎访问 Bunny Template 网关服务";
}
}
diff --git a/service-client/pom.xml b/service-client/pom.xml
index 55bac23..1552d44 100644
--- a/service-client/pom.xml
+++ b/service-client/pom.xml
@@ -3,7 +3,7 @@
4.0.0
cn.bunny
- bunny-template-mirror-server
+ bunny-mirror-server
0.0.1-SNAPSHOT
@@ -23,11 +23,6 @@
model
0.0.1-SNAPSHOT
-
- cn.bunny
- common-result
- 0.0.1-SNAPSHOT
-
org.springframework.cloud
diff --git a/service/pom.xml b/service/pom.xml
index d3d3c9d..45d8e0e 100644
--- a/service/pom.xml
+++ b/service/pom.xml
@@ -3,7 +3,7 @@
4.0.0
cn.bunny
- bunny-template-mirror-server
+ bunny-mirror-server
0.0.1-SNAPSHOT
@@ -31,5 +31,40 @@
org.springframework.boot
spring-boot-starter-test
+
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+ org.aspectj
+ aspectjrt
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+ com.zaxxer
+ HikariCP
+ 5.1.0
+
+
+
+ com.baomidou
+ mybatis-plus-spring-boot3-starter
+
+
+ org.aspectj
+ aspectjweaver
+
diff --git a/service/service-admin/pom.xml b/service/service-admin/pom.xml
index af3768f..b894921 100644
--- a/service/service-admin/pom.xml
+++ b/service/service-admin/pom.xml
@@ -25,12 +25,6 @@
spring-security
0.0.1-SNAPSHOT
-
-
- cn.bunny
- service-utils
- 0.0.1-SNAPSHOT
-
cn.bunny
module-mail
@@ -41,15 +35,6 @@
module-minio
0.0.1-SNAPSHOT
-
-
- org.aspectj
- aspectjrt
-
-
- org.aspectj
- aspectjweaver
-
diff --git a/service/service-admin/src/main/java/cn/bunny/service/admin/ServiceAdminApplication.java b/service/service-admin/src/main/java/cn/bunny/service/admin/ServiceAdminApplication.java
index f714149..d90a836 100644
--- a/service/service-admin/src/main/java/cn/bunny/service/admin/ServiceAdminApplication.java
+++ b/service/service-admin/src/main/java/cn/bunny/service/admin/ServiceAdminApplication.java
@@ -7,6 +7,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.stereotype.Indexed;
@ComponentScan(basePackages = {"cn.bunny"})
@MapperScan("cn.bunny.service.admin.mapper")
@@ -14,6 +15,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableCaching// 开启缓存注解
@SpringBootApplication
@Slf4j
+@Indexed
public class ServiceAdminApplication {
public static void main(String[] args) {
log.info("ServiceApplication启动...");
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/config/Knife4jConfig.java b/service/service-admin/src/main/java/cn/bunny/service/admin/config/Knife4jConfig.java
similarity index 86%
rename from common/service-utils/src/main/java/cn/bunny/common/service/config/Knife4jConfig.java
rename to service/service-admin/src/main/java/cn/bunny/service/admin/config/Knife4jConfig.java
index eee1b94..d1b84ea 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/config/Knife4jConfig.java
+++ b/service/service-admin/src/main/java/cn/bunny/service/admin/config/Knife4jConfig.java
@@ -1,4 +1,4 @@
-package cn.bunny.common.service.config;
+package cn.bunny.service.admin.config;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
@@ -26,12 +26,6 @@ public class Knife4jConfig {
return new OpenAPI().info(info).externalDocs(new ExternalDocumentation());
}
- // 管理员相关分类接口
- @Bean
- public GroupedOpenApi groupedOpenApi() {
- return GroupedOpenApi.builder().group("前台接口管理").pathsToMatch("/api/**").build();
- }
-
// 管理员相关分类接口
@Bean
public GroupedOpenApi groupedOpenAdminApi() {
diff --git a/service/service-admin/src/main/java/cn/bunny/service/admin/controller/IndexController.java b/service/service-admin/src/main/java/cn/bunny/service/admin/controller/IndexController.java
new file mode 100644
index 0000000..1245ba5
--- /dev/null
+++ b/service/service-admin/src/main/java/cn/bunny/service/admin/controller/IndexController.java
@@ -0,0 +1,13 @@
+package cn.bunny.service.admin.controller;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/")
+public class IndexController {
+ @RequestMapping("")
+ public String index() {
+ return "欢迎访问BunnyBBS";
+ }
+}
diff --git a/service/service-admin/src/main/java/cn/bunny/service/admin/controller/LoginController.java b/service/service-admin/src/main/java/cn/bunny/service/admin/controller/LoginController.java
new file mode 100644
index 0000000..ad7468c
--- /dev/null
+++ b/service/service-admin/src/main/java/cn/bunny/service/admin/controller/LoginController.java
@@ -0,0 +1,36 @@
+package cn.bunny.service.admin.controller;
+
+
+import cn.bunny.dto.user.LoginDto;
+import cn.bunny.result.Result;
+import cn.bunny.service.admin.service.UserService;
+import cn.bunny.vo.system.login.LoginVo;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Tag(name = "登录相关接口")
+@RestController
+@RequestMapping("/admin")
+public class LoginController {
+ @Autowired
+ private UserService userService;
+
+ @Operation(summary = "登录接口", description = "后台用户登录接口")
+ @PostMapping("login")
+ public Result login(@RequestBody LoginDto loginDto) {
+ LoginVo vo = userService.login(loginDto);
+ return Result.success(vo);
+ }
+
+ @Operation(summary = "发送邮箱验证码", description = "发送邮箱验证码")
+ @PostMapping("noAuth/sendEmail")
+ public Result sendEmail(String email) {
+ userService.sendEmail(email);
+ return Result.success();
+ }
+}
diff --git a/service/service-admin/src/main/java/cn/bunny/service/admin/mapper/AdminPowerMapper.java b/service/service-admin/src/main/java/cn/bunny/service/admin/mapper/AdminPowerMapper.java
new file mode 100644
index 0000000..00b666b
--- /dev/null
+++ b/service/service-admin/src/main/java/cn/bunny/service/admin/mapper/AdminPowerMapper.java
@@ -0,0 +1,34 @@
+package cn.bunny.service.admin.mapper;
+
+import cn.bunny.entity.system.admin.AdminPower;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ *
+ * Mapper 接口
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-18
+ */
+@Mapper
+public interface AdminPowerMapper extends BaseMapper {
+ /**
+ * 查询用户权限信息
+ *
+ * @param roleIdList 角色id 列表
+ * @return 用户对应的权限
+ */
+ AdminPower[] selectByPowerWithRoleIdList(List roleIdList);
+
+ /**
+ * 查询用户权限
+ *
+ * @param userId 用户id
+ * @return 用户权限列表
+ */
+ List queryByUserIdWithPower(Long userId);
+}
diff --git a/service/service-admin/src/main/java/cn/bunny/service/admin/mapper/AdminRoleMapper.java b/service/service-admin/src/main/java/cn/bunny/service/admin/mapper/AdminRoleMapper.java
new file mode 100644
index 0000000..2e0ae1b
--- /dev/null
+++ b/service/service-admin/src/main/java/cn/bunny/service/admin/mapper/AdminRoleMapper.java
@@ -0,0 +1,26 @@
+package cn.bunny.service.admin.mapper;
+
+import cn.bunny.entity.system.admin.AdminRole;
+import cn.bunny.entity.system.admin.auth.AuthUserRole;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ *
+ * Mapper 接口
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-18
+ */
+@Mapper
+public interface AdminRoleMapper extends BaseMapper {
+
+ /**
+ * 查询用户所有的角色信息
+ *
+ * @param userId 用户id
+ * @return 用户对应的角色
+ */
+ AuthUserRole[] selectByRoleWithUserId(Long userId);
+}
diff --git a/service/service-admin/src/main/java/cn/bunny/service/admin/mapper/EmailUsersMapper.java b/service/service-admin/src/main/java/cn/bunny/service/admin/mapper/EmailUsersMapper.java
new file mode 100644
index 0000000..e694eec
--- /dev/null
+++ b/service/service-admin/src/main/java/cn/bunny/service/admin/mapper/EmailUsersMapper.java
@@ -0,0 +1,24 @@
+package cn.bunny.service.admin.mapper;
+
+import cn.bunny.entity.system.email.EmailUsers;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ *
+ * Mapper 接口
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-14
+ */
+@Mapper
+public interface EmailUsersMapper extends BaseMapper {
+
+ /**
+ * 彻底删除邮箱用户
+ *
+ * @param id 用户ID
+ */
+ void thoroughDeleteById(Long id);
+}
diff --git a/service/service-admin/src/main/java/cn/bunny/service/admin/mapper/UserMapper.java b/service/service-admin/src/main/java/cn/bunny/service/admin/mapper/UserMapper.java
new file mode 100644
index 0000000..89f31db
--- /dev/null
+++ b/service/service-admin/src/main/java/cn/bunny/service/admin/mapper/UserMapper.java
@@ -0,0 +1,25 @@
+package cn.bunny.service.admin.mapper;
+
+import cn.bunny.entity.system.user.User;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ *
+ * 用户信息 Mapper 接口
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-18
+ */
+@Mapper
+public interface UserMapper extends BaseMapper {
+ /**
+ * 前台用户登录接口
+ *
+ * @param username 邮箱/昵称
+ * @param password 吗,Image
+ * @return 登录参数
+ */
+ User login(String username, String password);
+}
diff --git a/service/service-admin/src/main/java/cn/bunny/service/admin/security/CustomAuthorizationManagerServiceImpl.java b/service/service-admin/src/main/java/cn/bunny/service/admin/security/CustomAuthorizationManagerServiceImpl.java
new file mode 100644
index 0000000..7a00f59
--- /dev/null
+++ b/service/service-admin/src/main/java/cn/bunny/service/admin/security/CustomAuthorizationManagerServiceImpl.java
@@ -0,0 +1,72 @@
+package cn.bunny.service.admin.security;
+
+import cn.bunny.common.service.utils.JwtHelper;
+import cn.bunny.entity.system.admin.AdminPower;
+import cn.bunny.security.service.CustomAuthorizationManagerService;
+import cn.bunny.service.admin.mapper.AdminPowerMapper;
+import jakarta.servlet.http.HttpServletRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.AccessDeniedException;
+import org.springframework.security.authorization.AuthorizationDecision;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.web.access.intercept.RequestAuthorizationContext;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.function.Supplier;
+
+
+/**
+ * 自定义权限判断
+ * 判断用户有哪些权限
+ */
+@Component
+@Slf4j
+public class CustomAuthorizationManagerServiceImpl implements CustomAuthorizationManagerService {
+ @Autowired
+ private AdminPowerMapper adminPowerMapper;
+
+ @Override
+ public void verify(Supplier authentication, RequestAuthorizationContext requestAuthorizationContext) {
+ CustomAuthorizationManagerService.super.verify(authentication, requestAuthorizationContext);
+ }
+
+ @Override
+ public AuthorizationDecision check(Supplier authentication, RequestAuthorizationContext context) {
+ // 用户的token和用户id、请求Url
+ HttpServletRequest request = context.getRequest();
+ String token = request.getHeader("token");
+ Long userId = JwtHelper.getUserId(token);// 用户id
+ String requestURI = request.getRequestURI();// 请求地址
+ String method = request.getMethod();// 请求方式
+ List roleCodeList = authentication.get().getAuthorities().stream().map(GrantedAuthority::getAuthority).toList();// 角色代码列表
+ if (token == null) {
+ throw new AccessDeniedException("");
+ }
+
+ return new AuthorizationDecision(hasRoleList(requestURI, method, userId));
+ }
+
+ /**
+ * 查询用户所属的角色信息
+ *
+ * @param requestURI 请求url地址
+ * @param method 请求方式
+ * @param userId 用户id
+ */
+ private Boolean hasRoleList(String requestURI, String method, Long userId) {
+ // 查询用户权限
+ List powerList = adminPowerMapper.queryByUserIdWithPower(userId);
+ // 如果查询到当前地址符合这个地址
+ for (AdminPower adminPower : powerList) {
+ String description = adminPower.getDescription();
+ if (description.equals(requestURI) || requestURI.matches(description)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/security/CustomUserDetailsService.java b/service/service-admin/src/main/java/cn/bunny/service/admin/security/CustomUserDetailsService.java
similarity index 65%
rename from service/service-web/src/main/java/cn/bunny/service/web/security/CustomUserDetailsService.java
rename to service/service-admin/src/main/java/cn/bunny/service/admin/security/CustomUserDetailsService.java
index 61867c8..79aa939 100644
--- a/service/service-web/src/main/java/cn/bunny/service/web/security/CustomUserDetailsService.java
+++ b/service/service-admin/src/main/java/cn/bunny/service/admin/security/CustomUserDetailsService.java
@@ -1,13 +1,13 @@
-package cn.bunny.service.web.security;
+package cn.bunny.service.admin.security;
-import cn.bunny.dto.LoginDto;
-import cn.bunny.entity.system.User;
-import cn.bunny.entity.system.UserRole;
+import cn.bunny.dto.user.LoginDto;
+import cn.bunny.entity.system.admin.AdminRole;
+import cn.bunny.entity.system.user.User;
import cn.bunny.security.custom.CustomUser;
-import cn.bunny.service.web.mapper.UserMapper;
-import cn.bunny.service.web.mapper.UserRoleMapper;
-import cn.bunny.service.web.service.LoginService;
-import cn.bunny.vo.system.LoginVo;
+import cn.bunny.service.admin.mapper.AdminRoleMapper;
+import cn.bunny.service.admin.mapper.UserMapper;
+import cn.bunny.service.admin.service.UserService;
+import cn.bunny.vo.system.login.LoginVo;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
@@ -22,26 +22,22 @@ public class CustomUserDetailsService implements cn.bunny.security.service.Custo
@Autowired
private UserMapper userMapper;
@Autowired
- private LoginService loginService;
+ private UserService userService;
@Autowired
- private UserRoleMapper userRoleMapper;
+ private AdminRoleMapper adminRoleMapper;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// 根据邮箱查询用户名
User user = userMapper.selectOne(Wrappers.lambdaQuery().eq(User::getEmail, username));
- List sysRoleList = userRoleMapper.selectList(null);
- // 如果这次为空,再试下查询昵称
- if (user == null) {
- user = userMapper.selectOne(Wrappers.lambdaQuery().eq(User::getNickName, username));
- }
+ List sysRoleList = adminRoleMapper.selectList(null);
// 都为空抛出异常,用户不存在
if (user == null) {
throw new UsernameNotFoundException("");
}
// 查询所有的角色
- List roleAuthoritieList = sysRoleList.stream().map(UserRole::getRoleCode).toList();
+ List roleAuthoritieList = sysRoleList.stream().map(AdminRole::getRoleCode).toList();
return new CustomUser(user, AuthorityUtils.createAuthorityList(roleAuthoritieList));
}
@@ -53,6 +49,6 @@ public class CustomUserDetailsService implements cn.bunny.security.service.Custo
*/
@Override
public LoginVo login(LoginDto loginDto) {
- return loginService.login(loginDto);
+ return userService.login(loginDto);
}
}
diff --git a/service/service-admin/src/main/java/cn/bunny/service/admin/service/UserService.java b/service/service-admin/src/main/java/cn/bunny/service/admin/service/UserService.java
new file mode 100644
index 0000000..3311455
--- /dev/null
+++ b/service/service-admin/src/main/java/cn/bunny/service/admin/service/UserService.java
@@ -0,0 +1,31 @@
+package cn.bunny.service.admin.service;
+
+import cn.bunny.dto.user.LoginDto;
+import cn.bunny.entity.system.user.User;
+import cn.bunny.vo.system.login.LoginVo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ *
+ * 用户信息 服务类
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-18
+ */
+public interface UserService extends IService {
+ /**
+ * 前台用户登录接口
+ *
+ * @param loginDto 登录参数
+ * @return 登录后结果返回
+ */
+ LoginVo login(LoginDto loginDto);
+
+ /**
+ * 发送邮箱验证码
+ *
+ * @param email 邮箱
+ */
+ void sendEmail(String email);
+}
diff --git a/service/service-admin/src/main/java/cn/bunny/service/admin/service/impl/UserServiceImpl.java b/service/service-admin/src/main/java/cn/bunny/service/admin/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000..158725f
--- /dev/null
+++ b/service/service-admin/src/main/java/cn/bunny/service/admin/service/impl/UserServiceImpl.java
@@ -0,0 +1,122 @@
+package cn.bunny.service.admin.service.impl;
+
+import cn.bunny.common.service.utils.EmptyUtil;
+import cn.bunny.common.service.utils.JwtHelper;
+import cn.bunny.dto.user.LoginDto;
+import cn.bunny.entity.system.admin.AdminPower;
+import cn.bunny.entity.system.admin.auth.AuthUserRole;
+import cn.bunny.entity.system.email.EmailSend;
+import cn.bunny.entity.system.email.EmailSendInit;
+import cn.bunny.entity.system.email.EmailUsers;
+import cn.bunny.entity.system.user.User;
+import cn.bunny.module.mail.utils.MailSenderUtil;
+import cn.bunny.result.constant.ExceptionConstant;
+import cn.bunny.result.constant.MailMessageConstant;
+import cn.bunny.result.constant.RedisUserConstant;
+import cn.bunny.service.admin.mapper.AdminPowerMapper;
+import cn.bunny.service.admin.mapper.AdminRoleMapper;
+import cn.bunny.service.admin.mapper.EmailUsersMapper;
+import cn.bunny.service.admin.mapper.UserMapper;
+import cn.bunny.service.admin.service.UserService;
+import cn.bunny.vo.system.login.LoginVo;
+import cn.hutool.captcha.CaptchaUtil;
+import cn.hutool.captcha.CircleCaptcha;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+import org.springframework.util.DigestUtils;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ *
+ * 用户信息 服务实现类
+ *
+ *
+ * @author Bunny
+ * @since 2024-05-18
+ */
+@Service
+public class UserServiceImpl extends ServiceImpl implements UserService {
+ @Autowired
+ private AdminRoleMapper roleMapper;
+ @Autowired
+ private AdminPowerMapper powerMapper;
+ @Autowired
+ private EmailUsersMapper emailUsersMapper;
+ @Autowired
+ private RedisTemplate redisTemplate;
+
+ /**
+ * 前台用户登录接口
+ *
+ * @param loginDto 登录参数
+ * @return 登录后结果返回
+ */
+ @Override
+ public LoginVo login(LoginDto loginDto) {
+ // 判断用户和密码是否为空
+ String username = loginDto.getUsername();
+ EmptyUtil.isEmpty(username, ExceptionConstant.USERNAME_IS_EMPTY_Exception);
+ // 密码不能为空
+ EmptyUtil.isEmpty(loginDto.getPassword(), ExceptionConstant.PASSWORD_NOT_EMPTY_Exception);
+ String password = DigestUtils.md5DigestAsHex(loginDto.getPassword().getBytes());
+ // 查询数据库,用户对应的角色、权限
+ User user = baseMapper.login(username, password);
+ Long userId = user.getId();
+
+ // 查询用户所有的角色信息
+ AuthUserRole[] roleList = roleMapper.selectByRoleWithUserId(userId);
+ List roleCodeList = Arrays.stream(roleList).map(AuthUserRole::getRoleCode).toList();
+ List roleIdList = Arrays.stream(roleList).map(AuthUserRole::getRoleId).toList();
+ // 查询用户权限信息
+ AdminPower[] adminPowerList = powerMapper.selectByPowerWithRoleIdList(roleIdList);
+ List powerCodeList = Arrays.stream(adminPowerList).map(AdminPower::getPowerCode).toList();
+
+ // 设置返回类型
+ LoginVo loginVo = new LoginVo();
+ BeanUtils.copyProperties(user, loginVo);
+ String token = JwtHelper.createToken(loginVo.getId(), loginVo.getEmail(), 7);
+ loginVo.setToken(token);
+ loginVo.setRoleList(roleCodeList);
+ loginVo.setPowerList(powerCodeList);
+
+ return loginVo;
+ }
+
+ /**
+ * 发送邮箱验证码
+ *
+ * @param email 邮箱
+ */
+ @Override
+ public void sendEmail(String email) {
+ // 从数据库中获取发送邮箱参数
+ EmailUsers emailUsers = emailUsersMapper.selectOne(Wrappers.lambdaQuery().eq(EmailUsers::getIsDefault, 1));
+ EmailSendInit emailSendInit = new EmailSendInit();
+ // 判断发送邮箱邮件是否为空
+ EmptyUtil.isEmpty(emailUsers, MailMessageConstant.EMAIL_CONFIG_NOT_FOUND);
+ BeanUtils.copyProperties(emailUsers, emailSendInit);
+ emailSendInit.setUsername(emailUsers.getEmail());
+ // 生成验证码
+ MailSenderUtil mailSenderUtil = new MailSenderUtil(emailSendInit);
+ CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(150, 48, 4, 2);
+ // 生成验证码和可以
+ String code = captcha.getCode();
+ // 发送验证码
+ EmailSend emailSend = new EmailSend();
+ emailSend.setSubject("邮箱验证码");
+ emailSend.setMessage(code);
+ emailSend.setSendTo(email);
+ emailSend.setIsRichText(false);
+ mailSenderUtil.sendSimpleEmail(emailSend);
+
+ // 将验证码保存到Redis中,并设置15分钟过期
+ redisTemplate.opsForValue().set(RedisUserConstant.ADMIN_EMAIL_CODE_PREFIX + email, code, 15, TimeUnit.MINUTES);
+ }
+}
diff --git a/service/service-admin/src/main/resources/application-dev.yml b/service/service-admin/src/main/resources/application-dev.yml
index 616df4b..0cbfec1 100644
--- a/service/service-admin/src/main/resources/application-dev.yml
+++ b/service/service-admin/src/main/resources/application-dev.yml
@@ -9,11 +9,16 @@ bunny:
redis:
host: 47.120.65.66
port: 6379
- database: 3
+ database: 0
password: "02120212"
minio:
endpointUrl: "http://129.211.31.58:9000"
bucket-name: ssyx
accessKey: bunny
- secretKey: "02120212"
\ No newline at end of file
+ secretKey: "02120212"
+
+ nacos:
+ server-addr: z-bunny.cn:8848
+ discovery:
+ namespace: bunnyBBS
\ No newline at end of file
diff --git a/service/service-admin/src/main/resources/application.yml b/service/service-admin/src/main/resources/application.yml
index 036eb8e..be219c3 100644
--- a/service/service-admin/src/main/resources/application.yml
+++ b/service/service-admin/src/main/resources/application.yml
@@ -6,7 +6,10 @@ spring:
active: dev
application:
name: service-admin
-
+ main:
+ lazy-initialization: true
+ jmx:
+ enabled: false
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
@@ -31,8 +34,20 @@ spring:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
+ cloud:
+ sentinel:
+ log:
+ dir: logs/${spring.application.name}/sentinel
+ nacos:
+ discovery:
+ namespace: ${bunny.nacos.discovery.namespace}
+ server-addr: ${bunny.nacos.server-addr}
+
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
+ global-config:
+ db-config:
+ logic-delete-field: isDelete
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
diff --git a/service/service-admin/src/main/resources/mapper/AdminPowerMapper.xml b/service/service-admin/src/main/resources/mapper/AdminPowerMapper.xml
new file mode 100644
index 0000000..b57bbf3
--- /dev/null
+++ b/service/service-admin/src/main/resources/mapper/AdminPowerMapper.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, power_name, power_code, description, create_time, update_time, update_user, is_delete
+
+
+
+
+
+
+
+
diff --git a/service/service-admin/src/main/resources/mapper/AdminRoleMapper.xml b/service/service-admin/src/main/resources/mapper/AdminRoleMapper.xml
new file mode 100644
index 0000000..006a91b
--- /dev/null
+++ b/service/service-admin/src/main/resources/mapper/AdminRoleMapper.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, role_name, description, role_code, create_time, update_time, update_user, is_deleted
+
+
+
+
+
diff --git a/service/service-admin/src/main/resources/mapper/EmailUsersMapper.xml b/service/service-admin/src/main/resources/mapper/EmailUsersMapper.xml
new file mode 100644
index 0000000..6c2bfe9
--- /dev/null
+++ b/service/service-admin/src/main/resources/mapper/EmailUsersMapper.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, email, password, host, port, create_time, update_time, update_user, is_delete
+
+
+
+
+ delete
+ from email_users
+ where id = #{id}
+
+
+
diff --git a/service/service-admin/src/main/resources/mapper/UserMapper.xml b/service/service-admin/src/main/resources/mapper/UserMapper.xml
new file mode 100644
index 0000000..2b190fc
--- /dev/null
+++ b/service/service-admin/src/main/resources/mapper/UserMapper.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, nick_name, email, password, avatar, sex, person_description, join_time, last_login_time, last_login_ip, last_login_ip_address, total_integral, current_integral, status, create_time, update_time, update_user, is_deleted
+
+
+
+
+
diff --git a/service/service-web/pom.xml b/service/service-web/pom.xml
index 6a7c3e7..7459383 100644
--- a/service/service-web/pom.xml
+++ b/service/service-web/pom.xml
@@ -10,7 +10,7 @@
service-web
jar
- service-main
+ service-web
https://maven.apache.org
@@ -21,48 +21,26 @@
-
- cn.bunny
- spring-security
- 0.0.1-SNAPSHOT
-
-
-
- cn.bunny
- service-utils
- 0.0.1-SNAPSHOT
-
cn.bunny
module-mail
0.0.1-SNAPSHOT
+
+ cn.bunny
+ common-utils
+ 0.0.1-SNAPSHOT
+
cn.bunny
module-minio
0.0.1-SNAPSHOT
-
-
- org.aspectj
- aspectjrt
-
-
- org.aspectj
- aspectjweaver
-
-
-
- org.springframework.cloud
- spring-cloud-starter-loadbalancer
- 4.1.2
-
-
-
- com.alibaba.cloud
- spring-cloud-starter-alibaba-nacos-discovery
- 2023.0.0.0-RC1
-
+
+
+
+
+
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/ServiceWebApplication.java b/service/service-web/src/main/java/cn/bunny/service/web/ServiceWebApplication.java
index d7bdf63..0a19e1b 100644
--- a/service/service-web/src/main/java/cn/bunny/service/web/ServiceWebApplication.java
+++ b/service/service-web/src/main/java/cn/bunny/service/web/ServiceWebApplication.java
@@ -6,12 +6,17 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@Slf4j
@ComponentScan(basePackages = {"cn.bunny"})
@MapperScan("cn.bunny.service.web.mapper")
@EnableCaching// 开启缓存注解
+@EnableScheduling// 开启task
+// @EnableFeignClients(basePackages = {"cn.bunny.feign.admin"})
+@EnableTransactionManagement // 开启注解方式的事务管理
public class ServiceWebApplication {
public static void main(String[] args) {
log.info("ServiceApplication启动...");
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/config/Knife4jConfig.java b/service/service-web/src/main/java/cn/bunny/service/web/config/Knife4jConfig.java
new file mode 100644
index 0000000..5d354de
--- /dev/null
+++ b/service/service-web/src/main/java/cn/bunny/service/web/config/Knife4jConfig.java
@@ -0,0 +1,40 @@
+package cn.bunny.service.web.config;
+
+import io.swagger.v3.oas.models.ExternalDocumentation;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Contact;
+import io.swagger.v3.oas.models.info.Info;
+import io.swagger.v3.oas.models.info.License;
+import lombok.extern.slf4j.Slf4j;
+import org.springdoc.core.models.GroupedOpenApi;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@Slf4j
+public class Knife4jConfig {
+ @Bean
+ public OpenAPI openAPI() {
+ log.info("Knife4jConfig===>配置knife4j");
+ // 作者等信息
+ Contact contact = new Contact().name("Bunny").email("1319900154@qq.com").url("http://z-bunny.com");
+ // 使用协议
+ License license = new License().name("MIT").url("http://MUT.com");
+ // 相关信息
+ Info info = new Info().title("Bunny-Java-Template").description("Bunny的Java模板").version("v1.0.0").contact(contact).license(license);
+
+ return new OpenAPI().info(info).externalDocs(new ExternalDocumentation());
+ }
+
+ // 管理员相关分类接口
+ @Bean
+ public GroupedOpenApi groupedOpenApi() {
+ return GroupedOpenApi.builder().group("前台接口管理").pathsToMatch("/api/**").build();
+ }
+
+ // 测试相关分类接口
+ @Bean
+ public GroupedOpenApi testGroupedOpenApi() {
+ return GroupedOpenApi.builder().group("测试相关分类接口").pathsToMatch("/test/**").build();
+ }
+}
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/config/WebMvcConfiguration.java b/service/service-web/src/main/java/cn/bunny/service/web/config/WebMvcConfiguration.java
similarity index 52%
rename from common/service-utils/src/main/java/cn/bunny/common/service/config/WebMvcConfiguration.java
rename to service/service-web/src/main/java/cn/bunny/service/web/config/WebMvcConfiguration.java
index 7624b83..197bcfe 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/config/WebMvcConfiguration.java
+++ b/service/service-web/src/main/java/cn/bunny/service/web/config/WebMvcConfiguration.java
@@ -1,22 +1,18 @@
-package cn.bunny.common.service.config;
+package cn.bunny.service.web.config;
+import cn.bunny.service.web.interceptor.UserTokenInterceptor;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@Slf4j
public class WebMvcConfiguration implements WebMvcConfigurer {
- @Override
- public void addResourceHandlers(ResourceHandlerRegistry registry) {
- log.info("WebMvcConfiguration===>设置");
-
- registry.addResourceHandler("/favicon.ico").addResourceLocations("classpath:/");
- registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
- registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
- }
+ @Autowired
+ private UserTokenInterceptor userTokenInterceptor;
/**
* 跨域配置
@@ -31,4 +27,12 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
// 放行哪些原始域
.allowedOriginPatterns("*").allowedMethods("GET", "POST", "PUT", "DELETE").allowedHeaders("*").exposedHeaders("*");
}
+
+ @Override
+ public void addInterceptors(InterceptorRegistry registry) {
+ String[] excludeList = {"/api/checkCode", "/api/sendEmailCode", "/api/register", "/api/login", "/api/article/loadArticle/**"};
+ log.info("WebMvcConfiguration===>开始注册自定义拦截器...");
+ registry.addInterceptor(userTokenInterceptor).addPathPatterns("/api/**")
+ .excludePathPatterns(excludeList);
+ }
}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/controller/IndexController.java b/service/service-web/src/main/java/cn/bunny/service/web/controller/IndexController.java
new file mode 100644
index 0000000..7588cd8
--- /dev/null
+++ b/service/service-web/src/main/java/cn/bunny/service/web/controller/IndexController.java
@@ -0,0 +1,16 @@
+package cn.bunny.service.web.controller;
+
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Tag(name = "访问索引页")
+@RestController
+@RequestMapping("/")
+public class IndexController {
+ @GetMapping("")
+ public String index() {
+ return "欢迎访问 Bunny Template 微服务模板";
+ }
+}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/controller/LoginController.java b/service/service-web/src/main/java/cn/bunny/service/web/controller/LoginController.java
index 8ca67d9..c44781d 100644
--- a/service/service-web/src/main/java/cn/bunny/service/web/controller/LoginController.java
+++ b/service/service-web/src/main/java/cn/bunny/service/web/controller/LoginController.java
@@ -1,10 +1,11 @@
package cn.bunny.service.web.controller;
-import cn.bunny.common.result.utils.Result;
-import cn.bunny.dto.LoginDto;
+import cn.bunny.dto.user.LoginDto;
+import cn.bunny.dto.user.RegisterDto;
+import cn.bunny.result.Result;
import cn.bunny.service.web.service.LoginService;
-import cn.bunny.vo.system.LoginVo;
-import cn.bunny.vo.system.ValidateCodeVo;
+import cn.bunny.vo.system.login.LoginVo;
+import cn.bunny.vo.system.login.ValidateCodeVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,4 +31,25 @@ public class LoginController {
ValidateCodeVo vo = loginService.checkCode();
return Result.success(vo);
}
+
+ @Operation(summary = "发送邮箱验证码", description = "发送邮箱验证码")
+ @PostMapping("sendEmailCode")
+ public Result sendEmailCode(String email) {
+ loginService.sendEmailCode(email);
+ return Result.success();
+ }
+
+ @Operation(summary = "注册用户", description = "注册用户")
+ @PostMapping("register")
+ public Result register(@RequestBody RegisterDto registerDto) {
+ loginService.register(registerDto);
+ return Result.success();
+ }
+
+ @Operation(summary = "退出登录", description = "退出登录")
+ @PostMapping("logout")
+ public Result logout() {
+ loginService.logout();
+ return Result.success();
+ }
}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/controller/UserController.java b/service/service-web/src/main/java/cn/bunny/service/web/controller/UserController.java
deleted file mode 100644
index 1fad15f..0000000
--- a/service/service-web/src/main/java/cn/bunny/service/web/controller/UserController.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package cn.bunny.service.web.controller;
-
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- *
- * 用户信息 前端控制器
- *
- *
- * @author Bunny
- * @since 2024-05-13
- */
-@RestController
-@RequestMapping("/user")
-public class UserController {
-
-}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/controller/UserIntegralRecordController.java b/service/service-web/src/main/java/cn/bunny/service/web/controller/UserIntegralRecordController.java
deleted file mode 100644
index 727cf66..0000000
--- a/service/service-web/src/main/java/cn/bunny/service/web/controller/UserIntegralRecordController.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package cn.bunny.service.web.controller;
-
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- *
- * 用户积分记录表 前端控制器
- *
- *
- * @author Bunny
- * @since 2024-05-13
- */
-@RestController
-@RequestMapping("/userIntegralRecord")
-public class UserIntegralRecordController {
-
-}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/controller/UserRoleController.java b/service/service-web/src/main/java/cn/bunny/service/web/controller/UserRoleController.java
deleted file mode 100644
index c222e9f..0000000
--- a/service/service-web/src/main/java/cn/bunny/service/web/controller/UserRoleController.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package cn.bunny.service.web.controller;
-
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- *
- * 前端控制器
- *
- *
- * @author Bunny
- * @since 2024-05-13
- */
-@RestController
-@RequestMapping("/userRole")
-public class UserRoleController {
-
-}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/interceptor/UserTokenInterceptor.java b/service/service-web/src/main/java/cn/bunny/service/web/interceptor/UserTokenInterceptor.java
new file mode 100644
index 0000000..3dbf895
--- /dev/null
+++ b/service/service-web/src/main/java/cn/bunny/service/web/interceptor/UserTokenInterceptor.java
@@ -0,0 +1,54 @@
+package cn.bunny.service.web.interceptor;
+
+import cn.bunny.result.constant.RedisUserConstant;
+import cn.bunny.result.ResultCodeEnum;
+import cn.bunny.result.Result;
+import cn.bunny.common.service.context.BaseContext;
+import cn.bunny.common.service.utils.JwtHelper;
+import cn.bunny.common.service.utils.ResponseUtil;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.lang.Nullable;
+import org.springframework.stereotype.Component;
+import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+@Component
+@Slf4j
+public class UserTokenInterceptor implements HandlerInterceptor {
+ @Autowired
+ private RedisTemplate redisTemplate;
+
+ @Override
+ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+ log.info("UserTokenInterceptor===>设置拦截器");
+ String token = request.getHeader("token");
+ Long userId = JwtHelper.getUserId(token);
+ String username = JwtHelper.getUsername(token);
+ Object redisUserinfo = redisTemplate.opsForValue().get(RedisUserConstant.getUserLoginInfoPrefix(username));
+
+ // 不是动态方法直接返回
+ if (!(handler instanceof HandlerMethod)) return true;
+ // 解析不到userId
+ if (userId == null) {
+ ResponseUtil.out(response, Result.error(ResultCodeEnum.LOGIN_AUTH));
+ return false;
+ }
+ if (redisUserinfo == null) {
+ ResponseUtil.out(response, Result.error(ResultCodeEnum.LOGIN_AUTH));
+ return false;
+ }
+
+ BaseContext.setUserId(userId);
+ BaseContext.setUsername(username);
+ return true;
+ }
+
+ @Override
+ public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception {
+ BaseContext.removeUser();
+ }
+}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/mapper/UserIntegralRecordMapper.java b/service/service-web/src/main/java/cn/bunny/service/web/mapper/EmailTemplateMapper.java
similarity index 50%
rename from service/service-web/src/main/java/cn/bunny/service/web/mapper/UserIntegralRecordMapper.java
rename to service/service-web/src/main/java/cn/bunny/service/web/mapper/EmailTemplateMapper.java
index 257458d..bb7521d 100644
--- a/service/service-web/src/main/java/cn/bunny/service/web/mapper/UserIntegralRecordMapper.java
+++ b/service/service-web/src/main/java/cn/bunny/service/web/mapper/EmailTemplateMapper.java
@@ -1,18 +1,18 @@
package cn.bunny.service.web.mapper;
-import cn.bunny.entity.system.UserIntegralRecord;
+import cn.bunny.entity.system.email.EmailTemplate;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
*
- * 用户积分记录表 Mapper 接口
+ * Mapper 接口
*
*
* @author Bunny
- * @since 2024-05-13
+ * @since 2024-05-19
*/
@Mapper
-public interface UserIntegralRecordMapper extends BaseMapper {
+public interface EmailTemplateMapper extends BaseMapper {
}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/mapper/UserRoleMapper.java b/service/service-web/src/main/java/cn/bunny/service/web/mapper/EmailUsersMapper.java
similarity index 60%
rename from service/service-web/src/main/java/cn/bunny/service/web/mapper/UserRoleMapper.java
rename to service/service-web/src/main/java/cn/bunny/service/web/mapper/EmailUsersMapper.java
index fd5e6e1..b087ba0 100644
--- a/service/service-web/src/main/java/cn/bunny/service/web/mapper/UserRoleMapper.java
+++ b/service/service-web/src/main/java/cn/bunny/service/web/mapper/EmailUsersMapper.java
@@ -1,6 +1,6 @@
package cn.bunny.service.web.mapper;
-import cn.bunny.entity.system.UserRole;
+import cn.bunny.entity.system.email.EmailUsers;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@@ -10,9 +10,9 @@ import org.apache.ibatis.annotations.Mapper;
*
*
* @author Bunny
- * @since 2024-05-13
+ * @since 2024-05-14
*/
@Mapper
-public interface UserRoleMapper extends BaseMapper {
+public interface EmailUsersMapper extends BaseMapper {
}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/mapper/UserMapper.java b/service/service-web/src/main/java/cn/bunny/service/web/mapper/UserMapper.java
index 7332cba..51361d8 100644
--- a/service/service-web/src/main/java/cn/bunny/service/web/mapper/UserMapper.java
+++ b/service/service-web/src/main/java/cn/bunny/service/web/mapper/UserMapper.java
@@ -1,7 +1,7 @@
package cn.bunny.service.web.mapper;
-import cn.bunny.entity.system.User;
-import cn.bunny.vo.system.LoginVo;
+import cn.bunny.entity.system.user.User;
+import cn.bunny.vo.system.login.LoginVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/security/CustomAuthorizationManagerServiceImpl.java b/service/service-web/src/main/java/cn/bunny/service/web/security/CustomAuthorizationManagerServiceImpl.java
deleted file mode 100644
index 608bf57..0000000
--- a/service/service-web/src/main/java/cn/bunny/service/web/security/CustomAuthorizationManagerServiceImpl.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package cn.bunny.service.web.security;
-
-import cn.bunny.security.service.CustomAuthorizationManagerService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.security.access.AccessDeniedException;
-import org.springframework.security.authorization.AuthorizationDecision;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.web.access.intercept.RequestAuthorizationContext;
-import org.springframework.stereotype.Service;
-
-import java.util.function.Supplier;
-
-
-/**
- * 自定义权限判断
- * 判断用户有哪些权限
- */
-@Service
-@Slf4j
-public class CustomAuthorizationManagerServiceImpl implements CustomAuthorizationManagerService {
- @Override
- public void verify(Supplier authentication, RequestAuthorizationContext requestAuthorizationContext) {
- CustomAuthorizationManagerService.super.verify(authentication, requestAuthorizationContext);
- }
-
- @Override
- public AuthorizationDecision check(Supplier authentication, RequestAuthorizationContext object) {
- String token = object.getRequest().getHeader("token");
-
- if (token == null) {
- throw new AccessDeniedException("");
- }
-
- return new AuthorizationDecision(true);
- }
-}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/service/LoginService.java b/service/service-web/src/main/java/cn/bunny/service/web/service/LoginService.java
index 433c1b0..4c58e1f 100644
--- a/service/service-web/src/main/java/cn/bunny/service/web/service/LoginService.java
+++ b/service/service-web/src/main/java/cn/bunny/service/web/service/LoginService.java
@@ -1,9 +1,10 @@
package cn.bunny.service.web.service;
-import cn.bunny.dto.LoginDto;
-import cn.bunny.entity.system.User;
-import cn.bunny.vo.system.LoginVo;
-import cn.bunny.vo.system.ValidateCodeVo;
+import cn.bunny.dto.user.LoginDto;
+import cn.bunny.dto.user.RegisterDto;
+import cn.bunny.entity.system.user.User;
+import cn.bunny.vo.system.login.LoginVo;
+import cn.bunny.vo.system.login.ValidateCodeVo;
import com.baomidou.mybatisplus.extension.service.IService;
public interface LoginService extends IService {
@@ -21,4 +22,23 @@ public interface LoginService extends IService {
* @return 验证码生成信息
*/
ValidateCodeVo checkCode();
+
+ /**
+ * 发送邮箱验证码
+ *
+ * @param email 邮箱
+ */
+ void sendEmailCode(String email);
+
+ /**
+ * 注册用户
+ *
+ * @param registerDto 注册表单
+ */
+ void register(RegisterDto registerDto);
+
+ /**
+ * 退出登录
+ */
+ void logout();
}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/service/UserIntegralRecordService.java b/service/service-web/src/main/java/cn/bunny/service/web/service/UserIntegralRecordService.java
deleted file mode 100644
index 091d37f..0000000
--- a/service/service-web/src/main/java/cn/bunny/service/web/service/UserIntegralRecordService.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package cn.bunny.service.web.service;
-
-import cn.bunny.entity.system.UserIntegralRecord;
-import com.baomidou.mybatisplus.extension.service.IService;
-
-/**
- *
- * 用户积分记录表 服务类
- *
- *
- * @author Bunny
- * @since 2024-05-13
- */
-public interface UserIntegralRecordService extends IService {
-
-}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/service/UserRoleService.java b/service/service-web/src/main/java/cn/bunny/service/web/service/UserRoleService.java
deleted file mode 100644
index f3b6f5a..0000000
--- a/service/service-web/src/main/java/cn/bunny/service/web/service/UserRoleService.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package cn.bunny.service.web.service;
-
-import cn.bunny.entity.system.UserRole;
-import com.baomidou.mybatisplus.extension.service.IService;
-
-/**
- *
- * 服务类
- *
- *
- * @author Bunny
- * @since 2024-05-13
- */
-public interface UserRoleService extends IService {
-
-}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/service/UserService.java b/service/service-web/src/main/java/cn/bunny/service/web/service/UserService.java
index 2f5ffd4..2267eb4 100644
--- a/service/service-web/src/main/java/cn/bunny/service/web/service/UserService.java
+++ b/service/service-web/src/main/java/cn/bunny/service/web/service/UserService.java
@@ -1,6 +1,8 @@
package cn.bunny.service.web.service;
-import cn.bunny.entity.system.User;
+import cn.bunny.dto.user.ResetPwdDto;
+import cn.bunny.entity.system.user.User;
+import cn.bunny.vo.system.user.UserInfoVo;
import com.baomidou.mybatisplus.extension.service.IService;
/**
@@ -13,4 +15,24 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface UserService extends IService {
+ /**
+ * 重置密码
+ *
+ * @param dto 重置密码参数
+ */
+ void resetPwd(ResetPwdDto dto);
+
+ /**
+ * 获取当前登录用户信息
+ *
+ * @return 获取用户信息返回参数
+ */
+ UserInfoVo getCurrentUserInfo();
+
+ /**
+ * 获取登录用户信息
+ *
+ * @return 获取用户信息返回参数
+ */
+ UserInfoVo getUserInfo(Long userId);
}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/service/impl/LoginServiceImpl.java b/service/service-web/src/main/java/cn/bunny/service/web/service/impl/LoginServiceImpl.java
index c4c22df..057b182 100644
--- a/service/service-web/src/main/java/cn/bunny/service/web/service/impl/LoginServiceImpl.java
+++ b/service/service-web/src/main/java/cn/bunny/service/web/service/impl/LoginServiceImpl.java
@@ -1,17 +1,33 @@
package cn.bunny.service.web.service.impl;
-import cn.bunny.common.result.constant.CommonMessageConstant;
+import cn.bunny.common.service.context.BaseContext;
+import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.common.service.utils.EmptyUtil;
import cn.bunny.common.service.utils.JwtHelper;
-import cn.bunny.dto.LoginDto;
-import cn.bunny.entity.system.User;
+import cn.bunny.dto.user.LoginDto;
+import cn.bunny.dto.user.RegisterDto;
+import cn.bunny.entity.system.email.EmailSend;
+import cn.bunny.entity.system.email.EmailSendInit;
+import cn.bunny.entity.system.email.EmailTemplate;
+import cn.bunny.entity.system.email.EmailUsers;
+import cn.bunny.entity.system.user.User;
+import cn.bunny.module.mail.utils.MailSenderUtil;
+import cn.bunny.result.constant.ExceptionConstant;
+import cn.bunny.result.constant.MailMessageConstant;
+import cn.bunny.result.constant.RedisUserConstant;
+import cn.bunny.result.constant.UserConstant;
+import cn.bunny.service.web.mapper.EmailTemplateMapper;
+import cn.bunny.service.web.mapper.EmailUsersMapper;
import cn.bunny.service.web.mapper.UserMapper;
import cn.bunny.service.web.service.LoginService;
-import cn.bunny.vo.system.LoginVo;
-import cn.bunny.vo.system.ValidateCodeVo;
+import cn.bunny.vo.system.login.LoginVo;
+import cn.bunny.vo.system.login.ValidateCodeVo;
import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.CircleCaptcha;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@@ -26,6 +42,10 @@ public class LoginServiceImpl extends ServiceImpl implements L
private UserMapper userMapper;
@Autowired
private RedisTemplate redisTemplate;
+ @Autowired
+ private EmailUsersMapper emailUsersMapper;
+ @Autowired
+ private EmailTemplateMapper emailTemplateMapper;
/**
* 前台用户登录接口
@@ -37,16 +57,23 @@ public class LoginServiceImpl extends ServiceImpl implements L
public LoginVo login(LoginDto loginDto) {
// 判断用户和密码是否为空
String username = loginDto.getUsername();
- EmptyUtil.isEmpty(username, CommonMessageConstant.USERNAME_NOT_EMPTY);
+ EmptyUtil.isEmpty(username, ExceptionConstant.USERNAME_IS_EMPTY_Exception);
// 密码不能为空
- EmptyUtil.isEmpty(loginDto.getPassword(), CommonMessageConstant.PASSWORD_NOT_EMPTY);
+ EmptyUtil.isEmpty(loginDto.getPassword(), ExceptionConstant.PASSWORD_NOT_EMPTY_Exception);
String password = DigestUtils.md5DigestAsHex(loginDto.getPassword().getBytes());
// 设置返回类型
LoginVo loginVo = userMapper.login(username, password);
- String token = JwtHelper.createToken(Long.valueOf(loginVo.getUserId()), loginVo.getEmail(), 7);
+ String token = JwtHelper.createToken(loginVo.getId(), loginVo.getEmail(), 7);
loginVo.setToken(token);
+ // 用户是否被锁定
+ if (loginVo.getStatus() == 1) {
+ throw new BunnyException(ExceptionConstant.ACCOUNT_LOCKED_Exception);
+ }
+
+ // 将信息存入Redis中
+ redisTemplate.opsForValue().set(RedisUserConstant.getUserLoginInfoPrefix(loginVo.getEmail()), loginVo, 15, TimeUnit.DAYS);
return loginVo;
}
@@ -66,4 +93,82 @@ public class LoginServiceImpl extends ServiceImpl implements L
redisTemplate.opsForValue().set(uuid, code, 10, TimeUnit.MINUTES);
return ValidateCodeVo.builder().codeKey(uuid).codeValue(base64Image).build();
}
+
+ /**
+ * 发送邮箱验证码
+ *
+ * @param email 邮箱
+ */
+ @Override
+ public void sendEmailCode(String email) {
+ // 从数据库中获取,发送邮箱参数,发送邮件模板
+ EmailUsers emailUsers = emailUsersMapper.selectOne(Wrappers.lambdaQuery().eq(EmailUsers::getIsDefault, 1));
+ EmailTemplate emailSendTemplate = emailTemplateMapper.selectOne(Wrappers.lambdaQuery().eq(EmailTemplate::getId, 1791870020197625858L));
+ EmailSendInit emailSendInit = new EmailSendInit();
+ // 判断发送邮箱邮件是否为空
+ EmptyUtil.isEmpty(emailUsers, MailMessageConstant.EMAIL_CONFIG_NOT_FOUND);
+ BeanUtils.copyProperties(emailUsers, emailSendInit);
+ emailSendInit.setUsername(emailUsers.getEmail());
+ // 生成验证码
+ MailSenderUtil mailSenderUtil = new MailSenderUtil(emailSendInit);
+ CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(150, 48, 4, 2);
+ // 生成验证码和可以
+ String code = captcha.getCode();
+ String htmlContent = emailSendTemplate.getBody().replace("${verifyCode}", code);
+ // 发送验证码
+ EmailSend emailSend = new EmailSend();
+ emailSend.setSubject("邮箱验证码");
+ emailSend.setMessage(htmlContent);
+ emailSend.setSendTo(email);
+ emailSend.setIsRichText(true);
+ mailSenderUtil.sendSimpleEmail(emailSend);
+
+ // 将验证码保存到Redis中,并设置15分钟过期
+ redisTemplate.opsForValue().set(RedisUserConstant.USER_EMAIL_CODE_PREFIX + email, code, 15, TimeUnit.MINUTES);
+ }
+
+ /**
+ * 注册用户
+ *
+ * @param registerDto 注册表单
+ */
+ @Override
+ public void register(RegisterDto registerDto) {
+ String nickName = registerDto.getNickName();
+ String email = registerDto.getEmail();
+ // 查询用户是否已经注册
+ LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>();
+ lambdaQueryWrapper.eq(User::getEmail, email).or().eq(User::getNickName, nickName);
+ User user = userMapper.selectOne(lambdaQueryWrapper);
+
+ // 用户存在保存
+ if (user != null) throw new BunnyException(ExceptionConstant.ALREADY_USER_Exception);
+ // 判断验证码是否正确
+ Object emailCode = redisTemplate.opsForValue().get(RedisUserConstant.getUserEmailCodePrefix(email));
+ if (!registerDto.getCode().equalsIgnoreCase(String.valueOf(emailCode))) {
+ throw new BunnyException(ExceptionConstant.VERIFICATION_CODE_ERROR_Exception);
+ }
+
+ // 用户没有注册时才去注册
+ user = new User();
+ BeanUtils.copyProperties(registerDto, user);
+ user.setPassword(DigestUtils.md5DigestAsHex(registerDto.getPassword().getBytes()));
+ user.setAvatar(UserConstant.USER_AVATAR);
+ save(user);
+
+ // 删除邮箱验证码
+ redisTemplate.delete(RedisUserConstant.getUserEmailCodePrefix(registerDto.getEmail()));
+ }
+
+ /**
+ * 退出登录
+ */
+ @Override
+ public void logout() {
+ Long userId = BaseContext.getUserId();
+ // 查询当前用户信息
+ User user = getById(userId);
+ // 删除Redis中用户信息
+ redisTemplate.delete(RedisUserConstant.getUserLoginInfoPrefix(user.getEmail()));
+ }
}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/service/impl/UserIntegralRecordServiceImpl.java b/service/service-web/src/main/java/cn/bunny/service/web/service/impl/UserIntegralRecordServiceImpl.java
deleted file mode 100644
index 072bf9d..0000000
--- a/service/service-web/src/main/java/cn/bunny/service/web/service/impl/UserIntegralRecordServiceImpl.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package cn.bunny.service.web.service.impl;
-
-import cn.bunny.entity.system.UserIntegralRecord;
-import cn.bunny.service.web.mapper.UserIntegralRecordMapper;
-import cn.bunny.service.web.service.UserIntegralRecordService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.stereotype.Service;
-
-/**
- *
- * 用户积分记录表 服务实现类
- *
- *
- * @author Bunny
- * @since 2024-05-13
- */
-@Service
-public class UserIntegralRecordServiceImpl extends ServiceImpl implements UserIntegralRecordService {
-
-}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/service/impl/UserRoleServiceImpl.java b/service/service-web/src/main/java/cn/bunny/service/web/service/impl/UserRoleServiceImpl.java
deleted file mode 100644
index 1758324..0000000
--- a/service/service-web/src/main/java/cn/bunny/service/web/service/impl/UserRoleServiceImpl.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package cn.bunny.service.web.service.impl;
-
-import cn.bunny.entity.system.UserRole;
-import cn.bunny.service.web.mapper.UserRoleMapper;
-import cn.bunny.service.web.service.UserRoleService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.stereotype.Service;
-
-/**
- *
- * 服务实现类
- *
- *
- * @author Bunny
- * @since 2024-05-13
- */
-@Service
-public class UserRoleServiceImpl extends ServiceImpl implements UserRoleService {
-
-}
diff --git a/service/service-web/src/main/java/cn/bunny/service/web/service/impl/UserServiceImpl.java b/service/service-web/src/main/java/cn/bunny/service/web/service/impl/UserServiceImpl.java
index e63451a..038df86 100644
--- a/service/service-web/src/main/java/cn/bunny/service/web/service/impl/UserServiceImpl.java
+++ b/service/service-web/src/main/java/cn/bunny/service/web/service/impl/UserServiceImpl.java
@@ -1,10 +1,22 @@
package cn.bunny.service.web.service.impl;
-import cn.bunny.entity.system.User;
+import cn.bunny.common.service.context.BaseContext;
+import cn.bunny.common.service.exception.BunnyException;
+import cn.bunny.common.service.utils.EmptyUtil;
+import cn.bunny.dto.user.ResetPwdDto;
+import cn.bunny.entity.system.user.User;
+import cn.bunny.result.constant.ExceptionConstant;
+import cn.bunny.result.constant.RedisUserConstant;
import cn.bunny.service.web.mapper.UserMapper;
import cn.bunny.service.web.service.UserService;
+import cn.bunny.vo.system.user.UserInfoVo;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
+import org.springframework.util.DigestUtils;
/**
*
@@ -16,5 +28,78 @@ import org.springframework.stereotype.Service;
*/
@Service
public class UserServiceImpl extends ServiceImpl implements UserService {
+ @Autowired
+ private RedisTemplate redisTemplate;
+ @Autowired
+ private UserMapper userMapper;
+ /**
+ * 重置密码
+ *
+ * @param dto 重置密码参数
+ */
+ @Override
+ public void resetPwd(ResetPwdDto dto) {
+ String username = dto.getEmail();
+ String password = dto.getPassword();
+ String emailCode = dto.getEmailCode().toLowerCase();
+ Long userId = BaseContext.getUserId();
+ String redisEmailCode = (String) redisTemplate.opsForValue().get(RedisUserConstant.getUserEmailCodePrefix(dto.getEmail()));
+
+ // 判断邮箱验证码是否正确
+ EmptyUtil.isEmpty(redisEmailCode, ExceptionConstant.PLEASE_SEND_EMAIL_CODE_Exception);
+ if (!emailCode.equals(redisEmailCode.toLowerCase()))
+ throw new BunnyException(ExceptionConstant.VERIFICATION_CODE_ERROR_Exception);
+
+ // 查询用户信息
+ LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>();
+ lambdaQueryWrapper.eq(User::getEmail, username).or().eq(User::getNickName, username);
+ User user = getOne(lambdaQueryWrapper);
+
+ // 用户不存在
+ if (user == null) throw new BunnyException(ExceptionConstant.USER_NOT_FOUND_Exception);
+
+ user = new User();
+ user.setPassword(DigestUtils.md5DigestAsHex(password.getBytes()));
+ user.setId(userId);
+
+ // 更新用户
+ updateById(user);
+
+ // 删除邮箱验证码
+ redisTemplate.delete(RedisUserConstant.getUserEmailCodePrefix(dto.getEmail()));
+ }
+
+
+ /**
+ * 获取当前登录用户信息
+ *
+ * @return 获取用户信息返回参数
+ */
+ @Override
+ public UserInfoVo getCurrentUserInfo() {
+ UserInfoVo userInfo = new UserInfoVo();
+ User user = getById(BaseContext.getUserId());
+ BeanUtils.copyProperties(user, userInfo);
+
+ return userInfo;
+ }
+
+
+ /**
+ * 获取登录用户信息
+ *
+ * @param userId 用户id
+ * @return 获取用户信息返回参数
+ */
+ @Override
+ public UserInfoVo getUserInfo(Long userId) {
+ UserInfoVo userInfoVo = new UserInfoVo();
+ User user = userMapper.selectById(userId);
+
+ if (user == null) throw new BunnyException(ExceptionConstant.USER_NOT_FOUND_Exception);
+ BeanUtils.copyProperties(user, userInfoVo);
+
+ return userInfoVo;
+ }
}
diff --git a/service/service-web/src/main/resources/application-dev.yml b/service/service-web/src/main/resources/application-dev.yml
index 0209e71..668d3b3 100644
--- a/service/service-web/src/main/resources/application-dev.yml
+++ b/service/service-web/src/main/resources/application-dev.yml
@@ -9,12 +9,12 @@ bunny:
redis:
host: 47.120.65.66
port: 6379
- database: 3
+ database: 1
password: "02120212"
minio:
endpointUrl: "http://129.211.31.58:9000"
- bucket-name: ssyx
+ bucket-name: bunny-bbs
accessKey: bunny
secretKey: "02120212"
diff --git a/service/service-web/src/main/resources/application.yml b/service/service-web/src/main/resources/application.yml
index 0ec40d1..2ce2552 100644
--- a/service/service-web/src/main/resources/application.yml
+++ b/service/service-web/src/main/resources/application.yml
@@ -6,6 +6,11 @@ spring:
active: dev
application:
name: service-web
+ main:
+ lazy-initialization: true
+ jmx:
+ enabled: false
+
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
@@ -39,10 +44,18 @@ spring:
namespace: ${bunny.nacos.discovery.namespace}
server-addr: ${bunny.nacos.server-addr}
+
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
+ # cache-enabled: false
+ global-config:
+ db-config:
+ id-type: assign_id # 设置为雪花算法
+ logic-delete-value: 1
+ logic-not-delete-value: 0
+ logic-delete-field: id
logging:
level:
diff --git a/service/service-web/src/main/resources/mapper/EmailTemplateMapper.xml b/service/service-web/src/main/resources/mapper/EmailTemplateMapper.xml
new file mode 100644
index 0000000..a14de6b
--- /dev/null
+++ b/service/service-web/src/main/resources/mapper/EmailTemplateMapper.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, template_name, subject, body, type, create_time, update_time, update_user, is_deleted
+
+
+
diff --git a/service/service-web/src/main/resources/mapper/EmailUsersMapper.xml b/service/service-web/src/main/resources/mapper/EmailUsersMapper.xml
new file mode 100644
index 0000000..f16ab7d
--- /dev/null
+++ b/service/service-web/src/main/resources/mapper/EmailUsersMapper.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, email, password, host, port, create_time, update_time, update_user, is_delete
+
+
+
+
+ delete
+ from email_users
+ where id = #{id}
+
+
+
diff --git a/service/service-web/src/main/resources/mapper/UserIntegralRecordMapper.xml b/service/service-web/src/main/resources/mapper/UserIntegralRecordMapper.xml
deleted file mode 100644
index 198bd01..0000000
--- a/service/service-web/src/main/resources/mapper/UserIntegralRecordMapper.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- user_id, oper_type, integral, create_time
-
-
-
diff --git a/service/service-web/src/main/resources/mapper/UserMapper.xml b/service/service-web/src/main/resources/mapper/UserMapper.xml
index a45e006..3723891 100644
--- a/service/service-web/src/main/resources/mapper/UserMapper.xml
+++ b/service/service-web/src/main/resources/mapper/UserMapper.xml
@@ -1,19 +1,11 @@
-
-
-
- user_id, nick_name, email, password, sex, person_description, join_time, last_login_time, last_login_ip, last_login_ip_address, total_integral, current_integral, status
-
-
-
diff --git a/service/service-web/src/main/resources/mapper/UserRoleMapper.xml b/service/service-web/src/main/resources/mapper/UserRoleMapper.xml
deleted file mode 100644
index 332b514..0000000
--- a/service/service-web/src/main/resources/mapper/UserRoleMapper.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- id, user_id, role_name, description, role_code, create_time, update_time
-
-
-
diff --git a/service/service-web/src/main/resources/templates/email-template.html b/service/service-web/src/main/resources/templates/email-template.html
new file mode 100644
index 0000000..7c4b0b6
--- /dev/null
+++ b/service/service-web/src/main/resources/templates/email-template.html
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+ Email Verification Code
+
+
+
+
+
+
+ BunnyBBS邮箱验证码
+ |
+
+
+
+
+
+ 尊敬的用户,
+
+
+ 感谢您注册我们的产品. 您的账号正在进行电子邮件验证.
+
+
+ 验证码为: ${verifyCode}
+
+
+ 验证码的有效期只有一分钟,请抓紧时间进行验证吧!
+
+
+ 如果非本人操作,请忽略此邮件
+
+
+ |
+
+
+
+
+ XXXXX
+ Contact us: XXXXXXX@qq.com
+
+
+ This is an automated email, please do not reply.
+ © Company Name
+
+ |
+
+
+
+
+
\ No newline at end of file
diff --git a/service/service-web/src/test/java/cn/bunny/service/web/service/impl/CommentServiceImplTest.java b/service/service-web/src/test/java/cn/bunny/service/web/service/impl/CommentServiceImplTest.java
new file mode 100644
index 0000000..acaf5d0
--- /dev/null
+++ b/service/service-web/src/test/java/cn/bunny/service/web/service/impl/CommentServiceImplTest.java
@@ -0,0 +1,45 @@
+package cn.bunny.service.web.service.impl;
+
+import cn.bunny.common.utils.CommentUtil;
+import cn.bunny.dto.common.CommentQueryDto;
+import cn.bunny.entity.system.article.ForumComment;
+import cn.bunny.vo.system.comment.CommentVo;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@SpringBootTest
+class CommentServiceImplTest {
+ @Autowired
+ private CommentMapper commentMapper;
+
+ /**
+ * 获取文章评论
+ */
+ @Test
+ public void loadComment() {
+ CommentQueryDto dto = new CommentQueryDto();
+ dto.setArticleId("RtiXj832TFL4nhW");
+ // 返回参数
+ ArrayList list = new ArrayList<>();
+ // 查询
+ Page page = new Page<>(1, 6);
+ IPage commentList = commentMapper.loadComment(page, dto);
+
+ // 准备返回值
+ commentList.getRecords().forEach(forumComments -> {
+ CommentVo commentVo = new CommentVo();
+ BeanUtils.copyProperties(forumComments, commentVo);
+ list.add(commentVo);
+ });
+
+ List buildTree = CommentUtil.buildTree(list);
+ System.out.println(buildTree);
+ }
+}
\ No newline at end of file