diff --git a/config/application-common.yml b/config/application-common.yml
index 1faaba8..c730538 100644
--- a/config/application-common.yml
+++ b/config/application-common.yml
@@ -52,6 +52,10 @@ spring :
mode : always
enabled : true
+ spring:
+ messages:
+ basename: i18n/messages
+
#mybatis
mybatis :
mapper-locations : classpath*:mappers/*.xml
diff --git a/config/application-test.yml b/config/application-test.yml
index fa52a82..a34658e 100644
--- a/config/application-test.yml
+++ b/config/application-test.yml
@@ -5,12 +5,12 @@ spring :
data-locations : file:../config/rbac/data.sql
datasource:
- url : jdbc:mysql://xajhuang.com:3307/common_framework?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true
- username : xajhuang
- password : wkj!nky5cjb!GMV6guq
- #url : jdbc:mysql://localhost:3306/common_framework?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true
- #username : root
- #password : aaaHuang1
+ #url : jdbc:mysql://xajhuang.com:3307/common_framework?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true
+ #username : xajhuang
+ #password : wkj!nky5cjb!GMV6guq
+ url : jdbc:mysql://localhost:3306/common_framework?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true
+ username : root
+ password : aaaHuang1
#config log
logging :
diff --git a/cs-base/src/main/java/com/cf/cs/base/config/LocaleConfig.java b/cs-base/src/main/java/com/cf/cs/base/config/LocaleConfig.java
new file mode 100644
index 0000000..be5706c
--- /dev/null
+++ b/cs-base/src/main/java/com/cf/cs/base/config/LocaleConfig.java
@@ -0,0 +1,33 @@
+package com.cf.cs.base.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.support.ResourceBundleMessageSource;
+
+import java.util.Locale;
+
+/**
+ * The type Locale config.
+ *
+ * @author xajhuang @163.com
+ */
+@Configuration
+public class LocaleConfig {
+ /**
+ * Message source resource bundle message source.
+ *
+ * @return the resource bundle message source
+ */
+ @Bean
+ public ResourceBundleMessageSource messageSource() {
+ Locale.setDefault(Locale.CHINA);
+ ResourceBundleMessageSource source = new ResourceBundleMessageSource();
+ //设置国际化文件存储路径和名称 i18n目录,messages文件名
+ source.setBasenames("i18n/messages");
+ //设置根据key如果没有获取到对应的文本信息,则返回key作为信息
+ source.setUseCodeAsDefaultMessage(true);
+ //设置字符编码
+ source.setDefaultEncoding("UTF-8");
+ return source;
+ }
+}
diff --git a/cs-base/src/main/java/com/cf/cs/base/misc/ApiContextUtils.java b/cs-base/src/main/java/com/cf/cs/base/misc/ApiContextUtils.java
index e6dc0f5..1e9b3c1 100644
--- a/cs-base/src/main/java/com/cf/cs/base/misc/ApiContextUtils.java
+++ b/cs-base/src/main/java/com/cf/cs/base/misc/ApiContextUtils.java
@@ -41,6 +41,20 @@ public class ApiContextUtils {
context.setRequestTime(reqTime);
}
+ public static String getLanguare() {
+ return HelperUtils.stringNotEmptyOrNull(get().getReqLocal()) ? get().getReqLocal() : "zh_CN";
+ }
+
+ /**
+ * Sets request local.
+ *
+ * @param local the local
+ */
+ public static void setRequestLocal(String local) {
+ ApiContext context = get();
+ context.setReqLocal(local);
+ }
+
/**
* Sets jwt user info.
*
diff --git a/cs-base/src/main/java/com/cf/cs/base/pojo/po/ApiContext.java b/cs-base/src/main/java/com/cf/cs/base/pojo/po/ApiContext.java
index 0b03dca..98aed9e 100644
--- a/cs-base/src/main/java/com/cf/cs/base/pojo/po/ApiContext.java
+++ b/cs-base/src/main/java/com/cf/cs/base/pojo/po/ApiContext.java
@@ -15,6 +15,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
public class ApiContext {
+ private String reqLocal;
private String requestBody;
private Long requestTime;
private String jwt;
diff --git a/cs-base/src/main/resources/i18n/message_en_US.properties b/cs-base/src/main/resources/i18n/message_en_US.properties
new file mode 100644
index 0000000..e9c0714
--- /dev/null
+++ b/cs-base/src/main/resources/i18n/message_en_US.properties
@@ -0,0 +1,54 @@
+ERR_OK=Successful
+ERR_PASSWORD=Incorrect password
+ERR_USERNOTFOUND=User does not exist
+ERR_PASSWORDMORE=The number of consecutive incorrect passwords reaches the upper limit
+ERR_USERLOCK=Password error reaches the upper limit, The user is locked
+ERR_PASSWORD_EXPIRED=The password has expired
+ERR_ACCOUNT=The user account is abnormal
+ERR_USEREXIST=The user already exists
+ERR_PASSWORDSIMPLE=The user password strength does not meet the requirement. ERR_INPUTFORMAT=The input information format is incorrect
+ERR_INPUTMISS=No necessary input information
+ERR_PERMISSION=Operator permission is insufficient
+ERR_REQTIMEOUT=Request timeout
+ERR_PARAMS=Parameter error
+ERR_SYSTEMEXCEPTION=System exception
+ERR_UNKNOWNCMD=unknown command
+ERR_LOGOUT=User not logged in
+ERR_TOKENTIMEOUT=Token timeout
+ERR_TOKENNOTFOUND=Illegal Token
+ERR_TOKEN_KEY=Token key error
+ERR_MISSAUTHHEAD=Http request missing authentication header
+ERR_NOSUCHITEM=No such content
+ERR_ITEMEXISTS=The content already exists
+ERR_PARAMEXCEPTION=Parameter exception
+ERR_DEVICELOCKED=Device locked
+ERR_VERSION=Protocol version incompatible, Please upgrade the system
+ERR_NOSUCHTYPE=No device of this type exists
+ERR_REMOVEMORE=Disable deleting multiple devices at the same time
+ERR_TASKRUNNING=Similar tasks are running
+ERR_UNSUPPORT=Unsupported operations
+ERR_INTERRUPT=Operation interruption
+ERR_CALLDEVICE=Failed to call the device
+ERR_NOSUCHTASK=No task
+ERR_TASKNOTRUNNING=No task is running
+ERR_REQUESTTIMEOUT=Request timeout
+ERR_UNABLEDISPOSEIP=Unable to handle the IP
+ERR_DATABASE=Failed to operate the database
+ERR_UNTRUSTHOST=Unauthorized client
+ERR_UNTRUSTTOKEN=Unauthorized Token
+ERR_UNKNOWNINTERFACE=Interface not provided
+ERR_DECRYPT_BASE64=BASE64 decryption failure
+ERR_ENCRYPT_BASE64=BASE64 encryption failure
+ERR_DECRYPT_AES128=AES128 decryption failure
+ERR_ENCRYPT_AES128=AES128 encryption failure
+ERR_DECRYPT_3DES=3DES decryption failure
+ERR_ENCRYPT_3DES=3DES Encryption failure
+ERR_DECRYPT_UNKNOWN=Unsupported decryption algorithm
+ERR_ENCRYPT_UNKNOWN=unsupported encryption algorithm
+ERR_JSON_ENCODE=Json Sequence number error
+ERR_JSON_DECODE=Json deserialization error
+ERR_ENCRYPT_AES256=AES256 Encryption failure
+ERR_DECRYPT_AES256=AES256 decryption failure
+ERR_CRYPTO_KEY=wrong secret key
+ERR_USER_ROLE_NOTEXISTS=The user role does not exist
+ERR_RESOURCE_USED=Resource used
diff --git a/cs-base/src/main/resources/i18n/message_zh_CN.properties b/cs-base/src/main/resources/i18n/message_zh_CN.properties
new file mode 100644
index 0000000..b4f8c27
--- /dev/null
+++ b/cs-base/src/main/resources/i18n/message_zh_CN.properties
@@ -0,0 +1,55 @@
+ERR_OK=\u6210\u529F
+ERR_PASSWORD=\u5BC6\u7801\u9519\u8BEF
+ERR_USERNOTFOUND=\u7528\u6237\u4E0D\u5B58\u5728
+ERR_PASSWORDMORE=\u8FDE\u7EED\u5BC6\u7801\u9519\u8BEF\u8FBE\u4E0A\u9650\uFF0C\u518D\u6B21\u8F93\u5165\u9519\u8BEF\u5C06\u9501\u5B9A\u7528\u6237
+ERR_USERLOCK=\u5BC6\u7801\u9519\u8BEF\u8FBE\u4E0A\u9650\uFF0C\u7528\u6237\u88AB\u9501\u5B9A
+ERR_PASSWORD_EXPIRED=\u5BC6\u7801\u5DF2\u7ECF\u8FC7\u671F
+ERR_ACCOUNT=\u7528\u6237\u8D26\u6237\u5F02\u5E38
+ERR_USEREXIST=\u8BE5\u7528\u6237\u5DF2\u7ECF\u5B58\u5728
+ERR_PASSWORDSIMPLE=\u7528\u6237\u5BC6\u7801\u5F3A\u5EA6\u4E0D\u7B26\u5408\u8981\u6C42
+ERR_INPUTFORMAT=\u8F93\u5165\u4FE1\u606F\u683C\u5F0F\u6709\u8BEF
+ERR_INPUTMISS=\u7F3A\u5C11\u5FC5\u8981\u8F93\u5165\u4FE1\u606F
+ERR_PERMISSION=\u64CD\u4F5C\u5458\u6743\u9650\u4E0D\u8DB3
+ERR_REQTIMEOUT=\u8BF7\u6C42\u8D85\u65F6
+ERR_PARAMS=\u53C2\u6570\u9519\u8BEF
+ERR_SYSTEMEXCEPTION=\u7CFB\u7EDF\u5F02\u5E38
+ERR_UNKNOWNCMD=\u672A\u77E5\u547D\u4EE4
+ERR_LOGOUT=\u7528\u6237\u672A\u767B\u5F55
+ERR_TOKENTIMEOUT=Token\u8D85\u65F6
+ERR_TOKENNOTFOUND=\u975E\u6CD5Token
+ERR_TOKEN_KEY=Token \u79D8\u94A5\u9519\u8BEF
+ERR_MISSAUTHHEAD=Http \u8BF7\u6C42\u7F3A\u5C11\u8BA4\u8BC1\u5934\u90E8
+ERR_NOSUCHITEM=\u6CA1\u6709\u8BE5\u5185\u5BB9
+ERR_ITEMEXISTS=\u8BE5\u5185\u5BB9\u5DF2\u7ECF\u5B58\u5728
+ERR_PARAMEXCEPTION=\u53C2\u6570\u5F02\u5E38
+ERR_DEVICELOCKED=\u8BBE\u5907\u5DF2\u9501\u5B9A
+ERR_VERSION=\u534F\u8BAE\u7248\u672C\u4E0D\u517C\u5BB9\uFF0C\u8BF7\u5347\u7EA7\u7CFB\u7EDF
+ERR_NOSUCHTYPE=\u6CA1\u6709\u8FD9\u4E2A\u7C7B\u578B\u7684\u8BBE\u5907
+ERR_REMOVEMORE=\u7981\u6B62\u540C\u65F6\u5220\u9664\u591A\u4E2A\u8BBE\u5907
+ERR_TASKRUNNING=\u540C\u7C7B\u4EFB\u52A1\u6B63\u5728\u8FD0\u884C
+ERR_UNSUPPORT=\u4E0D\u652F\u6301\u7684\u64CD\u4F5C
+ERR_INTERRUPT=\u64CD\u4F5C\u4E2D\u65AD
+ERR_CALLDEVICE=\u8C03\u7528\u8BBE\u5907\u5931\u8D25
+ERR_NOSUCHTASK=\u6CA1\u6709\u8BE5\u4EFB\u52A1
+ERR_TASKNOTRUNNING=\u8BE5\u4EFB\u52A1\u6CA1\u6709\u8FD0\u884C
+ERR_REQUESTTIMEOUT=\u8BF7\u6C42\u8D85\u65F6
+ERR_UNABLEDISPOSEIP=\u65E0\u6CD5\u5904\u7F6E\u8BE5IP
+ERR_DATABASE=\u64CD\u4F5C\u6570\u636E\u5E93\u5931\u8D25
+ERR_UNTRUSTHOST=\u672A\u7ECF\u6388\u6743\u7684\u5BA2\u6237\u7AEF
+ERR_UNTRUSTTOKEN=\u672A\u7ECF\u6388\u6743\u7684Token
+ERR_UNKNOWNINTERFACE=\u672A\u63D0\u4F9B\u8BE5\u63A5\u53E3
+ERR_DECRYPT_BASE64=BASE64\u89E3\u5BC6\u5931\u8D25
+ERR_ENCRYPT_BASE64=BASE64\u52A0\u5BC6\u5931\u8D25
+ERR_DECRYPT_AES128=AES128\u89E3\u5BC6\u5931\u8D25
+ERR_ENCRYPT_AES128=AES128\u52A0\u5BC6\u5931\u8D25
+ERR_DECRYPT_3DES=3DES\u89E3\u5BC6\u5931\u8D25
+ERR_ENCRYPT_3DES=3DES\u52A0\u5BC6\u5931\u8D25
+ERR_DECRYPT_UNKNOWN=\u4E0D\u652F\u6301\u7684\u89E3\u5BC6\u7B97\u6CD5
+ERR_ENCRYPT_UNKNOWN=\u4E0D\u652F\u6301\u7684\u52A0\u5BC6\u7B97\u6CD5
+ERR_JSON_ENCODE=Json \u5E8F\u5217\u53F7\u9519\u8BEF
+ERR_JSON_DECODE=Json \u53CD\u5E8F\u5217\u5316\u9519\u8BEF
+ERR_ENCRYPT_AES256=AES256\u52A0\u5BC6\u5931\u8D25
+ERR_DECRYPT_AES256=AES256\u89E3\u5BC6\u5931\u8D25
+ERR_CRYPTO_KEY=\u9519\u8BEF\u7684\u79D8\u94A5
+ERR_USER_ROLE_NOTEXISTS=\u7528\u6237\u89D2\u8272\u4E0D\u5B58\u5728
+ERR_RESOURCE_USED=\u8D44\u6E90\u88AB\u5360\u7528
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 4329d9c..276f057 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.springframework.boot
spring-boot-starter-parent
- 3.2.3
+ 3.2.4
@@ -81,7 +81,7 @@
org.springframework.security
spring-security-core
- 6.2.2
+ 6.2.3
com.mybatis-flex