Explorar el Código

1、新增系统图服务相关文件和配置
2、axiosUtils里给所有请求的url上追加projectId、groupCode参数

niuheng hace 3 años
padre
commit
893112422c

+ 2 - 0
public/systemConf.js

@@ -1,6 +1,8 @@
 var __systemConf = {
   //基础数据根域名
   baseServiceUrl: '/api',
+  //系统图服务域名
+  sysGraphServiceUrl: 'http://127.0.0.1',
   //导航菜单
   menus: [{
     "id": "ready",

+ 6 - 0
src/controller/sysGraphController.ts

@@ -0,0 +1,6 @@
+import { sysGraphHttpUtils } from "@/utils/http/sysGraphHttpUtils";
+
+export class sysGraphController { 
+    //查询系统图列表
+    async getDiagrams(){}
+}

+ 17 - 2
src/utils/http/axiosUtils.ts

@@ -50,7 +50,7 @@ export class axiosUtils {
     protected async getRequest(url: string, data: any) {
         try {
             let response = await this.customRequest(url, {}, data, 'get');
-            return response.data;
+            return response;
         } catch (err) {
             throw err
         }
@@ -65,7 +65,7 @@ export class axiosUtils {
     protected async postRequest(url: string, data: any) {
         try {
             let response = await this.customRequest(url, {}, data, 'post');
-            return response.data;
+            return response;
         } catch (err) {
             throw err
         }
@@ -81,9 +81,24 @@ export class axiosUtils {
      */
     protected async customRequest(url: string, headers: any, data: any, method: string = 'post') {
         try {
+            //headers里放入 groupCode、projectId  为了兼顾老ADM的写法,以后可删除
             headers = headers || {};
             headers.groupCode = headers.groupCode || vueStore.state.selectProject.groupCode;
             headers.projectId= headers.projectId || vueStore.state.selectProject.id;
+
+            var urlArr = url.split('?');
+            var urlPrefix=urlArr[0];
+            var urlParamStr = urlArr[1] || '';
+            if (urlParamStr.indexOf('projectId=') == -1) { 
+                urlParamStr = 'projectId=' + vueStore.state.selectProject.id + '&' + urlParamStr;
+            }
+
+            if (urlParamStr.indexOf('groupCode=') == -1) { 
+                urlParamStr = 'groupCode=' + vueStore.state.selectProject.groupCode + '&' + urlParamStr;
+            }
+
+            url = urlPrefix + '?' + urlParamStr;
+
             let response = await axiosservice({
                 url,
                 headers: headers || {},

+ 12 - 0
src/utils/http/sysGraphHttpUtils.ts

@@ -0,0 +1,12 @@
+/**
+ * 系统图服务的http辅助类,供业务调用
+ * nh 2022.1.5
+ */
+
+import { httpUtils } from "./httpUtils";
+
+export class sysGraphHttpUtils extends httpUtils {
+    constructor() {
+        super((window as any).__systemConf.sysGraphServiceUrl);
+    };
+}