diff --git a/nl-i18n-sdk/pom.xml b/nl-i18n-sdk/pom.xml
new file mode 100644
index 0000000..0e568ec
--- /dev/null
+++ b/nl-i18n-sdk/pom.xml
@@ -0,0 +1,78 @@
+
+
+ 4.0.0
+
+ org.nl
+ nl-verify-check
+ 1.0-SNAPSHOT
+
+
+ nl-i18n-sdk
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ cn.dev33
+ sa-token-spring-boot-starter
+ 1.31.0
+
+
+ com.alibaba
+ fastjson
+ 1.2.83
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.12.1
+
+
+ -parameters
+
+ 17
+ 17
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.3.0
+
+ true
+
+
+
+ compile
+
+ jar
+
+
+
+
+
+
+
+ src/main/resources
+
+
+ src/main/java
+
+ **/*.xml
+
+
+
+
+
diff --git a/nl-i18n-sdk/src/main/java/org/nl/LanguageApplication.java b/nl-i18n-sdk/src/main/java/org/nl/LanguageApplication.java
new file mode 100644
index 0000000..5488915
--- /dev/null
+++ b/nl-i18n-sdk/src/main/java/org/nl/LanguageApplication.java
@@ -0,0 +1,11 @@
+package org.nl;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class LanguageApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(LanguageApplication.class, args);
+ }
+}
diff --git a/nl-i18n-sdk/src/main/java/org/nl/common/BadLanguageException.java b/nl-i18n-sdk/src/main/java/org/nl/common/BadLanguageException.java
new file mode 100644
index 0000000..ca1c483
--- /dev/null
+++ b/nl-i18n-sdk/src/main/java/org/nl/common/BadLanguageException.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.nl.common;
+
+import org.springframework.http.HttpStatus;
+
+import static org.springframework.http.HttpStatus.BAD_REQUEST;
+
+/**
+ * @author Zheng Jie
+ * @date 2018-11-23
+ * 统一异常处理
+ */
+public class BadLanguageException extends RuntimeException{
+
+ private Integer status = BAD_REQUEST.value();
+
+ public BadLanguageException(String msg){
+ super(msg);
+ }
+
+ public BadLanguageException(HttpStatus status, String msg){
+ super(msg);
+ this.status = status.value();
+ }
+
+ public Integer getStatus() {
+ return status;
+ }
+
+ public void setStatus(Integer status) {
+ this.status = status;
+ }
+}
diff --git a/nl-i18n-sdk/src/main/java/org/nl/common/DataCanvers.java b/nl-i18n-sdk/src/main/java/org/nl/common/DataCanvers.java
new file mode 100644
index 0000000..7acbe52
--- /dev/null
+++ b/nl-i18n-sdk/src/main/java/org/nl/common/DataCanvers.java
@@ -0,0 +1,113 @@
+package org.nl.common;
+
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 表格分页数据对象
+ *
+ * @author Lion Li
+ */
+
+public class DataCanvers implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 总记录数
+ */
+ private long totalElements;
+
+ /**
+ * 列表数据
+ */
+ private Object content;
+
+ /**
+ * 消息状态码
+ */
+ private String code;
+
+ /**
+ * 消息内容
+ */
+ private String msg;
+ /**
+ * 分页
+ *
+ * @param list 列表数据
+ * @param total 总记录数
+ */
+ public DataCanvers(List list, long total) {
+ this.content = list;
+ this.totalElements = total;
+ }
+
+
+ public static DataCanvers buildList(List list) {
+ DataCanvers rspData = new DataCanvers<>();
+ rspData.setCode(String.valueOf(HttpStatus.OK.value()));
+ rspData.setMsg("查询成功");
+ rspData.setContent(list);
+ rspData.setTotalElements(list.size());
+ return rspData;
+ }
+
+ public static DataCanvers build() {
+ DataCanvers rspData = new DataCanvers<>();
+ rspData.setCode(String.valueOf(HttpStatus.OK.value()));
+ rspData.setMsg("查询成功");
+ return rspData;
+ }
+
+ public static DataCanvers buildJson(Object result) {
+ DataCanvers rspData = new DataCanvers<>();
+ rspData.setCode(String.valueOf(HttpStatus.OK.value()));
+ rspData.setContent(result);
+ rspData.setMsg("操作成功");
+ return rspData;
+ }
+
+ public long getTotalElements() {
+ return totalElements;
+ }
+
+ public void setTotalElements(long totalElements) {
+ this.totalElements = totalElements;
+ }
+
+ public Object getContent() {
+ return content;
+ }
+
+ public void setContent(Object content) {
+ this.content = content;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+
+ public DataCanvers() {
+ this.totalElements = totalElements;
+ }
+
+ public DataCanvers(long totalElements, Object content, String code, String msg) {
+ this.totalElements = totalElements;
+ this.content = content;
+ this.code = code;
+ this.msg = msg;
+ }
+}
diff --git a/nl-i18n-sdk/src/main/java/org/nl/common/HttpStatus.java b/nl-i18n-sdk/src/main/java/org/nl/common/HttpStatus.java
new file mode 100644
index 0000000..99c27e9
--- /dev/null
+++ b/nl-i18n-sdk/src/main/java/org/nl/common/HttpStatus.java
@@ -0,0 +1,139 @@
+package org.nl.common;
+
+public enum HttpStatus {
+ CONTINUE(100, org.springframework.http.HttpStatus.Series.INFORMATIONAL, "Continue"),
+ SWITCHING_PROTOCOLS(101, org.springframework.http.HttpStatus.Series.INFORMATIONAL, "Switching Protocols"),
+ PROCESSING(102, org.springframework.http.HttpStatus.Series.INFORMATIONAL, "Processing"),
+ CHECKPOINT(103, org.springframework.http.HttpStatus.Series.INFORMATIONAL, "Checkpoint"),
+ OK(200, org.springframework.http.HttpStatus.Series.SUCCESSFUL, "OK"),
+ CREATED(201, org.springframework.http.HttpStatus.Series.SUCCESSFUL, "Created"),
+ ACCEPTED(202, org.springframework.http.HttpStatus.Series.SUCCESSFUL, "Accepted"),
+ NON_AUTHORITATIVE_INFORMATION(203, org.springframework.http.HttpStatus.Series.SUCCESSFUL, "Non-Authoritative Information"),
+ NO_CONTENT(204, org.springframework.http.HttpStatus.Series.SUCCESSFUL, "No Content"),
+ RESET_CONTENT(205, org.springframework.http.HttpStatus.Series.SUCCESSFUL, "Reset Content"),
+ PARTIAL_CONTENT(206, org.springframework.http.HttpStatus.Series.SUCCESSFUL, "Partial Content"),
+ MULTI_STATUS(207, org.springframework.http.HttpStatus.Series.SUCCESSFUL, "Multi-Status"),
+ ALREADY_REPORTED(208, org.springframework.http.HttpStatus.Series.SUCCESSFUL, "Already Reported"),
+ IM_USED(226, org.springframework.http.HttpStatus.Series.SUCCESSFUL, "IM Used"),
+ MULTIPLE_CHOICES(300, org.springframework.http.HttpStatus.Series.REDIRECTION, "Multiple Choices"),
+ MOVED_PERMANENTLY(301, org.springframework.http.HttpStatus.Series.REDIRECTION, "Moved Permanently"),
+ FOUND(302, org.springframework.http.HttpStatus.Series.REDIRECTION, "Found"),
+ /** @deprecated */
+ @Deprecated
+ MOVED_TEMPORARILY(302, org.springframework.http.HttpStatus.Series.REDIRECTION, "Moved Temporarily"),
+ SEE_OTHER(303, org.springframework.http.HttpStatus.Series.REDIRECTION, "See Other"),
+ NOT_MODIFIED(304, org.springframework.http.HttpStatus.Series.REDIRECTION, "Not Modified"),
+ /** @deprecated */
+ @Deprecated
+ USE_PROXY(305, org.springframework.http.HttpStatus.Series.REDIRECTION, "Use Proxy"),
+ TEMPORARY_REDIRECT(307, org.springframework.http.HttpStatus.Series.REDIRECTION, "Temporary Redirect"),
+ PERMANENT_REDIRECT(308, org.springframework.http.HttpStatus.Series.REDIRECTION, "Permanent Redirect"),
+ BAD_REQUEST(400, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Bad Request"),
+ UNAUTHORIZED(401, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Unauthorized"),
+ PAYMENT_REQUIRED(402, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Payment Required"),
+ FORBIDDEN(403, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Forbidden"),
+ NOT_FOUND(404, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Not Found"),
+ METHOD_NOT_ALLOWED(405, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Method Not Allowed"),
+ NOT_ACCEPTABLE(406, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Not Acceptable"),
+ PROXY_AUTHENTICATION_REQUIRED(407, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Proxy Authentication Required"),
+ REQUEST_TIMEOUT(408, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Request Timeout"),
+ CONFLICT(409, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Conflict"),
+ GONE(410, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Gone"),
+ LENGTH_REQUIRED(411, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Length Required"),
+ PRECONDITION_FAILED(412, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Precondition Failed"),
+ PAYLOAD_TOO_LARGE(413, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Payload Too Large"),
+ /** @deprecated */
+ @Deprecated
+ REQUEST_ENTITY_TOO_LARGE(413, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Request Entity Too Large"),
+ URI_TOO_LONG(414, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "URI Too Long"),
+ /** @deprecated */
+ @Deprecated
+ REQUEST_URI_TOO_LONG(414, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Request-URI Too Long"),
+ UNSUPPORTED_MEDIA_TYPE(415, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Unsupported Media Type"),
+ REQUESTED_RANGE_NOT_SATISFIABLE(416, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Requested range not satisfiable"),
+ EXPECTATION_FAILED(417, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Expectation Failed"),
+ I_AM_A_TEAPOT(418, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "I'm a teapot"),
+ /** @deprecated */
+ @Deprecated
+ INSUFFICIENT_SPACE_ON_RESOURCE(419, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Insufficient Space On Resource"),
+ /** @deprecated */
+ @Deprecated
+ METHOD_FAILURE(420, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Method Failure"),
+ /** @deprecated */
+ @Deprecated
+ DESTINATION_LOCKED(421, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Destination Locked"),
+ UNPROCESSABLE_ENTITY(422, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Unprocessable Entity"),
+ LOCKED(423, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Locked"),
+ FAILED_DEPENDENCY(424, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Failed Dependency"),
+ TOO_EARLY(425, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Too Early"),
+ UPGRADE_REQUIRED(426, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Upgrade Required"),
+ PRECONDITION_REQUIRED(428, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Precondition Required"),
+ TOO_MANY_REQUESTS(429, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Too Many Requests"),
+ REQUEST_HEADER_FIELDS_TOO_LARGE(431, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Request Header Fields Too Large"),
+ UNAVAILABLE_FOR_LEGAL_REASONS(451, org.springframework.http.HttpStatus.Series.CLIENT_ERROR, "Unavailable For Legal Reasons"),
+ INTERNAL_SERVER_ERROR(500, org.springframework.http.HttpStatus.Series.SERVER_ERROR, "Internal Server Error"),
+ NOT_IMPLEMENTED(501, org.springframework.http.HttpStatus.Series.SERVER_ERROR, "Not Implemented"),
+ BAD_GATEWAY(502, org.springframework.http.HttpStatus.Series.SERVER_ERROR, "Bad Gateway"),
+ SERVICE_UNAVAILABLE(503, org.springframework.http.HttpStatus.Series.SERVER_ERROR, "Service Unavailable"),
+ GATEWAY_TIMEOUT(504, org.springframework.http.HttpStatus.Series.SERVER_ERROR, "Gateway Timeout"),
+ HTTP_VERSION_NOT_SUPPORTED(505, org.springframework.http.HttpStatus.Series.SERVER_ERROR, "HTTP Version not supported"),
+ VARIANT_ALSO_NEGOTIATES(506, org.springframework.http.HttpStatus.Series.SERVER_ERROR, "Variant Also Negotiates"),
+ INSUFFICIENT_STORAGE(507, org.springframework.http.HttpStatus.Series.SERVER_ERROR, "Insufficient Storage"),
+ LOOP_DETECTED(508, org.springframework.http.HttpStatus.Series.SERVER_ERROR, "Loop Detected"),
+ BANDWIDTH_LIMIT_EXCEEDED(509, org.springframework.http.HttpStatus.Series.SERVER_ERROR, "Bandwidth Limit Exceeded"),
+ NOT_EXTENDED(510, org.springframework.http.HttpStatus.Series.SERVER_ERROR, "Not Extended"),
+ NETWORK_AUTHENTICATION_REQUIRED(511, org.springframework.http.HttpStatus.Series.SERVER_ERROR, "Network Authentication Required");
+
+ private static final HttpStatus[] VALUES = values();
+ private final int value;
+ private final org.springframework.http.HttpStatus.Series series;
+ private final String reasonPhrase;
+
+ private HttpStatus(int value, org.springframework.http.HttpStatus.Series series, String reasonPhrase) {
+ this.value = value;
+ this.series = series;
+ this.reasonPhrase = reasonPhrase;
+ }
+
+ public int value() {
+ return this.value;
+ }
+
+ public org.springframework.http.HttpStatus.Series series() {
+ return this.series;
+ }
+
+ public String getReasonPhrase() {
+ return this.reasonPhrase;
+ }
+
+ public boolean is1xxInformational() {
+ return this.series() == org.springframework.http.HttpStatus.Series.INFORMATIONAL;
+ }
+
+ public boolean is2xxSuccessful() {
+ return this.series() == org.springframework.http.HttpStatus.Series.SUCCESSFUL;
+ }
+
+ public boolean is3xxRedirection() {
+ return this.series() == org.springframework.http.HttpStatus.Series.REDIRECTION;
+ }
+
+ public boolean is4xxClientError() {
+ return this.series() == org.springframework.http.HttpStatus.Series.CLIENT_ERROR;
+ }
+
+ public boolean is5xxServerError() {
+ return this.series() == org.springframework.http.HttpStatus.Series.SERVER_ERROR;
+ }
+
+ public boolean isError() {
+ return this.is4xxClientError() || this.is5xxServerError();
+ }
+
+ public String toString() {
+ return this.value + " " + this.name();
+ }
+
+}
+
diff --git a/nl-i18n-sdk/src/main/java/org/nl/language/LangBehavior.java b/nl-i18n-sdk/src/main/java/org/nl/language/LangBehavior.java
new file mode 100644
index 0000000..26d18ff
--- /dev/null
+++ b/nl-i18n-sdk/src/main/java/org/nl/language/LangBehavior.java
@@ -0,0 +1,36 @@
+package org.nl.language;
+
+
+import org.nl.language.engine.I18nManagerService;
+import org.springframework.util.StringUtils;
+
+public class LangBehavior {
+ public static I18nManagerService i18nManagerService;
+
+ /**
+ * 不带从参数
+ * @param key:common.paramException
+ * @return
+ */
+ public static String language(String key) {
+ if(StringUtils.isEmpty(key)){
+ return "";
+ }
+ return i18nManagerService.language(key);
+ }
+
+ /**
+ * 带参数的解析
+ * @param key:common.paramException
+ * @param arg: 替换语言输出中的占位符:数据异常,${0}信息不存在
+ * @return
+ */
+ public static String language(String key, String...arg) {
+ if(StringUtils.isEmpty(key)){
+ return "";
+ }
+ String language = i18nManagerService.language(key);
+ String format = String.format(language, arg);
+ return format;
+ }
+}
diff --git a/nl-i18n-sdk/src/main/java/org/nl/language/controller/langController.java b/nl-i18n-sdk/src/main/java/org/nl/language/controller/langController.java
new file mode 100644
index 0000000..ec7edeb
--- /dev/null
+++ b/nl-i18n-sdk/src/main/java/org/nl/language/controller/langController.java
@@ -0,0 +1,85 @@
+package org.nl.language.controller;
+
+import cn.dev33.satoken.annotation.SaIgnore;
+import com.alibaba.fastjson.JSONObject;
+import org.nl.language.engine.I18nManagerService;
+import org.nl.common.BadLanguageException;
+import org.nl.common.DataCanvers;
+import org.nl.language.LangBehavior;
+import org.nl.language.engine.dto.LanguageDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+@RestController
+@RequestMapping("/api/language")
+public class langController {
+
+ @Autowired
+ private I18nManagerService i18nManagerService;
+
+ /**
+ * 查询code对应结构
+ * @param languageDto
+ * @return
+ */
+ @PostMapping("/structure")
+ @SaIgnore
+ public ResponseEntity