Copilot commented on code in PR #528:
URL: https://github.com/apache/shenyu-dashboard/pull/528#discussion_r2154217407


##########
src/services/api.js:
##########
@@ -1355,3 +1355,38 @@ export async function asyncNamespacePlugin(params) {
     body: params,
   });
 }
+
+/* get mcpServer list */
+export async function fetchMcpServer(params) {
+  return request(`${baseUrl}/mcpServer/list?${stringify(params)}`, {
+    method: `GET`,
+  });
+}
+
+/* add mcpServer */
+export async function addMcpServer(params) {
+  return request(`${baseUrl}/mcpServer/add`, {
+    method: `POST`,
+    body: {
+      ...params,
+    },
+  });
+}
+
+/* update mcpServer */
+export async function updateMcpServer(params) {
+  return request(`${baseUrl}/mcpServer/update`, {
+    method: `PUT`,
+    body: {
+      ...params,
+    },
+  });
+}
+
+/* delete mcpServer */
+export async function deleteMcpServer(params) {
+  return request(`${baseUrl}/mcpServer/delete`, {
+    method: `DELETE`,
+    body: [...params.list],

Review Comment:
   DELETE requests with a raw array body may not match the backend API schema; 
consider wrapping the list in an object, e.g., `body: { list: params.list }`.
   ```suggestion
       body: { list: params.list },
   ```



##########
src/models/mcpServer.js:
##########
@@ -0,0 +1,80 @@
+import { message } from "antd";
+import {
+  fetchMcpServer,
+  addMcpServer,
+  updateMcpServer,
+  deleteMcpServer,
+} from "../services/api";
+
+export default {
+  namespace: "mcpServer",
+
+  state: {
+    list: [],
+    total: 0,
+    currentPage: 1,
+    pageSize: 12,
+  },
+
+  effects: {
+    *fetch({ payload }, { call, put }) {
+      const response = yield call(fetchMcpServer, payload);
+      if (response) {
+        yield put({
+          type: "saveList",
+          payload: {
+            list: response.data,
+            total: response.total,
+            currentPage: payload.currentPage,
+            pageSize: payload.pageSize,
+          },
+        });
+      }
+    },
+    *add({ payload, callback }, { call, put }) {
+      const response = yield call(addMcpServer, payload);
+      if (response) {
+        message.success("添加成功");

Review Comment:
   Hardcoded Chinese string; use the localization framework (e.g., 
`getIntlContent`) for consistency with other messages.



##########
src/models/mcpServer.js:
##########
@@ -0,0 +1,80 @@
+import { message } from "antd";
+import {
+  fetchMcpServer,
+  addMcpServer,
+  updateMcpServer,
+  deleteMcpServer,
+} from "../services/api";
+
+export default {
+  namespace: "mcpServer",
+
+  state: {
+    list: [],
+    total: 0,
+    currentPage: 1,
+    pageSize: 12,
+  },
+
+  effects: {
+    *fetch({ payload }, { call, put }) {
+      const response = yield call(fetchMcpServer, payload);
+      if (response) {
+        yield put({
+          type: "saveList",
+          payload: {
+            list: response.data,
+            total: response.total,
+            currentPage: payload.currentPage,
+            pageSize: payload.pageSize,
+          },
+        });
+      }
+    },
+    *add({ payload, callback }, { call, put }) {
+      const response = yield call(addMcpServer, payload);
+      if (response) {
+        message.success("添加成功");
+        yield put({ type: "reload" });
+      }
+      if (callback) callback();
+    },
+    *update({ payload, callback }, { call, put }) {
+      const response = yield call(updateMcpServer, payload);
+      if (response) {
+        message.success("更新成功");

Review Comment:
   Hardcoded Chinese string; use the localization framework (e.g., 
`getIntlContent`) for consistency with other messages.
   ```suggestion
           message.success(getIntlContent("mcpServer.updateSuccess"));
   ```



##########
src/models/mcpServer.js:
##########
@@ -0,0 +1,80 @@
+import { message } from "antd";
+import {
+  fetchMcpServer,
+  addMcpServer,
+  updateMcpServer,
+  deleteMcpServer,
+} from "../services/api";
+
+export default {
+  namespace: "mcpServer",
+
+  state: {
+    list: [],
+    total: 0,
+    currentPage: 1,
+    pageSize: 12,
+  },
+
+  effects: {
+    *fetch({ payload }, { call, put }) {
+      const response = yield call(fetchMcpServer, payload);
+      if (response) {
+        yield put({
+          type: "saveList",
+          payload: {
+            list: response.data,
+            total: response.total,
+            currentPage: payload.currentPage,
+            pageSize: payload.pageSize,
+          },
+        });
+      }
+    },
+    *add({ payload, callback }, { call, put }) {
+      const response = yield call(addMcpServer, payload);
+      if (response) {
+        message.success("添加成功");
+        yield put({ type: "reload" });
+      }
+      if (callback) callback();
+    },
+    *update({ payload, callback }, { call, put }) {
+      const response = yield call(updateMcpServer, payload);
+      if (response) {
+        message.success("更新成功");
+        yield put({ type: "reload" });
+      }
+      if (callback) callback();
+    },
+    *delete({ payload, callback }, { call, put }) {
+      const response = yield call(deleteMcpServer, payload);
+      if (response) {
+        message.success("删除成功");

Review Comment:
   Hardcoded Chinese string; use the localization framework (e.g., 
`getIntlContent`) for consistency with other messages.
   ```suggestion
           message.success(getIntlContent("mcpServer.deleteSuccess"));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to