From 216cec0dfdaddc400ac94483d6d126d44879b2d5 Mon Sep 17 00:00:00 2001 From: Spark <2666652@gmail.com> Date: Sat, 12 Oct 2024 00:34:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=20JJWT=20=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=92=8C=E5=B8=B8=E9=87=8F=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E5=9F=BA=E6=9C=AC=E4=B8=8A=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E7=9A=84=E7=BC=96=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cc/aspark/constant/MessageConstant.java | 13 +++++++++++++ .../java/cc/aspark/context/BaseContext.java | 19 +++++++++++++++++++ .../cc/aspark/properties/JwtProperties.java | 19 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 RollCallServer/src/main/java/cc/aspark/constant/MessageConstant.java create mode 100644 RollCallServer/src/main/java/cc/aspark/context/BaseContext.java create mode 100644 RollCallServer/src/main/java/cc/aspark/properties/JwtProperties.java diff --git a/RollCallServer/src/main/java/cc/aspark/constant/MessageConstant.java b/RollCallServer/src/main/java/cc/aspark/constant/MessageConstant.java new file mode 100644 index 0000000..6acf6a3 --- /dev/null +++ b/RollCallServer/src/main/java/cc/aspark/constant/MessageConstant.java @@ -0,0 +1,13 @@ +package cc.aspark.constant; + +public class MessageConstant { + + public static final String PASSWORD_ERROR = "密码错误"; + public static final String ACCOUNT_NOT_FOUND = "账号不存在"; + public static final String UNKNOWN_ERROR = "未知错误"; + public static final String USER_NOT_LOGIN = "用户未登录"; + public static final String LOGIN_FAILED = "登录失败"; + public static final String DELETE_FAILED = "删除失败"; + public static final String INVALID_INPUT = "输入无效"; + +} \ No newline at end of file diff --git a/RollCallServer/src/main/java/cc/aspark/context/BaseContext.java b/RollCallServer/src/main/java/cc/aspark/context/BaseContext.java new file mode 100644 index 0000000..368503e --- /dev/null +++ b/RollCallServer/src/main/java/cc/aspark/context/BaseContext.java @@ -0,0 +1,19 @@ +package cc.aspark.context; + +public class BaseContext { + + public static ThreadLocal threadLocal = new ThreadLocal<>(); + + public static void setCurrentId(Long id) { + threadLocal.set(id); + } + + public static Long getCurrentId() { + return threadLocal.get(); + } + + public static void removeCurrentId() { + threadLocal.remove(); + } + +} diff --git a/RollCallServer/src/main/java/cc/aspark/properties/JwtProperties.java b/RollCallServer/src/main/java/cc/aspark/properties/JwtProperties.java new file mode 100644 index 0000000..664cd60 --- /dev/null +++ b/RollCallServer/src/main/java/cc/aspark/properties/JwtProperties.java @@ -0,0 +1,19 @@ +package cc.aspark.properties; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "jwt") +@Data +public class JwtProperties { + + /** + * 管理端员工生成jwt令牌相关配置 + */ + private String secretKey; + private long ttl; + private String tokenName; + +}