midway-fatcms 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/config.default.js +5 -3
- package/dist/configuration.d.ts +0 -3
- package/dist/configuration.js +0 -19
- package/dist/controller/gateway/ProxyApiGatewayController.d.ts +0 -2
- package/dist/controller/gateway/ProxyApiGatewayController.js +0 -18
- package/dist/controller/helpers.controller.d.ts +4 -5
- package/dist/controller/helpers.controller.js +56 -14
- package/dist/controller/manage/AccountRoleManageApi.js +3 -5
- package/dist/controller/manage/AnyApiMangeApi.js +4 -3
- package/dist/controller/manage/AppMangeApi.js +3 -4
- package/dist/controller/manage/AppPageMangeApi.js +4 -3
- package/dist/controller/manage/CrudMethodsMangeApi.js +3 -4
- package/dist/controller/manage/DataDictManageApi.js +6 -7
- package/dist/controller/manage/DeployManageApi.js +4 -5
- package/dist/controller/manage/FlowConfigManageApi.js +3 -5
- package/dist/controller/manage/MenuManageApi.js +3 -4
- package/dist/controller/manage/ProxyApiMangeApi.js +3 -4
- package/dist/controller/manage/SysConfigMangeApi.js +3 -3
- package/dist/controller/manage/SystemInfoManageApi.js +3 -1
- package/dist/controller/manage/WorkbenchMangeApi.js +3 -4
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +27 -4
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.d.ts +5 -8
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +25 -42
- package/dist/libs/crud-pro/services/CrudProDataTypeConvertService.d.ts +2 -37
- package/dist/libs/crud-pro/services/CrudProDataTypeConvertService.js +137 -213
- package/dist/libs/crud-pro/utils/CrudMonitor.d.ts +0 -9
- package/dist/libs/crud-pro/utils/CrudMonitor.js +0 -21
- package/dist/libs/crud-pro/utils/MixinUtils.d.ts +2 -17
- package/dist/libs/crud-pro/utils/MixinUtils.js +4 -84
- package/dist/libs/crud-pro/utils/idgene/generateSnowflakeId.d.ts +12 -0
- package/dist/libs/crud-pro/utils/idgene/generateSnowflakeId.js +61 -0
- package/dist/libs/crud-pro/utils/idgene/generateSnowflakeIdExt.d.ts +19 -0
- package/dist/libs/crud-pro/utils/idgene/generateSnowflakeIdExt.js +89 -0
- package/dist/libs/crud-pro/utils/idgene/index.d.ts +3 -0
- package/dist/libs/crud-pro/utils/idgene/index.js +10 -0
- package/dist/libs/crud-pro/utils/idgene/uuid.d.ts +7 -0
- package/dist/libs/crud-pro/utils/idgene/uuid.js +28 -0
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.js +26 -0
- package/dist/libs/crud-pro-quick/fixSoftDelete.d.ts +0 -17
- package/dist/libs/crud-pro-quick/fixSoftDelete.js +55 -5
- package/dist/libs/crud-pro-quick/models.d.ts +11 -1
- package/dist/middleware/cacherefresh.middleware.d.ts +3 -46
- package/dist/middleware/cacherefresh.middleware.js +9 -67
- package/dist/models/CacheRefreshCategory.d.ts +1 -18
- package/dist/models/CacheRefreshCategory.js +0 -17
- package/dist/models/SystemEntities.d.ts +2 -0
- package/dist/models/bizmodels.d.ts +0 -8
- package/dist/models/bizmodels.js +0 -8
- package/dist/schedule/scheduleNames.d.ts +2 -0
- package/dist/schedule/scheduleNames.js +3 -1
- package/dist/service/SysAppService.d.ts +0 -6
- package/dist/service/SysAppService.js +10 -79
- package/dist/service/SysConfigService.d.ts +0 -6
- package/dist/service/SysConfigService.js +6 -51
- package/dist/service/SysDictDataService.d.ts +0 -5
- package/dist/service/SysDictDataService.js +7 -65
- package/dist/service/SysMenuService.d.ts +0 -4
- package/dist/service/SysMenuService.js +5 -44
- package/dist/service/WorkbenchService.d.ts +1 -6
- package/dist/service/WorkbenchService.js +9 -63
- package/dist/service/anyapi/AnyApiService.d.ts +1 -1
- package/dist/service/anyapi/AnyApiService.js +6 -16
- package/dist/service/base/bizmemcache/BizMemCacheService.d.ts +16 -0
- package/dist/service/base/bizmemcache/BizMemCacheService.js +241 -0
- package/dist/service/base/bizmemcache/BizMemCacheStore.d.ts +34 -0
- package/dist/service/base/bizmemcache/BizMemCacheStore.js +119 -0
- package/dist/service/base/bizmemcache/BizMemCacheTypes.d.ts +60 -0
- package/dist/service/base/bizmemcache/BizMemCacheTypes.js +18 -0
- package/dist/service/base/cache-refresh/CacheRefreshHub.d.ts +0 -22
- package/dist/service/base/cache-refresh/CacheRefreshHub.js +0 -22
- package/dist/service/base/cache-refresh/CacheRefreshHubScheduleService.d.ts +0 -6
- package/dist/service/base/cache-refresh/CacheRefreshHubScheduleService.js +0 -6
- package/dist/service/crudstd/CrudStdService.js +1 -1
- package/dist/service/curd/CurdMixByDictService.d.ts +0 -4
- package/dist/service/curd/CurdMixByDictService.js +9 -55
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +0 -5
- package/dist/service/curd/CurdMixBySysConfigService.js +9 -54
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +0 -1
- package/dist/service/curd/CurdMixByWorkbenchService.js +9 -36
- package/dist/service/curd/CurdProService.d.ts +0 -1
- package/dist/service/curd/CurdProService.js +0 -4
- package/dist/service/curd/fixCfgModel.js +21 -1
- package/dist/service/proxyapi/ProxyApiLoadService.d.ts +3 -8
- package/dist/service/proxyapi/ProxyApiLoadService.js +40 -68
- package/dist/service/proxyapi/ProxyApiService.d.ts +2 -0
- package/dist/service/proxyapi/ProxyApiService.js +32 -9
- package/dist/service/proxyapi/RouteTrie.d.ts +1 -7
- package/dist/service/proxyapi/RouteTrie.js +1 -17
- package/package.json +1 -1
- package/src/config/config.default.ts +4 -2
- package/src/configuration.ts +0 -23
- package/src/controller/gateway/ProxyApiGatewayController.ts +1 -9
- package/src/controller/helpers.controller.ts +66 -15
- package/src/controller/manage/AccountRoleManageApi.ts +3 -5
- package/src/controller/manage/AnyApiMangeApi.ts +4 -3
- package/src/controller/manage/AppMangeApi.ts +4 -5
- package/src/controller/manage/AppPageMangeApi.ts +4 -3
- package/src/controller/manage/CrudMethodsMangeApi.ts +4 -5
- package/src/controller/manage/DataDictManageApi.ts +7 -8
- package/src/controller/manage/DeployManageApi.ts +2 -3
- package/src/controller/manage/FlowConfigManageApi.ts +3 -5
- package/src/controller/manage/MenuManageApi.ts +4 -5
- package/src/controller/manage/ProxyApiMangeApi.ts +4 -5
- package/src/controller/manage/SysConfigMangeApi.ts +5 -5
- package/src/controller/manage/SystemInfoManageApi.ts +3 -1
- package/src/controller/manage/WorkbenchMangeApi.ts +4 -5
- package/src/index.ts +3 -0
- package/src/libs/crud-pro/models/TransactionSqlServer.ts +26 -4
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +25 -43
- package/src/libs/crud-pro/services/CrudProDataTypeConvertService.ts +149 -219
- package/src/libs/crud-pro/utils/CrudMonitor.ts +0 -23
- package/src/libs/crud-pro/utils/MixinUtils.ts +309 -400
- package/src/libs/crud-pro/utils/idgene/generateSnowflakeId.ts +65 -0
- package/src/libs/crud-pro/utils/idgene/generateSnowflakeIdExt.ts +99 -0
- package/src/libs/crud-pro/utils/idgene/index.ts +3 -0
- package/src/libs/crud-pro/utils/idgene/uuid.ts +26 -0
- package/src/libs/crud-pro/utils/pool/SqlServerUtils.ts +31 -0
- package/src/libs/crud-pro-quick/fixSoftDelete.ts +84 -18
- package/src/libs/crud-pro-quick/models.ts +15 -3
- package/src/middleware/cacherefresh.middleware.ts +10 -71
- package/src/models/CacheRefreshCategory.ts +0 -17
- package/src/models/SystemEntities.ts +2 -0
- package/src/models/bizmodels.ts +0 -8
- package/src/schedule/scheduleNames.ts +5 -3
- package/src/service/SysAppService.ts +7 -78
- package/src/service/SysConfigService.ts +4 -45
- package/src/service/SysDictDataService.ts +5 -64
- package/src/service/SysMenuService.ts +3 -40
- package/src/service/WorkbenchService.ts +9 -72
- package/src/service/anyapi/AnyApiService.ts +5 -17
- package/src/service/base/bizmemcache/BizMemCacheService.ts +290 -0
- package/src/service/base/bizmemcache/BizMemCacheStore.ts +159 -0
- package/src/service/base/bizmemcache/BizMemCacheTypes.ts +76 -0
- package/src/service/base/cache-refresh/CacheRefreshHub.ts +0 -22
- package/src/service/base/cache-refresh/CacheRefreshHubScheduleService.ts +0 -6
- package/src/service/crudstd/CrudStdService.ts +3 -2
- package/src/service/curd/CurdMixByDictService.ts +10 -61
- package/src/service/curd/CurdMixBySysConfigService.ts +9 -62
- package/src/service/curd/CurdMixByWorkbenchService.ts +7 -32
- package/src/service/curd/CurdProService.ts +0 -6
- package/src/service/curd/fixCfgModel.ts +145 -125
- package/src/service/proxyapi/ProxyApiLoadService.ts +39 -77
- package/src/service/proxyapi/ProxyApiService.ts +45 -9
- package/src/service/proxyapi/RouteTrie.ts +1 -18
|
@@ -15,16 +15,13 @@ const _ = require("lodash");
|
|
|
15
15
|
const BaseService_1 = require("../base/BaseService");
|
|
16
16
|
const RouteTrie_1 = require("./RouteTrie");
|
|
17
17
|
const RouteHandler_1 = require("./RouteHandler");
|
|
18
|
-
const CurdProService_1 = require("../curd/CurdProService");
|
|
19
|
-
const SystemTables_1 = require("../../models/SystemTables");
|
|
20
|
-
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
21
18
|
const functions_1 = require("../../libs/utils/functions");
|
|
22
19
|
const ProxyApiUtils_1 = require("./ProxyApiUtils");
|
|
23
20
|
const WeightedRandom_1 = require("./WeightedRandom");
|
|
24
21
|
const WeightedRoundRobin_1 = require("./WeightedRoundRobin");
|
|
22
|
+
const BizMemCacheStore_1 = require("../../service/base/bizmemcache/BizMemCacheStore");
|
|
25
23
|
const WorkbenchService_1 = require("../WorkbenchService");
|
|
26
24
|
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
27
|
-
const global_config_1 = require("../../libs/global-config/global-config");
|
|
28
25
|
function toUpstreamInfo(config_content) {
|
|
29
26
|
const obj = (0, functions_1.parseJsonObject)(config_content);
|
|
30
27
|
if (!obj) {
|
|
@@ -62,40 +59,41 @@ function toUpstreamInfo(config_content) {
|
|
|
62
59
|
*/
|
|
63
60
|
let ProxyApiLoadService = class ProxyApiLoadService extends BaseService_1.BaseService {
|
|
64
61
|
/**
|
|
65
|
-
*
|
|
66
|
-
* 先构建全新的 RouteTrie,完成后原子替换,避免重建期间路由不可用
|
|
67
|
-
* @param workbench_code
|
|
62
|
+
* 获取站点路由树;routeTrieMap 为空或缺失时懒重建
|
|
68
63
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
64
|
+
getRouteTrie(workbench_code) {
|
|
65
|
+
var _a;
|
|
66
|
+
const cacheObj = BizMemCacheStore_1.bizMemCacheStore.getSysProxyApi();
|
|
67
|
+
if ((_a = cacheObj === null || cacheObj === void 0 ? void 0 : cacheObj.routeTrieMap) === null || _a === void 0 ? void 0 : _a[workbench_code]) {
|
|
68
|
+
return cacheObj.routeTrieMap[workbench_code];
|
|
69
|
+
}
|
|
70
|
+
return this.buildRouteTrie(workbench_code);
|
|
71
|
+
}
|
|
72
|
+
buildRouteTrie(workbench_code) {
|
|
73
|
+
const upstreamMap = this.buildUpstreamMap();
|
|
74
|
+
const routeTrie = new RouteTrie_1.RouteTrie();
|
|
75
|
+
const entities = this.loadProxyApiEntity(workbench_code, upstreamMap);
|
|
73
76
|
for (let i = 0; i < entities.length; i++) {
|
|
74
77
|
const entity = entities[i];
|
|
75
78
|
if (entity.status === 1) {
|
|
76
79
|
const path_prefix2 = '/' + entity.upstream_code + entity.path_prefix;
|
|
77
|
-
|
|
80
|
+
routeTrie.addRoute(path_prefix2, new RouteHandler_1.RouteHandler(entity));
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
const cacheObj = BizMemCacheStore_1.bizMemCacheStore.getSysProxyApi();
|
|
84
|
+
if (cacheObj) {
|
|
85
|
+
if (!cacheObj.routeTrieMap) {
|
|
86
|
+
cacheObj.routeTrieMap = {};
|
|
87
|
+
}
|
|
88
|
+
cacheObj.routeTrieMap[workbench_code] = routeTrie;
|
|
89
|
+
}
|
|
90
|
+
return routeTrie;
|
|
82
91
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
condition: {
|
|
88
|
-
biz_tag: 'upstream',
|
|
89
|
-
deleted_at: 0,
|
|
90
|
-
},
|
|
91
|
-
}, {
|
|
92
|
-
sqlTable: SystemTables_1.SystemTables.sys_configs,
|
|
93
|
-
sqlDatabase: SystemDbName,
|
|
94
|
-
sqlDbType: SystemDbType,
|
|
95
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
96
|
-
});
|
|
92
|
+
buildUpstreamMap() {
|
|
93
|
+
var _a;
|
|
94
|
+
const sysConfigList = ((_a = BizMemCacheStore_1.bizMemCacheStore.getSysConfig()) === null || _a === void 0 ? void 0 : _a.sysConfigList) || [];
|
|
95
|
+
const rows = sysConfigList.filter((row) => row.biz_tag === 'upstream');
|
|
97
96
|
const upstreamMap = {};
|
|
98
|
-
const rows = res.getResRows();
|
|
99
97
|
for (let i = 0; i < rows.length; i++) {
|
|
100
98
|
const row = rows[i];
|
|
101
99
|
const { config_code, config_content } = row || {};
|
|
@@ -103,30 +101,24 @@ let ProxyApiLoadService = class ProxyApiLoadService extends BaseService_1.BaseSe
|
|
|
103
101
|
}
|
|
104
102
|
return upstreamMap;
|
|
105
103
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
sqlDatabase: SystemDbName,
|
|
113
|
-
sqlDbType: SystemDbType,
|
|
114
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
115
|
-
});
|
|
116
|
-
const rows0 = res.getResRows();
|
|
117
|
-
const rows = rows0.filter(s => {
|
|
104
|
+
loadProxyApiEntity(workbench_code, upstreamMap) {
|
|
105
|
+
var _a;
|
|
106
|
+
const rows0 = ((_a = BizMemCacheStore_1.bizMemCacheStore.getSysProxyApi()) === null || _a === void 0 ? void 0 : _a.sysProxyApiList) || [];
|
|
107
|
+
const rows = [];
|
|
108
|
+
for (let i = 0; i < rows0.length; i++) {
|
|
109
|
+
const s = rows0[i];
|
|
118
110
|
if (!(0, functions_1.isEntityOK)(s)) {
|
|
119
|
-
|
|
111
|
+
continue;
|
|
120
112
|
}
|
|
121
113
|
if (!s.workbench_code_array) {
|
|
122
114
|
throw new exceptions_1.CommonException('IS_SUPPORT_CURRENT_WORKBENCH', '未配置支持的站点字段');
|
|
123
115
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const row =
|
|
128
|
-
|
|
129
|
-
|
|
116
|
+
if (!this.workbenchService.isMatchWorkbenchCode(s.workbench_code_array, workbench_code)) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const row = JSON.parse(JSON.stringify(s));
|
|
120
|
+
this.addUpstreamInfo(row, row.upstream_code, upstreamMap);
|
|
121
|
+
rows.push(row);
|
|
130
122
|
}
|
|
131
123
|
return rows;
|
|
132
124
|
}
|
|
@@ -141,27 +133,7 @@ let ProxyApiLoadService = class ProxyApiLoadService extends BaseService_1.BaseSe
|
|
|
141
133
|
row.weightedRandom = new WeightedRandom_1.WeightedRandom(upstreamInfo.targetList || []);
|
|
142
134
|
row.weightedRoundRobin = new WeightedRoundRobin_1.WeightedRoundRobin(upstreamInfo.targetList || []);
|
|
143
135
|
}
|
|
144
|
-
async refreshRouteTrie() {
|
|
145
|
-
const workbenchList = await this.workbenchService.getAllWorkbenchInfoList();
|
|
146
|
-
for (let i = 0; i < workbenchList.length; i++) {
|
|
147
|
-
const workbenchInfo = workbenchList[i];
|
|
148
|
-
try {
|
|
149
|
-
await this.buildRouteTrie(workbenchInfo.workbench_code);
|
|
150
|
-
}
|
|
151
|
-
catch (e) {
|
|
152
|
-
this.logError('ProxyApiLoadService_runBySchedule', e);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
136
|
};
|
|
157
|
-
__decorate([
|
|
158
|
-
(0, core_1.Inject)(),
|
|
159
|
-
__metadata("design:type", Object)
|
|
160
|
-
], ProxyApiLoadService.prototype, "ctx", void 0);
|
|
161
|
-
__decorate([
|
|
162
|
-
(0, core_1.Inject)(),
|
|
163
|
-
__metadata("design:type", CurdProService_1.CurdProService)
|
|
164
|
-
], ProxyApiLoadService.prototype, "curdProService", void 0);
|
|
165
137
|
__decorate([
|
|
166
138
|
(0, core_1.Inject)(),
|
|
167
139
|
__metadata("design:type", WorkbenchService_1.WorkbenchService)
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ProxyApiService = void 0;
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const _ = require("lodash");
|
|
15
|
-
const RouteTrie_1 = require("./RouteTrie");
|
|
16
15
|
const exceptions_1 = require("../../libs/crud-pro/exceptions");
|
|
17
16
|
const devops_1 = require("../../models/devops");
|
|
18
17
|
const CurdProService_1 = require("../curd/CurdProService");
|
|
@@ -23,6 +22,7 @@ const ProxyApiUtils_1 = require("./ProxyApiUtils");
|
|
|
23
22
|
const ProxyApiLoadService_1 = require("./ProxyApiLoadService");
|
|
24
23
|
const ApiBaseService_1 = require("../base/ApiBaseService");
|
|
25
24
|
const base64_1 = require("../../libs/utils/base64");
|
|
25
|
+
const functions_1 = require("../../libs/utils/functions");
|
|
26
26
|
/**
|
|
27
27
|
* 接口代理
|
|
28
28
|
*/
|
|
@@ -33,7 +33,7 @@ let ProxyApiService = class ProxyApiService extends ApiBaseService_1.ApiBaseServ
|
|
|
33
33
|
* @param upstream_path : 形如/[upstream_code]/[api_path]
|
|
34
34
|
*/
|
|
35
35
|
async handleProxyRequest(current_workbench_code, upstream_path) {
|
|
36
|
-
const routeTrie =
|
|
36
|
+
const routeTrie = this.proxyApiLoadService.getRouteTrie(current_workbench_code);
|
|
37
37
|
const ss = routeTrie.findLongestMatch(upstream_path);
|
|
38
38
|
if (!ss) {
|
|
39
39
|
throw new devops_1.BizException('路径没有匹配到', exceptions_1.Exceptions.CFG_NOT_FOUND);
|
|
@@ -69,16 +69,12 @@ let ProxyApiService = class ProxyApiService extends ApiBaseService_1.ApiBaseServ
|
|
|
69
69
|
// const response_type: ResponseType = (proxyApiEntity.response_type || 'stream') as any;
|
|
70
70
|
const response_type = 'stream';
|
|
71
71
|
try {
|
|
72
|
-
const headers =
|
|
73
|
-
|
|
74
|
-
host: targetUrl.host, // 设置正确的 host
|
|
75
|
-
};
|
|
76
|
-
delete headers['content-length'];
|
|
77
|
-
this.setRequestHeaders(headers, proxyApiEntity);
|
|
72
|
+
const headers = this.buildRequestHeaders(targetUrl.host, proxyApiEntity);
|
|
73
|
+
const requestBody = this.buildRequestBody(ctx.request.body, proxyApiEntity);
|
|
78
74
|
const axiosParams = {
|
|
79
75
|
method: ctx.method,
|
|
80
76
|
url: targetUrl.toString(),
|
|
81
|
-
data:
|
|
77
|
+
data: requestBody,
|
|
82
78
|
headers: headers,
|
|
83
79
|
responseType: response_type,
|
|
84
80
|
timeout: Number(proxyApiEntity.timeout_ms) || 5 * 60 * 1000,
|
|
@@ -227,6 +223,16 @@ let ProxyApiService = class ProxyApiService extends ApiBaseService_1.ApiBaseServ
|
|
|
227
223
|
const ss = targetList[proxyApiEntity.targetIndex];
|
|
228
224
|
return ss ? ss.origin : null;
|
|
229
225
|
}
|
|
226
|
+
buildRequestHeaders(targetHost, proxyApiEntity) {
|
|
227
|
+
const ctx = this.ctx;
|
|
228
|
+
const headers = {
|
|
229
|
+
...ctx.headers,
|
|
230
|
+
host: targetHost, // 设置正确的 host
|
|
231
|
+
};
|
|
232
|
+
delete headers['content-length'];
|
|
233
|
+
this.setRequestHeaders(headers, proxyApiEntity);
|
|
234
|
+
return headers;
|
|
235
|
+
}
|
|
230
236
|
setRequestHeaders(headers, proxyApiEntity) {
|
|
231
237
|
const ctx = this.ctx;
|
|
232
238
|
// 转发IP
|
|
@@ -251,6 +257,23 @@ let ProxyApiService = class ProxyApiService extends ApiBaseService_1.ApiBaseServ
|
|
|
251
257
|
if (proxyApiEntity.change_origin && proxyApiEntity.change_origin.length > 0) {
|
|
252
258
|
headers.origin = proxyApiEntity.change_origin;
|
|
253
259
|
}
|
|
260
|
+
// 强制设置自定义Header
|
|
261
|
+
const custom_header = (0, functions_1.parseJsonObject)(proxyApiEntity.custom_header);
|
|
262
|
+
if (custom_header && typeof custom_header === 'object' && Object.keys(custom_header).length > 0) {
|
|
263
|
+
Object.assign(headers, custom_header);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
buildRequestBody(requestBody, proxyApiEntity) {
|
|
267
|
+
// 强制设置自定义body
|
|
268
|
+
const custom_body = (0, functions_1.parseJsonObject)(proxyApiEntity.custom_body);
|
|
269
|
+
if (custom_body && typeof custom_body === 'object' && Object.keys(custom_body).length > 0) {
|
|
270
|
+
if (requestBody && typeof requestBody === 'object') {
|
|
271
|
+
Object.assign(requestBody, custom_body);
|
|
272
|
+
return requestBody;
|
|
273
|
+
}
|
|
274
|
+
return custom_body;
|
|
275
|
+
}
|
|
276
|
+
return requestBody;
|
|
254
277
|
}
|
|
255
278
|
buildUserContextHeader(proxyApiEntity) {
|
|
256
279
|
var _a, _b, _c;
|
|
@@ -8,10 +8,4 @@ declare class RouteTrie {
|
|
|
8
8
|
getRouteCount(): number;
|
|
9
9
|
findLongestMatch(path: string): any;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 原子替换指定 domainCode 的 RouteTrie
|
|
14
|
-
* 用于重建路由时先构建新树再整体替换,避免清空后重建期间路由不可用
|
|
15
|
-
*/
|
|
16
|
-
declare function setRouteTrie(domainCode: string, routeTrie: RouteTrie): void;
|
|
17
|
-
export { RouteTrie, getRouteTrie, setRouteTrie };
|
|
11
|
+
export { RouteTrie };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RouteTrie = void 0;
|
|
4
4
|
class RouteTrieNode {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.children = {}; // 子节点字典
|
|
@@ -54,19 +54,3 @@ class RouteTrie {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
exports.RouteTrie = RouteTrie;
|
|
57
|
-
const ROUTE_TRIE_MANAGER = {};
|
|
58
|
-
function getRouteTrie(domainCode) {
|
|
59
|
-
if (!ROUTE_TRIE_MANAGER[domainCode]) {
|
|
60
|
-
ROUTE_TRIE_MANAGER[domainCode] = new RouteTrie();
|
|
61
|
-
}
|
|
62
|
-
return ROUTE_TRIE_MANAGER[domainCode];
|
|
63
|
-
}
|
|
64
|
-
exports.getRouteTrie = getRouteTrie;
|
|
65
|
-
/**
|
|
66
|
-
* 原子替换指定 domainCode 的 RouteTrie
|
|
67
|
-
* 用于重建路由时先构建新树再整体替换,避免清空后重建期间路由不可用
|
|
68
|
-
*/
|
|
69
|
-
function setRouteTrie(domainCode, routeTrie) {
|
|
70
|
-
ROUTE_TRIE_MANAGER[domainCode] = routeTrie;
|
|
71
|
-
}
|
|
72
|
-
exports.setRouteTrie = setRouteTrie;
|
package/package.json
CHANGED
|
@@ -83,8 +83,9 @@ export default (appInfo: any) => {
|
|
|
83
83
|
},
|
|
84
84
|
pool: {
|
|
85
85
|
max: 30, // 最大连接数
|
|
86
|
-
min:
|
|
87
|
-
idleTimeoutMillis:
|
|
86
|
+
min: 5, // 最小连接数:保持常驻连接,避免频繁创建物理连接
|
|
87
|
+
idleTimeoutMillis: 300000, // 连接空闲超时时间(毫秒):5分钟,避免连接被过早销毁
|
|
88
|
+
acquireTimeoutMillis: 60000, // 获取连接的超时时间
|
|
88
89
|
},
|
|
89
90
|
},
|
|
90
91
|
},
|
|
@@ -184,6 +185,7 @@ export default (appInfo: any) => {
|
|
|
184
185
|
cacheRefreshHubScheduleService: 10 * 60 * 1000, // 10分钟刷新一次所有缓存
|
|
185
186
|
visitStatService: 10 * 60 * 1000, // 10分钟重新加载一次访问统计
|
|
186
187
|
asyncTaskRunnerService: 1000, // 1s可以执行
|
|
188
|
+
bizMemCacheService: 1000, // 1s刷新一次BizMemCache
|
|
187
189
|
},
|
|
188
190
|
|
|
189
191
|
// Excel导出文件的临时目录
|
package/src/configuration.ts
CHANGED
|
@@ -21,7 +21,6 @@ import { CacheRefreshHub } from './service/base/cache-refresh/CacheRefreshHub';
|
|
|
21
21
|
import { CacheRefreshCategory } from './models/CacheRefreshCategory';
|
|
22
22
|
import { CacheServiceFactory } from './service/base/cache/CacheServiceFactory';
|
|
23
23
|
import { CacheNameEnum } from './models/bizmodels';
|
|
24
|
-
import { ProxyApiLoadService } from './service/proxyapi/ProxyApiLoadService';
|
|
25
24
|
import { CurdProService } from './service/curd/CurdProService';
|
|
26
25
|
|
|
27
26
|
|
|
@@ -126,43 +125,21 @@ export class ContainerLifeCycle {
|
|
|
126
125
|
|
|
127
126
|
}
|
|
128
127
|
|
|
129
|
-
/**
|
|
130
|
-
* 注册各类型缓存的刷新器到 CacheRefreshHub
|
|
131
|
-
*/
|
|
132
128
|
private registerCacheRefreshers() {
|
|
133
|
-
// CrudMethodConfig: 清空 CRUD 方法配置缓存(清空后下次请求时懒加载)
|
|
134
|
-
CacheRefreshHub.register(CacheRefreshCategory.CrudMethodConfig, async (ctx) => {
|
|
135
|
-
// clearMethodCache();
|
|
136
|
-
const cacheServiceFactory = await ctx.requestContext.getAsync(CurdProService);
|
|
137
|
-
await cacheServiceFactory.loadMethodCache(ctx);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// TableMeta: 清空表元数据缓存(清空后下次请求时懒加载)
|
|
141
129
|
CacheRefreshHub.register(CacheRefreshCategory.TableMeta, async (ctx) => {
|
|
142
|
-
// clearTableMetaCache();
|
|
143
130
|
const cacheServiceFactory = await ctx.requestContext.getAsync(CurdProService);
|
|
144
131
|
await cacheServiceFactory.loadTableMetaCache(ctx);
|
|
145
132
|
});
|
|
146
133
|
|
|
147
|
-
// CacheService: 主动重加载所有 CacheServiceFactory 管理的业务缓存
|
|
148
134
|
CacheRefreshHub.register(CacheRefreshCategory.CacheService, async (ctx) => {
|
|
149
135
|
const cacheServiceFactory = await ctx.requestContext.getAsync(CacheServiceFactory);
|
|
150
136
|
await cacheServiceFactory.refreshAllCache(ctx);
|
|
151
137
|
});
|
|
152
138
|
|
|
153
|
-
// LinkToCustom: 刷新 linkToCustom 关联枚举缓存
|
|
154
139
|
CacheRefreshHub.register(CacheRefreshCategory.LinkToCustom, async (ctx) => {
|
|
155
140
|
const cacheServiceFactory = await ctx.requestContext.getAsync(CacheServiceFactory);
|
|
156
141
|
await cacheServiceFactory.refreshByCacheName(CacheNameEnum.CurdMixByLinkToCustom, ctx);
|
|
157
142
|
});
|
|
158
|
-
|
|
159
|
-
// ProxyApiRoute: 重建代理API路由树(复用 ProxyApiLoadService.runBySchedule 的逻辑)
|
|
160
|
-
CacheRefreshHub.register(CacheRefreshCategory.ProxyApiRoute, async (ctx) => {
|
|
161
|
-
const proxyApiLoadService = await ctx.requestContext.getAsync(ProxyApiLoadService);
|
|
162
|
-
await proxyApiLoadService.refreshRouteTrie();
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
|
|
166
143
|
}
|
|
167
144
|
|
|
168
145
|
private async startScheduleOnReady() {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { All, Controller, Inject
|
|
1
|
+
import { All, Controller, Inject } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
4
|
import { ProxyApiService } from '@/service/proxyapi/ProxyApiService';
|
|
5
5
|
import { WorkbenchService } from '@/service/WorkbenchService';
|
|
6
6
|
import { CommonResult } from '@/libs/utils/common-dto';
|
|
7
|
-
import { ProxyApiLoadService } from '@/service/proxyapi/ProxyApiLoadService';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* 只支持前缀匹配
|
|
@@ -22,8 +21,6 @@ export class ProxyApiGatewayController extends BaseApiController {
|
|
|
22
21
|
@Inject()
|
|
23
22
|
private workbenchService: WorkbenchService;
|
|
24
23
|
|
|
25
|
-
@Inject()
|
|
26
|
-
private proxyApiLoadService: ProxyApiLoadService;
|
|
27
24
|
/**
|
|
28
25
|
* 执行配置出来的接口的接口。此接口本身不需要鉴权。鉴权信息在配置中由curdPro底层进行鉴权
|
|
29
26
|
*/
|
|
@@ -39,9 +36,4 @@ export class ProxyApiGatewayController extends BaseApiController {
|
|
|
39
36
|
const path2 = this.ctx.path.replace(/^\/ns\/gw\/proxy/, '');
|
|
40
37
|
return this.proxyApiService.handleProxyRequest(workbench_code, path2);
|
|
41
38
|
}
|
|
42
|
-
|
|
43
|
-
@All('/buildRouteTrie')
|
|
44
|
-
async buildRouteTrie(@Query('workbench_code') workbench_code: string) {
|
|
45
|
-
return this.proxyApiLoadService.buildRouteTrie(workbench_code);
|
|
46
|
-
}
|
|
47
39
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Inject, Controller, Get, MidwayWebRouterService, Query } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
|
+
import { RedisService } from '@midwayjs/redis';
|
|
3
4
|
import * as _ from 'lodash';
|
|
4
5
|
import * as md5 from 'md5';
|
|
5
6
|
import { CommonException, Exceptions } from '@/libs/crud-pro/exceptions';
|
|
@@ -12,8 +13,12 @@ import { refreshCacheWithBroadcast } from '@/service/base/cache-refresh/CacheRef
|
|
|
12
13
|
import { CacheRefreshCategory } from '@/models/CacheRefreshCategory';
|
|
13
14
|
import { CacheNameEnum } from '@/models/bizmodels';
|
|
14
15
|
import { CacheServiceFactory } from '@/service/base/cache/CacheServiceFactory';
|
|
16
|
+
import { bizMemCacheStore } from '@/service/base/bizmemcache/BizMemCacheStore';
|
|
17
|
+
import { BizMemCacheKey } from '@/service/base/bizmemcache/BizMemCacheTypes';
|
|
15
18
|
import { ActionLogService } from '@/service/ActionLogService';
|
|
16
19
|
|
|
20
|
+
|
|
21
|
+
|
|
17
22
|
// http://127.0.0.1:7002/ns/api/helpers/getApiScript?prefix=/ns/api/manage
|
|
18
23
|
// http://127.0.0.1:7002/ns/api/helpers/getApiScript
|
|
19
24
|
// http://127.0.0.1:7002/ns/api/helpers/getApiEnv
|
|
@@ -154,54 +159,100 @@ export class HelpersApi {
|
|
|
154
159
|
});
|
|
155
160
|
}
|
|
156
161
|
|
|
157
|
-
/**
|
|
158
|
-
* 工具函数: 刷新缓存(集群广播)
|
|
159
|
-
* 通过 CacheRefreshHub 在 ANONYMOUS_CONTEXT 中主动重加载缓存,并通过 Redis Pub/Sub 广播通知集群中其他节点。
|
|
160
|
-
* 可通过 category 参数指定刷新的缓存类型(CacheRefreshCategory),不传则刷新全部。
|
|
161
|
-
* 可通过 cacheName 参数指定刷新的业务缓存(CacheNameEnum)。
|
|
162
|
-
*/
|
|
163
162
|
@Get('/refreshCache', { middleware: [checkPermission(SystemFuncCode.HelpersCacheRefresh)] })
|
|
164
163
|
async refreshCacheApi(@Query() queryData) {
|
|
165
164
|
const categoryParam = queryData.category as string;
|
|
166
165
|
const cacheNameParam = queryData.cacheName as string;
|
|
166
|
+
const bizMemCacheKeyParam = queryData.bizMemCacheKey as string;
|
|
167
|
+
|
|
168
|
+
if (bizMemCacheKeyParam) {
|
|
169
|
+
const refreshedKeys = await this.refreshBizMemCacheKeys(bizMemCacheKeyParam);
|
|
170
|
+
|
|
171
|
+
await this.actionLogService.insertActionLogTable({
|
|
172
|
+
actionModule: '系统工具',
|
|
173
|
+
actionName: '刷新缓存',
|
|
174
|
+
actionMessage: '刷新BizMemCache成功',
|
|
175
|
+
actionTarget: bizMemCacheKeyParam,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
return CommonResult.successRes({
|
|
179
|
+
message: `BizMemCache 已刷新: ${refreshedKeys.join(', ') || '(无有效 key)'}`,
|
|
180
|
+
bizMemCacheKeys: refreshedKeys,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
167
183
|
|
|
168
184
|
if (cacheNameParam) {
|
|
169
|
-
// 按 CacheNameEnum 单独刷新业务缓存
|
|
170
185
|
const cacheName = cacheNameParam as CacheNameEnum;
|
|
171
186
|
const cacheServiceFactory = await this.ctx.requestContext.getAsync(CacheServiceFactory);
|
|
172
187
|
await cacheServiceFactory.refreshByCacheName(cacheName, this.ctx as any);
|
|
173
188
|
|
|
174
|
-
|
|
175
189
|
await this.actionLogService.insertActionLogTable({
|
|
176
190
|
actionModule: '系统工具',
|
|
177
191
|
actionName: '刷新缓存',
|
|
178
192
|
actionMessage: '刷新缓存成功',
|
|
179
|
-
actionTarget: cacheNameParam
|
|
193
|
+
actionTarget: cacheNameParam,
|
|
180
194
|
});
|
|
181
195
|
|
|
182
196
|
return CommonResult.successRes({
|
|
183
|
-
message: `业务缓存 ${cacheName}
|
|
197
|
+
message: `业务缓存 ${cacheName} 已刷新(仅本节点)`,
|
|
184
198
|
cacheName,
|
|
185
199
|
});
|
|
186
200
|
}
|
|
187
201
|
|
|
188
|
-
|
|
189
|
-
|
|
202
|
+
if (categoryParam) {
|
|
203
|
+
await refreshCacheWithBroadcast(this.ctx, categoryParam as CacheRefreshCategory);
|
|
190
204
|
|
|
205
|
+
await this.actionLogService.insertActionLogTable({
|
|
206
|
+
actionModule: '系统工具',
|
|
207
|
+
actionName: '刷新缓存',
|
|
208
|
+
actionMessage: '刷新缓存成功',
|
|
209
|
+
actionTarget: categoryParam,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return CommonResult.successRes({
|
|
213
|
+
message: `CacheRefreshHub(${categoryParam}) 已刷新(已广播集群)`,
|
|
214
|
+
category: categoryParam,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const bizMemCacheKeys = await this.refreshBizMemCacheKeys('ALL');
|
|
219
|
+
await refreshCacheWithBroadcast(this.ctx, undefined);
|
|
191
220
|
|
|
192
221
|
await this.actionLogService.insertActionLogTable({
|
|
193
222
|
actionModule: '系统工具',
|
|
194
223
|
actionName: '刷新缓存',
|
|
195
224
|
actionMessage: '刷新缓存成功',
|
|
196
|
-
actionTarget:
|
|
225
|
+
actionTarget: 'ALL',
|
|
197
226
|
});
|
|
198
227
|
|
|
199
228
|
return CommonResult.successRes({
|
|
200
|
-
message:
|
|
201
|
-
category:
|
|
229
|
+
message: `全部缓存已刷新:BizMemCache(${bizMemCacheKeys.length}项) + CacheRefreshHub(全部)(已广播集群)`,
|
|
230
|
+
category: 'ALL',
|
|
231
|
+
bizMemCacheKeys,
|
|
202
232
|
});
|
|
203
233
|
}
|
|
204
234
|
|
|
235
|
+
/**
|
|
236
|
+
* 刷新 BizMemCache:写 Redis 时间戳,BizMemCacheService 轮询后全集群重载
|
|
237
|
+
* @param keysParam 逗号分隔的 key,或 ALL
|
|
238
|
+
*/
|
|
239
|
+
private async refreshBizMemCacheKeys(keysParam: string): Promise<string[]> {
|
|
240
|
+
const redisService = await this.ctx.requestContext.getAsync(RedisService);
|
|
241
|
+
const isAll = keysParam.trim().toUpperCase() === 'ALL';
|
|
242
|
+
const inputKeys = isAll
|
|
243
|
+
? bizMemCacheStore.getAllKeys()
|
|
244
|
+
: keysParam.split(',').map(s => s.trim()).filter(Boolean) as BizMemCacheKey[];
|
|
245
|
+
|
|
246
|
+
const refreshedKeys: string[] = [];
|
|
247
|
+
for (const key of inputKeys) {
|
|
248
|
+
if (bizMemCacheStore.isKeyValid(key)) {
|
|
249
|
+
await bizMemCacheStore.markDirty(key, redisService);
|
|
250
|
+
refreshedKeys.push(key);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return refreshedKeys;
|
|
254
|
+
}
|
|
255
|
+
|
|
205
256
|
private checkLocalPermissionEnv() {
|
|
206
257
|
|
|
207
258
|
//是否是开发者
|
|
@@ -3,8 +3,6 @@ import { Context } from '@midwayjs/koa';
|
|
|
3
3
|
import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
|
|
4
4
|
import { BaseApiController } from '../base/BaseApiController';
|
|
5
5
|
import { checkPermission } from '@/middleware/permission.middleware';
|
|
6
|
-
import { refreshCache } from '@/middleware/cacherefresh.middleware';
|
|
7
|
-
import { CacheNameEnum } from '@/models/bizmodels';
|
|
8
6
|
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
9
7
|
import { RelatedType } from '@/service/curd/CurdMixUtils';
|
|
10
8
|
import { SystemTables } from '@/models/SystemTables';
|
|
@@ -40,7 +38,7 @@ export class AccountRoleManageApi extends BaseApiController {
|
|
|
40
38
|
return this.executeSysSimpleSQL('sys_perm_user_role', KeysOfSimpleSQL.SIMPLE_QUERY_ONE);
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
@Post('/createAccountRole', { middleware: [checkPermission(SystemFuncCode.AccountRoleManageWrite)
|
|
41
|
+
@Post('/createAccountRole', { middleware: [checkPermission(SystemFuncCode.AccountRoleManageWrite)] })
|
|
44
42
|
async createAccountRole() {
|
|
45
43
|
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
46
44
|
const body = this.ctx.request.body as any;
|
|
@@ -86,7 +84,7 @@ export class AccountRoleManageApi extends BaseApiController {
|
|
|
86
84
|
});
|
|
87
85
|
}
|
|
88
86
|
|
|
89
|
-
@Post('/updateAccountRole', { middleware: [checkPermission(SystemFuncCode.AccountRoleManageWrite)
|
|
87
|
+
@Post('/updateAccountRole', { middleware: [checkPermission(SystemFuncCode.AccountRoleManageWrite)] })
|
|
90
88
|
async updateAccountRole() {
|
|
91
89
|
return this.executeSysSimpleSQL('sys_perm_user_role', KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
92
90
|
validateCfg: {
|
|
@@ -95,7 +93,7 @@ export class AccountRoleManageApi extends BaseApiController {
|
|
|
95
93
|
});
|
|
96
94
|
}
|
|
97
95
|
|
|
98
|
-
@Post('/deleteAccountRole', { middleware: [checkPermission(SystemFuncCode.AccountRoleManageWrite)
|
|
96
|
+
@Post('/deleteAccountRole', { middleware: [checkPermission(SystemFuncCode.AccountRoleManageWrite)] })
|
|
99
97
|
async deleteAccountRole() {
|
|
100
98
|
return this.executeSysSimpleSQL('sys_perm_user_role', KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
101
99
|
validateCfg: {
|
|
@@ -3,6 +3,7 @@ import { Context } from '@midwayjs/koa';
|
|
|
3
3
|
import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
|
|
4
4
|
import { BaseApiController } from '../base/BaseApiController';
|
|
5
5
|
import { checkPermission } from '@/middleware/permission.middleware';
|
|
6
|
+
import { refreshBizMemCache } from '@/middleware/cacherefresh.middleware';
|
|
6
7
|
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
7
8
|
import { SystemTables } from '@/models/SystemTables';
|
|
8
9
|
import { ISysAnyApiEntity } from '@/models/SystemEntities';
|
|
@@ -35,7 +36,7 @@ export class AnyApiMangeApi extends BaseApiController {
|
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
@Post('/createAnyApi', { middleware: [checkPermission(SystemFuncCode.AnyApiManageWrite)] })
|
|
39
|
+
@Post('/createAnyApi', { middleware: [checkPermission(SystemFuncCode.AnyApiManageWrite), refreshBizMemCache('sysAnyApiCacheObj')] })
|
|
39
40
|
async createAnyApi() {
|
|
40
41
|
fixBodyData(this.ctx.request.body);
|
|
41
42
|
|
|
@@ -49,7 +50,7 @@ export class AnyApiMangeApi extends BaseApiController {
|
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
@Post('/updateAnyApi', { middleware: [checkPermission(SystemFuncCode.AnyApiManageWrite)] })
|
|
53
|
+
@Post('/updateAnyApi', { middleware: [checkPermission(SystemFuncCode.AnyApiManageWrite), refreshBizMemCache('sysAnyApiCacheObj')] })
|
|
53
54
|
async updateAnyApi() {
|
|
54
55
|
fixBodyData(this.ctx.request.body);
|
|
55
56
|
|
|
@@ -61,7 +62,7 @@ export class AnyApiMangeApi extends BaseApiController {
|
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
@Post('/deleteAnyApi', { middleware: [checkPermission(SystemFuncCode.AnyApiManageWrite)] })
|
|
65
|
+
@Post('/deleteAnyApi', { middleware: [checkPermission(SystemFuncCode.AnyApiManageWrite), refreshBizMemCache('sysAnyApiCacheObj')] })
|
|
65
66
|
async deleteAnyApi() {
|
|
66
67
|
return this.executeSysSimpleSQL(SystemTables.sys_anyapi, KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
67
68
|
enableSoftDelete: true,
|
|
@@ -4,8 +4,7 @@ import { KeysOfSimpleSQL, KeysOfValidators } from '@/libs/crud-pro/models/keys';
|
|
|
4
4
|
import { BaseApiController } from '../base/BaseApiController';
|
|
5
5
|
import { checkPermission } from '@/middleware/permission.middleware';
|
|
6
6
|
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
7
|
-
import {
|
|
8
|
-
import { CacheNameEnum } from '@/models/bizmodels';
|
|
7
|
+
import { refreshBizMemCache } from '@/middleware/cacherefresh.middleware';
|
|
9
8
|
|
|
10
9
|
@Controller('/ns/api/manage/app', { middleware: [checkPermission(SystemFuncCode.AppMangeRead)] })
|
|
11
10
|
export class AppMangeApi extends BaseApiController {
|
|
@@ -26,7 +25,7 @@ export class AppMangeApi extends BaseApiController {
|
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
@Post('/createApp', { middleware: [checkPermission(SystemFuncCode.AppMangeWrite),
|
|
28
|
+
@Post('/createApp', { middleware: [checkPermission(SystemFuncCode.AppMangeWrite), refreshBizMemCache(['sysAppCacheObj', 'sysAppPageCacheObj'])] })
|
|
30
29
|
async createApp() {
|
|
31
30
|
return this.executeSysSimpleSQL('sys_app', KeysOfSimpleSQL.SIMPLE_INSERT, {
|
|
32
31
|
enableSoftDelete: true,
|
|
@@ -38,7 +37,7 @@ export class AppMangeApi extends BaseApiController {
|
|
|
38
37
|
});
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
@Post('/updateApp', { middleware: [checkPermission(SystemFuncCode.AppMangeWrite),
|
|
40
|
+
@Post('/updateApp', { middleware: [checkPermission(SystemFuncCode.AppMangeWrite), refreshBizMemCache(['sysAppCacheObj', 'sysAppPageCacheObj'])] })
|
|
42
41
|
async updateApp() {
|
|
43
42
|
return this.executeSysSimpleSQL('sys_app', KeysOfSimpleSQL.SIMPLE_UPDATE, {
|
|
44
43
|
enableSoftDelete: true,
|
|
@@ -49,7 +48,7 @@ export class AppMangeApi extends BaseApiController {
|
|
|
49
48
|
});
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
@Post('/deleteApp', { middleware: [checkPermission(SystemFuncCode.AppMangeWrite),
|
|
51
|
+
@Post('/deleteApp', { middleware: [checkPermission(SystemFuncCode.AppMangeWrite), refreshBizMemCache(['sysAppCacheObj', 'sysAppPageCacheObj'])] })
|
|
53
52
|
async deleteApp() {
|
|
54
53
|
return this.executeSysSimpleSQL('sys_app', KeysOfSimpleSQL.SIMPLE_DELETE, {
|
|
55
54
|
enableSoftDelete: true,
|