diff --git a/api/pom.xml b/api/pom.xml
index 45b3ae08302..47850806e17 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -96,6 +96,10 @@
javax.annotation
javax.annotation-api
-
+
+ org.springframework
+ spring-web
+
+
diff --git a/api/src/main/java/com/alibaba/nacos/api/model/v2/ErrorCode.java b/api/src/main/java/com/alibaba/nacos/api/model/v2/ErrorCode.java
index 53b4c35735f..0fd8d0013c8 100644
--- a/api/src/main/java/com/alibaba/nacos/api/model/v2/ErrorCode.java
+++ b/api/src/main/java/com/alibaba/nacos/api/model/v2/ErrorCode.java
@@ -183,7 +183,20 @@ public enum ErrorCode {
/**
* server error.
*/
- SERVER_ERROR(30000, "server error");
+ SERVER_ERROR(30000, "server error"),
+
+ /**
+ * Config use 100001 ~ 100999.
+ **/
+ METADATA_ILLEGAL(100002, "导入的元数据非法"),
+
+ DATA_VALIDATION_FAILED(100003, "未读取到合法数据"),
+
+ PARSING_DATA_FAILED(100004, "解析数据失败"),
+
+ DATA_EMPTY(100005, "导入的文件数据为空"),
+
+ NO_SELECTED_CONFIG(100006, "没有选择任何配置");
private final Integer code;
diff --git a/api/src/main/java/com/alibaba/nacos/api/model/v2/Result.java b/api/src/main/java/com/alibaba/nacos/api/model/v2/Result.java
index 98ae78c5f73..2d6e1e75cc3 100644
--- a/api/src/main/java/com/alibaba/nacos/api/model/v2/Result.java
+++ b/api/src/main/java/com/alibaba/nacos/api/model/v2/Result.java
@@ -17,6 +17,7 @@
package com.alibaba.nacos.api.model.v2;
import java.io.Serializable;
+import org.springframework.http.HttpStatus;
/**
* Response Result.
@@ -96,6 +97,15 @@ public static Result failure(ErrorCode errorCode, T data) {
return new Result<>(errorCode.getCode(), errorCode.getMsg(), data);
}
+ /**
+ * Failed return with httpStatus, message and data.
+ * @param data type
+ * @return Result
+ */
+ public static Result failure(HttpStatus httpStatus, T data) {
+ return new Result<>(httpStatus.value(), httpStatus.getReasonPhrase(), data);
+ }
+
@Override
public String toString() {
return "Result{" + "errorCode=" + code + ", message='" + message + '\'' + ", data=" + data + '}';
diff --git a/api/src/main/java/com/alibaba/nacos/api/model/v2/SupportedLanguage.java b/api/src/main/java/com/alibaba/nacos/api/model/v2/SupportedLanguage.java
new file mode 100644
index 00000000000..8ca862cef5f
--- /dev/null
+++ b/api/src/main/java/com/alibaba/nacos/api/model/v2/SupportedLanguage.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 1999-2024 Alibaba Group Holding Ltd.
+ *
+ * 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 com.alibaba.nacos.api.model.v2;
+
+/**
+ * Supported languages for announcements.
+ *
+ * @author zhangyukun on:2024/9/24
+ */
+public enum SupportedLanguage {
+ /**
+ * Chinese language.
+ */
+ ZH_CN("zh-CN"),
+
+ /**
+ * English language.
+ */
+ EN_US("en-US");
+
+ private final String language;
+
+ SupportedLanguage(String language) {
+ this.language = language;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ /**
+ * Check if the given language is supported.
+ *
+ * @param language the language to check
+ * @return true if the language is supported, false otherwise
+ */
+ public static boolean isSupported(String language) {
+ for (SupportedLanguage lang : SupportedLanguage.values()) {
+ if (lang.getLanguage().equals(language)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/console-ui/src/components/EditorNameSpace/EditorNameSpace.js b/console-ui/src/components/EditorNameSpace/EditorNameSpace.js
index 5e1af4a796d..1f96be34380 100644
--- a/console-ui/src/components/EditorNameSpace/EditorNameSpace.js
+++ b/console-ui/src/components/EditorNameSpace/EditorNameSpace.js
@@ -72,8 +72,9 @@ class EditorNameSpace extends React.Component {
this.field.setValues(record);
request({
type: 'get',
- url: `v1/console/namespaces?show=all&namespaceId=${record.namespace}`,
+ url: `v3/console/core/namespace?namespaceId=${record.namespace}`,
success: res => {
+ res = res.data;
if (res !== null) {
this.field.setValue('namespaceDesc', res.namespaceDesc);
} else {
@@ -101,15 +102,18 @@ class EditorNameSpace extends React.Component {
beforeSend: () => {
this.openLoading();
},
- url: 'v1/console/namespaces',
+ url: 'v3/console/core/namespace',
contentType: 'application/x-www-form-urlencoded',
data: {
- namespace: values.namespace,
- namespaceShowName: values.namespaceShowName,
+ namespaceId: values.namespace,
+ namespaceName: values.namespaceShowName,
namespaceDesc: values.namespaceDesc,
},
success: res => {
- if (res === true) {
+ // res = res.data;
+ console.log(3);
+ if (res.code === 0) {
+ res = res.data;
this.closeDialog();
this.props.getNameSpaces();
this.refreshNameSpace(); // 刷新全局namespace
@@ -131,9 +135,10 @@ class EditorNameSpace extends React.Component {
setTimeout(() => {
request({
type: 'get',
- url: 'v1/console/namespaces',
+ url: 'v3/console/core/namespace',
success: res => {
- if (res.code === 200) {
+ console.log(res);
+ if (res.code === 0) {
window.namespaceList = res.data;
}
},
diff --git a/console-ui/src/components/NameSpaceList/NameSpaceList.js b/console-ui/src/components/NameSpaceList/NameSpaceList.js
index 825337cfd53..8fe772cf634 100644
--- a/console-ui/src/components/NameSpaceList/NameSpaceList.js
+++ b/console-ui/src/components/NameSpaceList/NameSpaceList.js
@@ -111,9 +111,9 @@ class NameSpaceList extends React.Component {
} else {
request({
type: 'get',
- url: 'v1/console/namespaces',
+ url: 'v3/console/core/namespace/list',
success: res => {
- if (res.code === 200) {
+ if (res.code === 0) {
this.handleNameSpaces(res.data);
} else {
Dialog.alert({
diff --git a/console-ui/src/components/NewNameSpace/NewNameSpace.js b/console-ui/src/components/NewNameSpace/NewNameSpace.js
index 4f50e0c07d7..40b628e58e5 100644
--- a/console-ui/src/components/NewNameSpace/NewNameSpace.js
+++ b/console-ui/src/components/NewNameSpace/NewNameSpace.js
@@ -111,13 +111,14 @@ class NewNameSpace extends React.Component {
}
request({
type: 'get',
- url: 'v1/console/namespaces?checkNamespaceIdExist=true',
+ url: 'v3/console/core/namespace/exist',
contentType: 'application/x-www-form-urlencoded',
beforeSend: () => this.openLoading(),
data: {
customNamespaceId,
},
success: res => {
+ res = res.data;
this.disabled = false;
this.setState({
disabled: false,
@@ -130,7 +131,7 @@ class NewNameSpace extends React.Component {
} else {
request({
type: 'post',
- url: 'v1/console/namespaces',
+ url: 'v3/console/core/namespace',
contentType: 'application/x-www-form-urlencoded',
beforeSend: () => this.openLoading(),
data: {
@@ -139,6 +140,7 @@ class NewNameSpace extends React.Component {
namespaceDesc: values.namespaceDesc,
},
success: res => {
+ res = res.data;
this.disabled = false;
this.setState({
disabled: false,
@@ -167,9 +169,9 @@ class NewNameSpace extends React.Component {
setTimeout(() => {
request({
type: 'get',
- url: 'v1/console/namespaces',
+ url: 'v3/console/core/namespace',
success: res => {
- if (res.code === 200) {
+ if (res.code === 0) {
window.namespaceList = res.data;
}
},
diff --git a/console-ui/src/pages/ClusterManagement/ClusterNodeList/ClusterNodeList.js b/console-ui/src/pages/ClusterManagement/ClusterNodeList/ClusterNodeList.js
index 51092c9fa1a..7860b793811 100644
--- a/console-ui/src/pages/ClusterManagement/ClusterNodeList/ClusterNodeList.js
+++ b/console-ui/src/pages/ClusterManagement/ClusterNodeList/ClusterNodeList.js
@@ -84,7 +84,7 @@ class ClusterNodeList extends React.Component {
`keyword=${keyword}`,
];
request({
- url: `v1/core/cluster/nodes?${parameter.join('&')}`,
+ url: `v3/console/core/cluster/nodes?${parameter.join('&')}`,
beforeSend: () => this.openLoading(),
success: ({ count = 0, data = [] } = {}) => {
this.setState({
@@ -107,7 +107,7 @@ class ClusterNodeList extends React.Component {
const accessToken = JSON.parse(localStorage.token || '{}').accessToken;
this.openLoading();
axios
- .post(`v1/core/cluster/server/leave?accessToken=${accessToken}`, nodes)
+ .post(`v3/console/core/cluster/server/leave?accessToken=${accessToken}`, nodes)
.then(response => {
if (response.data.code === 200) {
Message.success(locale.leaveSucc);
diff --git a/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigCompared.js b/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigCompared.js
index 21c97ae2235..bf876e5423b 100644
--- a/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigCompared.js
+++ b/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigCompared.js
@@ -58,9 +58,9 @@ class ConfigCompared extends React.Component {
getNamespaces() {
request({
type: 'get',
- url: 'v1/console/namespaces',
+ url: 'v3/console/core/namespace/list',
success: res => {
- if (res.code === 200) {
+ if (res.code === 0) {
const { namespacesDataSource } = this.state;
this.setState({ namespacesDataSource: res.data });
} else {
diff --git a/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigDetail.js b/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigDetail.js
index 59db9acfa39..3c87212384f 100644
--- a/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigDetail.js
+++ b/console-ui/src/pages/ConfigurationManagement/ConfigDetail/ConfigDetail.js
@@ -66,7 +66,7 @@ class ConfigDetail extends React.Component {
this.group = getParams('group') || 'DEFAULT_GROUP';
this.ips = '';
this.valueMap = {}; // 存储不同版本的数据
- this.tenant = getParams('namespace') || '';
+ this.namespaceId = getParams('namespace') || '';
this.searchDataId = getParams('searchDataId') || '';
this.searchGroup = getParams('searchGroup') || '';
this.pageSize = getParams('pageSize');
@@ -147,18 +147,18 @@ class ConfigDetail extends React.Component {
const { locale = {} } = this.props;
const self = this;
this.serverId = getParams('serverId') || 'center';
- this.tenant = getParams('namespace') || '';
+ this.namespaceId = getParams('namespace') || '';
this.edasAppName = getParams('edasAppName') || '';
this.inApp = this.edasAppName;
- const url = `v1/cs/configs?show=all&dataId=${this.dataId}&group=${this.group}`;
+ const url = `v3/console/cs/config?&dataId=${this.dataId}&group=${this.group}`;
request({
url,
beforeSend() {
self.openLoading();
},
success(result) {
- if (result != null) {
- const data = result;
+ if (result != null && result.code === 0) {
+ const data = result.data;
self.valueMap.normal = data;
self.field.setValue('dataId', data.dataId);
self.field.setValue('content', data.content);
@@ -186,7 +186,7 @@ class ConfigDetail extends React.Component {
serverId: this.serverId,
group: this.searchGroup,
dataId: this.searchDataId,
- namespace: this.tenant,
+ namespace: this.namespaceId,
pageNo: this.pageNo,
pageSize: this.pageSize,
})
@@ -226,7 +226,7 @@ class ConfigDetail extends React.Component {
let self = this;
const { locale = {} } = this.props;
let leftvalue = this.monacoEditor.getValue();
- let url = `v1/cs/history/previous?id=${this.valueMap.normal.id}&dataId=${this.dataId}&group=${this.group}`;
+ let url = `v3/console/cs/history/previous?id=${this.valueMap.normal.id}&dataId=${this.dataId}&group=${this.group}`;
request({
url,
beforeSend() {
@@ -234,6 +234,7 @@ class ConfigDetail extends React.Component {
},
success(result) {
if (result != null) {
+ const result = result.data;
let rightvalue = result.content;
leftvalue = leftvalue.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n');
rightvalue = rightvalue.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n');
@@ -248,18 +249,19 @@ class ConfigDetail extends React.Component {
});
}
- openCompare = ([dataId, group, tenant]) => {
+ openCompare = ([dataId, group, namespaceId]) => {
let self = this;
const { locale = {} } = this.props;
let leftvalue = this.monacoEditor.getValue();
const params = {
- show: 'all',
+ // show: 'all',
group,
dataId,
- tenant,
+ namespaceId,
};
- requestUtils.get('v1/cs/configs', { params }).then(res => {
- if (res != null && res !== '') {
+ requestUtils.get('v3/console/cs/config', { params }).then(res => {
+ if (res != null && res !== '' && res.code === 0) {
+ res = res.data;
let rightvalue = res.content;
leftvalue = leftvalue.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n');
rightvalue = rightvalue.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n');
@@ -319,7 +321,7 @@ class ConfigDetail extends React.Component {
)}