新增getBaseGateway方法,可以动态设置基础接口的gateway服务
parent
ccce791945
commit
7fab3cfc74
|
|
@ -1,6 +1,6 @@
|
|||
import { request } from "@cqsjjb/jjb-common-lib/http.js";
|
||||
import { useEffect, useState } from "react";
|
||||
import { executeWithCache } from "../../../../utils";
|
||||
import { executeWithCache, getBaseGateway } from "../../../../utils";
|
||||
import BasicLeftTree from "../../Basic";
|
||||
|
||||
/**
|
||||
|
|
@ -19,19 +19,19 @@ function DepartmentLeftTree(props) {
|
|||
let requestUrl = "";
|
||||
const actualParams = { ...params, time: new Date().getTime() };
|
||||
if (searchType === "current") {
|
||||
requestUrl = "/basicInfo/department/listTree";
|
||||
requestUrl = `/${getBaseGateway()}/department/listTree`;
|
||||
delete actualParams.inType;
|
||||
delete actualParams.enterpriseType;
|
||||
}
|
||||
if (searchType === "all") {
|
||||
requestUrl = "/basicInfo/department/listAllTree";
|
||||
requestUrl = `/${getBaseGateway()}/department/listAllTree`;
|
||||
delete actualParams.inType;
|
||||
delete actualParams.enterpriseType;
|
||||
delete actualParams.eqCorpinfoId;
|
||||
delete actualParams.eqParentId;
|
||||
}
|
||||
if (searchType === "inType") {
|
||||
requestUrl = "/basicInfo/department/listAllTreeByCorpType";
|
||||
requestUrl = `/${getBaseGateway()}/department/listAllTreeByCorpType`;
|
||||
delete actualParams.eqCorpinfoId;
|
||||
delete actualParams.eqParentId;
|
||||
if (actualParams.enterpriseType && !Array.isArray(actualParams.enterpriseType)) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { request } from "@cqsjjb/jjb-common-lib/http.js";
|
||||
import { useEffect, useState } from "react";
|
||||
import { executeWithCache } from "../../../../utils";
|
||||
import { executeWithCache, getBaseGateway } from "../../../../utils";
|
||||
import BasicSelect from "../../Basic";
|
||||
|
||||
/**
|
||||
|
|
@ -42,7 +42,7 @@ function PersonnelSelect(props) {
|
|||
const cacheKey = { params, extraParams: actualExtraParams };
|
||||
|
||||
await executeWithCache(cacheKey, async () => {
|
||||
const { data } = await request("/basicInfo/user/listAll", "get", { ...params, ...actualExtraParams, time: new Date().getTime() });
|
||||
const { data } = await request(`/${getBaseGateway()}/user/listAll`, "get", { ...params, ...actualExtraParams, time: new Date().getTime() });
|
||||
return data;
|
||||
}, setData);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { request } from "@cqsjjb/jjb-common-lib/http.js";
|
||||
import { useEffect, useState } from "react";
|
||||
import { executeWithCache } from "../../../../utils";
|
||||
import { executeWithCache, getBaseGateway } from "../../../../utils";
|
||||
import BasicSelectTree from "../../Basic";
|
||||
|
||||
/**
|
||||
|
|
@ -29,19 +29,19 @@ function DepartmentSelectTree(props) {
|
|||
let requestUrl = "";
|
||||
const actualParams = { ...params, time: new Date().getTime() };
|
||||
if (searchType === "current") {
|
||||
requestUrl = "/basicInfo/department/listTree";
|
||||
requestUrl = `/${getBaseGateway()}/department/listTree`;
|
||||
delete actualParams.inType;
|
||||
delete actualParams.enterpriseType;
|
||||
}
|
||||
if (searchType === "all") {
|
||||
requestUrl = "/basicInfo/department/listAllTree";
|
||||
requestUrl = `/${getBaseGateway()}/department/listAllTree`;
|
||||
delete actualParams.inType;
|
||||
delete actualParams.enterpriseType;
|
||||
delete actualParams.eqCorpinfoId;
|
||||
delete actualParams.eqParentId;
|
||||
}
|
||||
if (searchType === "inType") {
|
||||
requestUrl = "/basicInfo/department/listAllTreeByCorpType";
|
||||
requestUrl = `/${getBaseGateway()}/department/listAllTreeByCorpType`;
|
||||
delete actualParams.eqCorpinfoId;
|
||||
delete actualParams.eqParentId;
|
||||
if (actualParams.enterpriseType && !Array.isArray(actualParams.enterpriseType)) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { request } from "@cqsjjb/jjb-common-lib/http.js";
|
||||
import { useState } from "react";
|
||||
import { getBaseGateway } from "../../utils";
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
|
|
@ -73,8 +74,8 @@ function useDeleteFile(returnType = "object") {
|
|||
// 发送请求
|
||||
request(
|
||||
single
|
||||
? `/basicInfo/imgFiles/delete?filePath=${files[0].filePath}`
|
||||
: `/basicInfo/imgFiles/ids?ids=${files.filter(f => f.id).map(f => f.id)}`,
|
||||
? `/${getBaseGateway()}/imgFiles/delete?filePath=${files[0].filePath}`
|
||||
: `/${getBaseGateway()}/imgFiles/ids?ids=${files.filter(f => f.id).map(f => f.id)}`,
|
||||
"delete",
|
||||
)
|
||||
.then((res) => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { request } from "@cqsjjb/jjb-common-lib/http.js";
|
||||
import { useState } from "react";
|
||||
import { UPLOAD_FILE_TYPE_ENUM } from "../../enum/uploadFile/gwj";
|
||||
import { addingPrefixToFile } from "../../utils";
|
||||
import { addingPrefixToFile, getBaseGateway } from "../../utils";
|
||||
|
||||
/**
|
||||
* 获取文件
|
||||
|
|
@ -67,7 +67,7 @@ function useGetFile(returnType = "object") {
|
|||
|
||||
// 发送请求
|
||||
request(
|
||||
"/basicInfo/imgFiles/listAll",
|
||||
`/${getBaseGateway()}/imgFiles/listAll`,
|
||||
"get",
|
||||
params,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { request } from "@cqsjjb/jjb-common-lib/http.js";
|
||||
import { useState } from "react";
|
||||
import { getBaseGateway } from "../../utils";
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
|
|
@ -21,7 +22,7 @@ function useGetUserInfo(returnType = "object") {
|
|||
return new Promise((resolve, reject) => {
|
||||
// 发送请求
|
||||
request(
|
||||
"/basicInfo/user/getInfo",
|
||||
`/${getBaseGateway()}/user/getInfo`,
|
||||
"get",
|
||||
{},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { request } from "@cqsjjb/jjb-common-lib/http.js";
|
||||
import { useState } from "react";
|
||||
import { UPLOAD_FILE_PATH_ENUM, UPLOAD_FILE_TYPE_ENUM } from "../../enum/uploadFile/gwj";
|
||||
import { getBaseGateway } from "../../utils";
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
|
|
@ -116,7 +117,7 @@ function useUploadFile(returnType = "object") {
|
|||
|
||||
// 发送请求
|
||||
request(
|
||||
single ? "/basicInfo/imgFiles/save" : "/basicInfo/imgFiles/batchSave",
|
||||
single ? `/${getBaseGateway()}/imgFiles/save` : `/${getBaseGateway()}/imgFiles/batchSave`,
|
||||
"post",
|
||||
formData,
|
||||
{ "Content-Type": "multipart/form-data" },
|
||||
|
|
|
|||
|
|
@ -273,6 +273,12 @@ export function getIndexColumn(pagination: false | BasePaginationConfig): {
|
|||
* 获取文件url
|
||||
*/
|
||||
export function getFileUrl(): string;
|
||||
|
||||
/**
|
||||
* 获取基础接口放在哪个gateway服务下
|
||||
*/
|
||||
export function getBaseGateway(): string;
|
||||
|
||||
/**
|
||||
* 从服务器获取文件url
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -606,13 +606,20 @@ export function getFileUrl() {
|
|||
return window.fileUrl || process.env.app["fileUrl"];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取基础接口放在哪个gateway服务下
|
||||
*/
|
||||
export function getBaseGateway() {
|
||||
return window.baseGateway || "basicInfo";
|
||||
}
|
||||
|
||||
/**
|
||||
* 从服务器获取文件url
|
||||
*/
|
||||
export async function getFileUrlFromServer() {
|
||||
if (window.fileUrl)
|
||||
return;
|
||||
const { data } = await request("/basicInfo/imgFiles/getImagePath", "get");
|
||||
const { data } = await request(`/${getBaseGateway()}/imgFiles/getImagePath`, "get");
|
||||
window.fileUrl = data;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue