midway-fatcms 0.0.1-beta.68 → 0.0.1-beta.70
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 +1 -0
- package/dist/controller/gateway/CrudStdGatewayController.d.ts +1 -0
- package/dist/controller/gateway/CrudStdGatewayController.js +7 -13
- package/dist/controller/gateway/PublicApiController.d.ts +2 -1
- package/dist/controller/gateway/PublicApiController.js +31 -37
- package/dist/controller/manage/AppMangeApi.d.ts +3 -1
- package/dist/controller/manage/AppMangeApi.js +13 -0
- package/dist/controller/manage/SysConfigMangeApi.d.ts +1 -0
- package/dist/controller/manage/SysConfigMangeApi.js +9 -2
- package/dist/controller/manage/UserAccountManageApi.d.ts +4 -2
- package/dist/controller/manage/UserAccountManageApi.js +24 -0
- package/dist/controller/manage/WorkbenchMangeApi.js +2 -2
- package/dist/controller/render/AppRenderController.d.ts +1 -0
- package/dist/controller/render/AppRenderController.js +6 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/libs/crud-pro/interfaces.d.ts +1 -0
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +1 -0
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +2 -2
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +2 -4
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.d.ts +1 -1
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.js +4 -1
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.d.ts +1 -1
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.js +4 -1
- package/dist/models/bizmodels.d.ts +4 -3
- package/dist/models/bizmodels.js +4 -3
- package/dist/service/EnumInfoService.d.ts +1 -0
- package/dist/service/EnumInfoService.js +10 -17
- package/dist/service/SysAppService.d.ts +14 -0
- package/dist/service/SysAppService.js +96 -0
- package/dist/service/SysConfigService.d.ts +3 -0
- package/dist/service/SysConfigService.js +29 -12
- package/dist/service/WorkbenchService.d.ts +10 -5
- package/dist/service/WorkbenchService.js +54 -42
- package/dist/service/base/cache/CacheServiceFactory.d.ts +5 -0
- package/dist/service/base/cache/CacheServiceFactory.js +6 -1
- package/dist/service/crudstd/CrudStdService.d.ts +2 -14
- package/dist/service/crudstd/CrudStdService.js +6 -39
- package/dist/service/curd/CrudProQuick.d.ts +9 -3
- package/dist/service/curd/CrudProQuick.js +19 -3
- package/dist/service/curd/CurdMixByAccountService.js +4 -4
- package/dist/service/curd/CurdMixBySysConfigService.js +2 -2
- package/dist/service/curd/CurdMixByWorkbenchService.js +2 -2
- package/package.json +1 -1
- package/src/config/config.default.ts +1 -0
- package/src/controller/gateway/CrudStdGatewayController.ts +7 -13
- package/src/controller/gateway/PublicApiController.ts +39 -49
- package/src/controller/manage/AppMangeApi.ts +14 -1
- package/src/controller/manage/SysConfigMangeApi.ts +16 -8
- package/src/controller/manage/UserAccountManageApi.ts +28 -0
- package/src/controller/manage/WorkbenchMangeApi.ts +2 -2
- package/src/controller/render/AppRenderController.ts +5 -14
- package/src/index.ts +1 -0
- package/src/libs/crud-pro/interfaces.ts +1 -0
- package/src/libs/crud-pro/models/SqlCfgModel.ts +1 -0
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +2 -2
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +15 -17
- package/src/libs/crud-pro/utils/sqlConvert/convertMsSql.ts +5 -1
- package/src/libs/crud-pro/utils/sqlConvert/convertPgSql.ts +6 -1
- package/src/models/bizmodels.ts +5 -3
- package/src/service/EnumInfoService.ts +9 -22
- package/src/service/SysAppService.ts +88 -0
- package/src/service/SysConfigService.ts +30 -16
- package/src/service/WorkbenchService.ts +78 -61
- package/src/service/base/cache/CacheServiceFactory.ts +12 -1
- package/src/service/crudstd/CrudStdService.ts +7 -43
- package/src/service/curd/CrudProQuick.ts +22 -3
- package/src/service/curd/CurdMixByAccountService.ts +4 -4
- package/src/service/curd/CurdMixBySysConfigService.ts +3 -2
- package/src/service/curd/CurdMixByWorkbenchService.ts +2 -2
|
@@ -20,6 +20,7 @@ const CurdMixByLinkToCustomService_1 = require("./curd/CurdMixByLinkToCustomServ
|
|
|
20
20
|
const global_config_1 = require("../libs/global-config/global-config");
|
|
21
21
|
const CacheServiceFactory_1 = require("./base/cache/CacheServiceFactory");
|
|
22
22
|
const bizmodels_1 = require("../models/bizmodels");
|
|
23
|
+
const SysConfigService_1 = require("../service/SysConfigService");
|
|
23
24
|
function filterEmpty(e) {
|
|
24
25
|
return e.label && typeof e.value !== 'undefined';
|
|
25
26
|
}
|
|
@@ -29,16 +30,16 @@ let EnumInfoService = class EnumInfoService {
|
|
|
29
30
|
if (type === CurdMixUtils_1.RelatedType.linkToCustom) {
|
|
30
31
|
return await this.queryEnumInfoByLinkToCustom(code);
|
|
31
32
|
}
|
|
33
|
+
if (type === CurdMixUtils_1.RelatedType.sysCfgEnum) {
|
|
34
|
+
return await this.queryEnumInfoBySysCfgEnum(code);
|
|
35
|
+
}
|
|
32
36
|
const cacheKey = `${type}@@${code}`;
|
|
33
37
|
return await this.cacheServiceFactory.getJsonObjectCache({
|
|
34
38
|
cacheKey,
|
|
35
39
|
refreshCache,
|
|
36
40
|
cacheName: bizmodels_1.CacheNameEnum.GetEnumInfoByCode,
|
|
37
41
|
getter: async () => {
|
|
38
|
-
if (type === CurdMixUtils_1.RelatedType.
|
|
39
|
-
return await this.queryEnumInfoBySysCfgEnum(code);
|
|
40
|
-
}
|
|
41
|
-
else if (type === CurdMixUtils_1.RelatedType.dict) {
|
|
42
|
+
if (type === CurdMixUtils_1.RelatedType.dict) {
|
|
42
43
|
return await this.queryEnumInfoItemByDict(code);
|
|
43
44
|
}
|
|
44
45
|
return [];
|
|
@@ -72,19 +73,7 @@ let EnumInfoService = class EnumInfoService {
|
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
async queryEnumInfoBySysCfgEnum(code) {
|
|
75
|
-
const
|
|
76
|
-
const res1 = await this.curdProService.executeCrudByCfg({
|
|
77
|
-
condition: { config_code: code },
|
|
78
|
-
}, {
|
|
79
|
-
sqlTable: SystemTables_1.SystemTables.sys_configs,
|
|
80
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
81
|
-
sqlDatabase: SystemDbName,
|
|
82
|
-
sqlDbType: SystemDbType,
|
|
83
|
-
});
|
|
84
|
-
const obj = res1.getOneObj();
|
|
85
|
-
if (!obj) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
76
|
+
const obj = await this.sysConfigService.getSysConfigOne(code);
|
|
88
77
|
const rows = (0, parseConfig_1.parseConfigContentToEnumInfo)(obj);
|
|
89
78
|
return rows.map(e => ({ label: e.label, value: e.value, style: e.style, children: e.children })).filter(filterEmpty);
|
|
90
79
|
}
|
|
@@ -121,6 +110,10 @@ __decorate([
|
|
|
121
110
|
(0, core_1.Inject)(),
|
|
122
111
|
__metadata("design:type", CacheServiceFactory_1.CacheServiceFactory)
|
|
123
112
|
], EnumInfoService.prototype, "cacheServiceFactory", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
(0, core_1.Inject)(),
|
|
115
|
+
__metadata("design:type", SysConfigService_1.SysConfigService)
|
|
116
|
+
], EnumInfoService.prototype, "sysConfigService", void 0);
|
|
124
117
|
EnumInfoService = __decorate([
|
|
125
118
|
(0, core_1.Provide)()
|
|
126
119
|
], EnumInfoService);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseService } from './base/BaseService';
|
|
2
|
+
export declare class SysAppService extends BaseService {
|
|
3
|
+
private curdProService;
|
|
4
|
+
private cacheServiceFactory;
|
|
5
|
+
private get sysAppDao();
|
|
6
|
+
private get sysAppPageDao();
|
|
7
|
+
getSysAppPageOne({ page_path, workbench_code }: {
|
|
8
|
+
page_path: string;
|
|
9
|
+
workbench_code: string;
|
|
10
|
+
}): Promise<any>;
|
|
11
|
+
getSysAppOne(app_code: string): Promise<any>;
|
|
12
|
+
deletePrivateField(parsedAppInfo: any): any;
|
|
13
|
+
removeSysAppOneCache(app_code: string): Promise<any>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SysAppService = void 0;
|
|
13
|
+
const core_1 = require("@midwayjs/core");
|
|
14
|
+
const SystemTables_1 = require("../models/SystemTables");
|
|
15
|
+
const BaseService_1 = require("./base/BaseService");
|
|
16
|
+
const CurdProService_1 = require("./curd/CurdProService");
|
|
17
|
+
const global_config_1 = require("../libs/global-config/global-config");
|
|
18
|
+
const CacheServiceFactory_1 = require("../service/base/cache/CacheServiceFactory");
|
|
19
|
+
const bizmodels_1 = require("../models/bizmodels");
|
|
20
|
+
let SysAppService = class SysAppService extends BaseService_1.BaseService {
|
|
21
|
+
get sysAppDao() {
|
|
22
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
23
|
+
return this.curdProService.getBbUtil(SystemDbName, SystemDbType, SystemTables_1.SystemTables.sys_app);
|
|
24
|
+
}
|
|
25
|
+
get sysAppPageDao() {
|
|
26
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
27
|
+
return this.curdProService.getBbUtil(SystemDbName, SystemDbType, SystemTables_1.SystemTables.sys_app_page);
|
|
28
|
+
}
|
|
29
|
+
async getSysAppPageOne({ page_path, workbench_code }) {
|
|
30
|
+
if (!page_path || typeof page_path !== 'string') {
|
|
31
|
+
throw new Error('[getSysAppPageOne] page_path required');
|
|
32
|
+
}
|
|
33
|
+
if (!workbench_code || typeof workbench_code !== 'string') {
|
|
34
|
+
throw new Error('[getSysAppPageOne] workbench_code required');
|
|
35
|
+
}
|
|
36
|
+
return await this.cacheServiceFactory.getJsonObjectCache({
|
|
37
|
+
cacheKey: `${workbench_code}#${page_path}`,
|
|
38
|
+
cacheName: bizmodels_1.CacheNameEnum.GetSysAppPageOne,
|
|
39
|
+
getter: async () => {
|
|
40
|
+
return await this.sysAppPageDao.getUniqueOne({
|
|
41
|
+
condition: { page_path, workbench_code, deleted_at: 0 }
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async getSysAppOne(app_code) {
|
|
47
|
+
if (!app_code || typeof app_code !== 'string') {
|
|
48
|
+
throw new Error('[getSysAppOne] app_code required');
|
|
49
|
+
}
|
|
50
|
+
return await this.cacheServiceFactory.getJsonObjectCache({
|
|
51
|
+
cacheKey: app_code,
|
|
52
|
+
cacheName: bizmodels_1.CacheNameEnum.GetSysAppOne,
|
|
53
|
+
getter: async () => {
|
|
54
|
+
return await this.sysAppDao.getUniqueOne({
|
|
55
|
+
condition: { app_code, deleted_at: 0 }
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
deletePrivateField(parsedAppInfo) {
|
|
61
|
+
if (!parsedAppInfo) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const parsedAppInfo2 = { ...parsedAppInfo };
|
|
65
|
+
delete parsedAppInfo2.created_at;
|
|
66
|
+
delete parsedAppInfo2.created_by;
|
|
67
|
+
delete parsedAppInfo2.workbench_code_array;
|
|
68
|
+
delete parsedAppInfo2.modified_at;
|
|
69
|
+
delete parsedAppInfo2.modified_by;
|
|
70
|
+
delete parsedAppInfo2.modified_desc;
|
|
71
|
+
delete parsedAppInfo2.std_crud_db;
|
|
72
|
+
delete parsedAppInfo2.std_crud_tbl;
|
|
73
|
+
return parsedAppInfo2;
|
|
74
|
+
}
|
|
75
|
+
async removeSysAppOneCache(app_code) {
|
|
76
|
+
if (!app_code || typeof app_code !== 'string') {
|
|
77
|
+
throw new Error('[removeSysAppOneCache] app_code required');
|
|
78
|
+
}
|
|
79
|
+
return await this.cacheServiceFactory.removeItemCache({
|
|
80
|
+
cacheKey: app_code,
|
|
81
|
+
cacheName: bizmodels_1.CacheNameEnum.GetSysAppOne
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
__decorate([
|
|
86
|
+
(0, core_1.Inject)(),
|
|
87
|
+
__metadata("design:type", CurdProService_1.CurdProService)
|
|
88
|
+
], SysAppService.prototype, "curdProService", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
(0, core_1.Inject)(),
|
|
91
|
+
__metadata("design:type", CacheServiceFactory_1.CacheServiceFactory)
|
|
92
|
+
], SysAppService.prototype, "cacheServiceFactory", void 0);
|
|
93
|
+
SysAppService = __decorate([
|
|
94
|
+
(0, core_1.Provide)()
|
|
95
|
+
], SysAppService);
|
|
96
|
+
exports.SysAppService = SysAppService;
|
|
@@ -3,5 +3,8 @@ import { BaseService } from './base/BaseService';
|
|
|
3
3
|
export declare class SysConfigService extends BaseService {
|
|
4
4
|
ctx: Context;
|
|
5
5
|
private curdProService;
|
|
6
|
+
private cacheServiceFactory;
|
|
7
|
+
private get sysConfigsDao();
|
|
6
8
|
getSysConfigOne(config_code: string): Promise<any>;
|
|
9
|
+
removeSysConfigOneCache(config_code: string): Promise<any>;
|
|
7
10
|
}
|
|
@@ -11,26 +11,39 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.SysConfigService = void 0;
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const keys_1 = require("../libs/crud-pro/models/keys");
|
|
15
14
|
const SystemTables_1 = require("../models/SystemTables");
|
|
16
15
|
const BaseService_1 = require("./base/BaseService");
|
|
17
16
|
const CurdProService_1 = require("./curd/CurdProService");
|
|
18
17
|
const global_config_1 = require("../libs/global-config/global-config");
|
|
18
|
+
const bizmodels_1 = require("../models/bizmodels");
|
|
19
|
+
const CacheServiceFactory_1 = require("../service/base/cache/CacheServiceFactory");
|
|
19
20
|
let SysConfigService = class SysConfigService extends BaseService_1.BaseService {
|
|
21
|
+
get sysConfigsDao() {
|
|
22
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
23
|
+
return this.curdProService.getBbUtil(SystemDbName, SystemDbType, SystemTables_1.SystemTables.sys_configs);
|
|
24
|
+
}
|
|
20
25
|
async getSysConfigOne(config_code) {
|
|
21
|
-
if (!config_code) {
|
|
22
|
-
throw new Error('[
|
|
26
|
+
if (!config_code || typeof config_code !== 'string') {
|
|
27
|
+
throw new Error('[getSysAppOne] config_code required');
|
|
23
28
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
return await this.cacheServiceFactory.getJsonObjectCache({
|
|
30
|
+
cacheKey: config_code,
|
|
31
|
+
cacheName: bizmodels_1.CacheNameEnum.GetSysConfigOne,
|
|
32
|
+
getter: async () => {
|
|
33
|
+
return await this.sysConfigsDao.getUniqueOne({
|
|
34
|
+
condition: { config_code, deleted_at: 0 }
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async removeSysConfigOneCache(config_code) {
|
|
40
|
+
if (!config_code || typeof config_code !== 'string') {
|
|
41
|
+
throw new Error('[removeSysConfigOneCache] config_code required');
|
|
42
|
+
}
|
|
43
|
+
return await this.cacheServiceFactory.removeItemCache({
|
|
44
|
+
cacheKey: config_code,
|
|
45
|
+
cacheName: bizmodels_1.CacheNameEnum.GetSysConfigOne,
|
|
32
46
|
});
|
|
33
|
-
return res1.getOneObj();
|
|
34
47
|
}
|
|
35
48
|
};
|
|
36
49
|
__decorate([
|
|
@@ -41,6 +54,10 @@ __decorate([
|
|
|
41
54
|
(0, core_1.Inject)(),
|
|
42
55
|
__metadata("design:type", CurdProService_1.CurdProService)
|
|
43
56
|
], SysConfigService.prototype, "curdProService", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, core_1.Inject)(),
|
|
59
|
+
__metadata("design:type", CacheServiceFactory_1.CacheServiceFactory)
|
|
60
|
+
], SysConfigService.prototype, "cacheServiceFactory", void 0);
|
|
44
61
|
SysConfigService = __decorate([
|
|
45
62
|
(0, core_1.Provide)()
|
|
46
63
|
], SysConfigService);
|
|
@@ -5,21 +5,21 @@ import { IScheduleService } from '../interface';
|
|
|
5
5
|
export declare class WorkbenchService extends BaseService implements IScheduleService {
|
|
6
6
|
ctx: Context;
|
|
7
7
|
private curdProService;
|
|
8
|
+
private cacheServiceFactory;
|
|
8
9
|
private fatcmsTargetWorkbenchCode;
|
|
9
|
-
clearCache(): void
|
|
10
|
+
clearCache(): Promise<void>;
|
|
10
11
|
runBySchedule(): Promise<void>;
|
|
12
|
+
private getWorkbenchCachedObj;
|
|
11
13
|
/**
|
|
12
14
|
* 获取所有站点列表
|
|
13
|
-
* @param isForceRefresh 是否强制刷新缓存
|
|
14
15
|
* @returns
|
|
15
16
|
*/
|
|
16
|
-
getAllWorkbenchInfoList(
|
|
17
|
+
getAllWorkbenchInfoList(): Promise<IWorkbenchEntity[]>;
|
|
17
18
|
/**
|
|
18
19
|
* 获取所有站点列表,以map的形式返回。其中key为站点域名,value为站点信息
|
|
19
|
-
* @param isForceRefresh 是否强制刷新缓存
|
|
20
20
|
* @returns
|
|
21
21
|
*/
|
|
22
|
-
getAllWorkbenchInfoMap(
|
|
22
|
+
getAllWorkbenchInfoMap(): Promise<Record<string, IWorkbenchEntity>>;
|
|
23
23
|
/**
|
|
24
24
|
* 检查站点编码是否匹配
|
|
25
25
|
* @param workbench_code_array 站点编码数组
|
|
@@ -50,5 +50,10 @@ export declare class WorkbenchService extends BaseService implements IScheduleSe
|
|
|
50
50
|
private getCurrentHost;
|
|
51
51
|
isSupportCurrentWorkbench(workbench_code_array: string | string[]): Promise<boolean>;
|
|
52
52
|
isSupportCurrentHostForForMiddleware(): Promise<string | boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* 根据站点,配置接口报名单模式
|
|
55
|
+
* @param workbenchInfo
|
|
56
|
+
* @param path
|
|
57
|
+
*/
|
|
53
58
|
isSupportTheNodePathByWorkbenchInfo(workbenchInfo: IWorkbenchEntity, path: string): boolean;
|
|
54
59
|
}
|
|
@@ -23,61 +23,64 @@ const MixinUtils_1 = require("../libs/crud-pro/utils/MixinUtils");
|
|
|
23
23
|
const global_config_1 = require("../libs/global-config/global-config");
|
|
24
24
|
const AsyncTaskModel_1 = require("../models/AsyncTaskModel");
|
|
25
25
|
const format_url_1 = require("../libs/utils/format-url");
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// max: 500,
|
|
29
|
-
// ttl: 1000 * 60 * 60,
|
|
30
|
-
// ttlAutopurge: true,
|
|
31
|
-
// });
|
|
32
|
-
const lruCache = new Map();
|
|
33
|
-
const CACHE_KEY_WORKBENCH_LIST = 'CACHE_KEY_WORKBENCH_LIST';
|
|
34
|
-
const CACHE_KEY_DOMAIN_MAP = 'CACHE_KEY_DOMAIN_MAP';
|
|
26
|
+
const CacheServiceFactory_1 = require("../service/base/cache/CacheServiceFactory");
|
|
27
|
+
const bizmodels_1 = require("../models/bizmodels");
|
|
35
28
|
let WorkbenchService = class WorkbenchService extends BaseService_1.BaseService {
|
|
36
|
-
clearCache() {
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
async clearCache() {
|
|
30
|
+
await this.cacheServiceFactory.removeItemCache({
|
|
31
|
+
cacheKey: bizmodels_1.CacheNameEnum.CurdMixByWorkbench,
|
|
32
|
+
cacheName: bizmodels_1.CacheNameEnum.CurdMixByWorkbench,
|
|
33
|
+
});
|
|
34
|
+
await this.cacheServiceFactory.removeItemCache({
|
|
35
|
+
cacheKey: bizmodels_1.CacheNameEnum.GetWorkbenchCachedObj,
|
|
36
|
+
cacheName: bizmodels_1.CacheNameEnum.GetWorkbenchCachedObj,
|
|
37
|
+
});
|
|
39
38
|
}
|
|
40
39
|
async runBySchedule() {
|
|
41
|
-
await this.
|
|
40
|
+
await this.getWorkbenchCachedObj(true);
|
|
41
|
+
}
|
|
42
|
+
async getWorkbenchCachedObj(isForceRefresh) {
|
|
43
|
+
return this.cacheServiceFactory.getJsonObjectCache({
|
|
44
|
+
cacheKey: bizmodels_1.CacheNameEnum.GetWorkbenchCachedObj,
|
|
45
|
+
cacheName: bizmodels_1.CacheNameEnum.GetWorkbenchCachedObj,
|
|
46
|
+
refreshCache: isForceRefresh,
|
|
47
|
+
getter: async () => {
|
|
48
|
+
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
49
|
+
const reqJson = { condition: {}, pageSize: 1000, limit: 1000 };
|
|
50
|
+
const res = await this.curdProService.executeCrudByCfg(reqJson, {
|
|
51
|
+
sqlTable: SystemTables_1.SystemTables.sys_workbench,
|
|
52
|
+
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
53
|
+
sqlDatabase: SystemDbName,
|
|
54
|
+
sqlDbType: SystemDbType,
|
|
55
|
+
});
|
|
56
|
+
const listData = res.getResRows();
|
|
57
|
+
const domainMap1 = MixinUtils_1.MixinUtils.toMap(listData, (e) => e.workbench_domain); // 主域名。其他两个域名。
|
|
58
|
+
const domainMap2 = MixinUtils_1.MixinUtils.toMap(listData, (e) => e.workbench_domain2);
|
|
59
|
+
const domainMap3 = MixinUtils_1.MixinUtils.toMap(listData, (e) => e.workbench_domain3);
|
|
60
|
+
const domainMap = { ...domainMap1, ...domainMap2, ...domainMap3 };
|
|
61
|
+
const cacheObj = {
|
|
62
|
+
workbenchList: listData,
|
|
63
|
+
workbenchDomainMap: domainMap
|
|
64
|
+
};
|
|
65
|
+
return cacheObj;
|
|
66
|
+
},
|
|
67
|
+
});
|
|
42
68
|
}
|
|
43
69
|
/**
|
|
44
70
|
* 获取所有站点列表
|
|
45
|
-
* @param isForceRefresh 是否强制刷新缓存
|
|
46
71
|
* @returns
|
|
47
72
|
*/
|
|
48
|
-
async getAllWorkbenchInfoList(
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
if (!listData || isForceRefresh === true) {
|
|
52
|
-
const reqJson = { condition: {}, pageSize: 1000, limit: 1000 };
|
|
53
|
-
const res = await this.curdProService.executeCrudByCfg(reqJson, {
|
|
54
|
-
sqlTable: SystemTables_1.SystemTables.sys_workbench,
|
|
55
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
56
|
-
sqlDatabase: SystemDbName,
|
|
57
|
-
sqlDbType: SystemDbType,
|
|
58
|
-
});
|
|
59
|
-
listData = res.getResRows();
|
|
60
|
-
lruCache.set(CACHE_KEY_WORKBENCH_LIST, listData);
|
|
61
|
-
}
|
|
62
|
-
return listData;
|
|
73
|
+
async getAllWorkbenchInfoList() {
|
|
74
|
+
const cachedObj = await this.getWorkbenchCachedObj();
|
|
75
|
+
return cachedObj.workbenchList;
|
|
63
76
|
}
|
|
64
77
|
/**
|
|
65
78
|
* 获取所有站点列表,以map的形式返回。其中key为站点域名,value为站点信息
|
|
66
|
-
* @param isForceRefresh 是否强制刷新缓存
|
|
67
79
|
* @returns
|
|
68
80
|
*/
|
|
69
|
-
async getAllWorkbenchInfoMap(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!domainMap || isForceRefresh === true) {
|
|
73
|
-
listData = await this.getAllWorkbenchInfoList(isForceRefresh);
|
|
74
|
-
const domainMap1 = MixinUtils_1.MixinUtils.toMap(listData, (e) => e.workbench_domain); // 主域名。其他两个域名。
|
|
75
|
-
const domainMap2 = MixinUtils_1.MixinUtils.toMap(listData, (e) => e.workbench_domain2);
|
|
76
|
-
const domainMap3 = MixinUtils_1.MixinUtils.toMap(listData, (e) => e.workbench_domain3);
|
|
77
|
-
domainMap = { ...domainMap1, ...domainMap2, ...domainMap3 };
|
|
78
|
-
lruCache.set(CACHE_KEY_DOMAIN_MAP, domainMap);
|
|
79
|
-
}
|
|
80
|
-
return domainMap;
|
|
81
|
+
async getAllWorkbenchInfoMap() {
|
|
82
|
+
const cachedObj = await this.getWorkbenchCachedObj();
|
|
83
|
+
return cachedObj.workbenchDomainMap;
|
|
81
84
|
}
|
|
82
85
|
/**
|
|
83
86
|
* 检查站点编码是否匹配
|
|
@@ -194,6 +197,11 @@ let WorkbenchService = class WorkbenchService extends BaseService_1.BaseService
|
|
|
194
197
|
}
|
|
195
198
|
return true;
|
|
196
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* 根据站点,配置接口报名单模式
|
|
202
|
+
* @param workbenchInfo
|
|
203
|
+
* @param path
|
|
204
|
+
*/
|
|
197
205
|
isSupportTheNodePathByWorkbenchInfo(workbenchInfo, path) {
|
|
198
206
|
// 非node api路径,直接返回true
|
|
199
207
|
if (!path.startsWith('/ns/')) {
|
|
@@ -227,6 +235,10 @@ __decorate([
|
|
|
227
235
|
(0, core_1.Inject)(),
|
|
228
236
|
__metadata("design:type", CurdProService_1.CurdProService)
|
|
229
237
|
], WorkbenchService.prototype, "curdProService", void 0);
|
|
238
|
+
__decorate([
|
|
239
|
+
(0, core_1.Inject)(),
|
|
240
|
+
__metadata("design:type", CacheServiceFactory_1.CacheServiceFactory)
|
|
241
|
+
], WorkbenchService.prototype, "cacheServiceFactory", void 0);
|
|
230
242
|
__decorate([
|
|
231
243
|
(0, core_1.Config)('fatcmsTargetWorkbenchCode'),
|
|
232
244
|
__metadata("design:type", String)
|
|
@@ -7,6 +7,10 @@ interface IGetJsonObjectCacheParam {
|
|
|
7
7
|
refreshCache?: boolean;
|
|
8
8
|
getter: () => Promise<any>;
|
|
9
9
|
}
|
|
10
|
+
interface IRemoveItemCacheParam {
|
|
11
|
+
cacheName: CacheNameEnum;
|
|
12
|
+
cacheKey: string;
|
|
13
|
+
}
|
|
10
14
|
export declare class CacheServiceFactory {
|
|
11
15
|
protected ctx: Context;
|
|
12
16
|
private fatcmsCache;
|
|
@@ -14,5 +18,6 @@ export declare class CacheServiceFactory {
|
|
|
14
18
|
private getCacheService;
|
|
15
19
|
getCacheServiceByName(cacheName: CacheNameEnum): ICacheService;
|
|
16
20
|
getJsonObjectCache(param: IGetJsonObjectCacheParam): Promise<any>;
|
|
21
|
+
removeItemCache(param: IRemoveItemCacheParam): Promise<any>;
|
|
17
22
|
}
|
|
18
23
|
export {};
|
|
@@ -20,7 +20,7 @@ const MemoryCache_1 = require("./MemoryCache");
|
|
|
20
20
|
const NoneCache_1 = require("./NoneCache");
|
|
21
21
|
const defaultCacheConfig = {
|
|
22
22
|
cacheLevel: SystemEntities_1.CacheLevelEnum.MEMORY,
|
|
23
|
-
cacheSecond: 60 *
|
|
23
|
+
cacheSecond: 60 * 60 * 24 * 7
|
|
24
24
|
};
|
|
25
25
|
let CacheServiceFactory = class CacheServiceFactory {
|
|
26
26
|
getCacheService(cacheLevelEnum, cacheName, cacheSecond) {
|
|
@@ -59,6 +59,11 @@ let CacheServiceFactory = class CacheServiceFactory {
|
|
|
59
59
|
}
|
|
60
60
|
return obj;
|
|
61
61
|
}
|
|
62
|
+
async removeItemCache(param) {
|
|
63
|
+
const { cacheName, cacheKey } = param;
|
|
64
|
+
const cacheService = this.getCacheServiceByName(cacheName);
|
|
65
|
+
return await cacheService.removeItem(cacheKey);
|
|
66
|
+
}
|
|
62
67
|
};
|
|
63
68
|
__decorate([
|
|
64
69
|
(0, core_1.Inject)(),
|
|
@@ -7,7 +7,7 @@ import { ExecuteContext } from '../../libs/crud-pro/models/ExecuteContext';
|
|
|
7
7
|
import { CrudStdActionService } from './CrudStdActionService';
|
|
8
8
|
import { CrudStdRelationService } from './CrudStdRelationService';
|
|
9
9
|
import { ApiBaseService } from '../base/ApiBaseService';
|
|
10
|
-
import {
|
|
10
|
+
import { SysAppService } from "../../service/SysAppService";
|
|
11
11
|
export declare const SPECIAL_SETTING_KEY: {
|
|
12
12
|
QUERY_LIST: string;
|
|
13
13
|
QUERY_ONE: string;
|
|
@@ -26,7 +26,7 @@ export declare class CrudStdService extends ApiBaseService {
|
|
|
26
26
|
protected curdMixService: CurdMixService;
|
|
27
27
|
protected crudStdActionService: CrudStdActionService;
|
|
28
28
|
protected crudStdRelationService: CrudStdRelationService;
|
|
29
|
-
protected
|
|
29
|
+
protected sysAppService: SysAppService;
|
|
30
30
|
/**
|
|
31
31
|
* 执行普通CRUD
|
|
32
32
|
*/
|
|
@@ -46,24 +46,12 @@ export declare class CrudStdService extends ApiBaseService {
|
|
|
46
46
|
* @param params
|
|
47
47
|
*/
|
|
48
48
|
executeStdActionByReq(stdAction: ICrudStdActionParams, params: IRequestModelCrudProExt): Promise<ExecuteContext>;
|
|
49
|
-
/**
|
|
50
|
-
* 查询APP信息
|
|
51
|
-
* @param appCode
|
|
52
|
-
* @private
|
|
53
|
-
*/
|
|
54
|
-
private getCrudStdAppInfo;
|
|
55
49
|
/**
|
|
56
50
|
* 查询APP信息
|
|
57
51
|
* @param appCode
|
|
58
52
|
* @private
|
|
59
53
|
*/
|
|
60
54
|
getParsedCrudStdAppInfo(appCode: string): Promise<ICrudStdAppInfo>;
|
|
61
|
-
/**
|
|
62
|
-
* 查询APP信息
|
|
63
|
-
* @param appCode
|
|
64
|
-
* @private
|
|
65
|
-
*/
|
|
66
|
-
private getParsedCrudStdAppInfoPrivate;
|
|
67
55
|
private hasOperationPerm;
|
|
68
56
|
private fixCfgModelAndParamBySoftDelete;
|
|
69
57
|
private fixCfgModelByFilterValue;
|
|
@@ -18,15 +18,13 @@ const CurdMixService_1 = require("../curd/CurdMixService");
|
|
|
18
18
|
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
19
19
|
const functions_1 = require("../../libs/utils/functions");
|
|
20
20
|
const devops_1 = require("../../models/devops");
|
|
21
|
-
const SystemTables_1 = require("../../models/SystemTables");
|
|
22
21
|
const CrudStdActionService_1 = require("./CrudStdActionService");
|
|
23
22
|
const CrudStdRelationService_1 = require("./CrudStdRelationService");
|
|
24
23
|
const ApiBaseService_1 = require("../base/ApiBaseService");
|
|
25
24
|
const DatabaseName_1 = require("../../libs/crud-pro/utils/DatabaseName");
|
|
26
25
|
const global_config_1 = require("../../libs/global-config/global-config");
|
|
27
26
|
const MixinUtils_1 = require("../../libs/crud-pro/utils/MixinUtils");
|
|
28
|
-
const
|
|
29
|
-
const bizmodels_1 = require("../../models/bizmodels");
|
|
27
|
+
const SysAppService_1 = require("../../service/SysAppService");
|
|
30
28
|
exports.SPECIAL_SETTING_KEY = {
|
|
31
29
|
QUERY_LIST: 'QUERY_LIST',
|
|
32
30
|
QUERY_ONE: 'QUERY_ONE',
|
|
@@ -213,48 +211,17 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
|
|
|
213
211
|
const actionCfg = appInfo.settingKeyActionCfg;
|
|
214
212
|
return this.crudStdActionService.handleStdActionByReq({ appInfo, params, actionsMap, actionCfg });
|
|
215
213
|
}
|
|
216
|
-
/**
|
|
217
|
-
* 查询APP信息
|
|
218
|
-
* @param appCode
|
|
219
|
-
* @private
|
|
220
|
-
*/
|
|
221
|
-
async getCrudStdAppInfo(appCode) {
|
|
222
|
-
const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
|
|
223
|
-
this.logInfo('getCrudStdAppInfo', appCode);
|
|
224
|
-
const ss = {
|
|
225
|
-
sqlTable: SystemTables_1.SystemTables.sys_app,
|
|
226
|
-
sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
227
|
-
sqlDatabase: SystemDbName,
|
|
228
|
-
sqlDbType: SystemDbType,
|
|
229
|
-
};
|
|
230
|
-
return await this.curdMixService.executeCrudByCfg({ condition: { app_code: appCode } }, ss);
|
|
231
|
-
}
|
|
232
214
|
/**
|
|
233
215
|
* 查询APP信息
|
|
234
216
|
* @param appCode
|
|
235
217
|
* @private
|
|
236
218
|
*/
|
|
237
219
|
async getParsedCrudStdAppInfo(appCode) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
cacheName: bizmodels_1.CacheNameEnum.GetParsedCrudStdAppInfo,
|
|
241
|
-
getter: async () => {
|
|
242
|
-
return await this.getParsedCrudStdAppInfoPrivate(appCode);
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* 查询APP信息
|
|
248
|
-
* @param appCode
|
|
249
|
-
* @private
|
|
250
|
-
*/
|
|
251
|
-
async getParsedCrudStdAppInfoPrivate(appCode) {
|
|
252
|
-
const a = await this.getCrudStdAppInfo(appCode);
|
|
253
|
-
const { row } = a.getResModel();
|
|
254
|
-
if (!row) {
|
|
220
|
+
const appInfo = await this.sysAppService.getSysAppOne(appCode);
|
|
221
|
+
if (!appInfo) {
|
|
255
222
|
return null;
|
|
256
223
|
}
|
|
257
|
-
const { app_schema, ...others } =
|
|
224
|
+
const { app_schema, ...others } = appInfo;
|
|
258
225
|
const stdCrudCfgObj = (0, functions_1.parseJsonObject)(app_schema);
|
|
259
226
|
const handleArrayCfg = (arrayCfg) => {
|
|
260
227
|
if (Array.isArray(arrayCfg)) {
|
|
@@ -401,8 +368,8 @@ __decorate([
|
|
|
401
368
|
], CrudStdService.prototype, "crudStdRelationService", void 0);
|
|
402
369
|
__decorate([
|
|
403
370
|
(0, core_1.Inject)(),
|
|
404
|
-
__metadata("design:type",
|
|
405
|
-
], CrudStdService.prototype, "
|
|
371
|
+
__metadata("design:type", SysAppService_1.SysAppService)
|
|
372
|
+
], CrudStdService.prototype, "sysAppService", void 0);
|
|
406
373
|
CrudStdService = __decorate([
|
|
407
374
|
(0, core_1.Provide)()
|
|
408
375
|
], CrudStdService);
|
|
@@ -17,21 +17,21 @@ export declare class CrudProQuick {
|
|
|
17
17
|
* @deprecated
|
|
18
18
|
* @param reqJson
|
|
19
19
|
* @param sqlTable
|
|
20
|
-
* @returns
|
|
20
|
+
* @returns 返回一条数据对象
|
|
21
21
|
*/
|
|
22
22
|
getOne(reqJson: IRequestModel, sqlTable?: string): Promise<any>;
|
|
23
23
|
/**
|
|
24
24
|
* 期望获取唯一的一个对象,如果数据库中的数量不唯一,则报错。
|
|
25
25
|
* @param reqJson
|
|
26
26
|
* @param sqlTable
|
|
27
|
-
* @returns
|
|
27
|
+
* @returns 返回一条数据对象
|
|
28
28
|
*/
|
|
29
29
|
getUniqueOne(reqJson: IRequestModel, sqlTable?: string): Promise<any>;
|
|
30
30
|
/**
|
|
31
31
|
* 获取数据列表
|
|
32
32
|
* @param reqJson
|
|
33
33
|
* @param sqlTable 数据库表名称
|
|
34
|
-
* @returns
|
|
34
|
+
* @returns 返回多条数据对象组成的数组
|
|
35
35
|
*/
|
|
36
36
|
getList(reqJson: IRequestModel, sqlTable?: string): Promise<any[]>;
|
|
37
37
|
getListPage(reqJson: IRequestModel, sqlTable?: string): Promise<ResModelStandard>;
|
|
@@ -41,4 +41,10 @@ export declare class CrudProQuick {
|
|
|
41
41
|
insertOrUpdate(reqJson: IRequestModel, sqlTable?: string): Promise<ResModelStandard>;
|
|
42
42
|
deleteObject(reqJson: IRequestModel, sqlTable?: string): Promise<ResModelAffected>;
|
|
43
43
|
executeSQL(executeSql: string, args?: any[]): Promise<any>;
|
|
44
|
+
/**
|
|
45
|
+
* 执行数据库的原生SQL语句,不做任何封装的SQL
|
|
46
|
+
* @param executeNativeSql
|
|
47
|
+
* @param args
|
|
48
|
+
*/
|
|
49
|
+
executeNativeSQL(executeNativeSql: string, args?: any[]): Promise<any>;
|
|
44
50
|
}
|
|
@@ -36,7 +36,7 @@ class CrudProQuick {
|
|
|
36
36
|
* @deprecated
|
|
37
37
|
* @param reqJson
|
|
38
38
|
* @param sqlTable
|
|
39
|
-
* @returns
|
|
39
|
+
* @returns 返回一条数据对象
|
|
40
40
|
*/
|
|
41
41
|
async getOne(reqJson, sqlTable) {
|
|
42
42
|
const cfgModel = {
|
|
@@ -50,7 +50,7 @@ class CrudProQuick {
|
|
|
50
50
|
* 期望获取唯一的一个对象,如果数据库中的数量不唯一,则报错。
|
|
51
51
|
* @param reqJson
|
|
52
52
|
* @param sqlTable
|
|
53
|
-
* @returns
|
|
53
|
+
* @returns 返回一条数据对象
|
|
54
54
|
*/
|
|
55
55
|
async getUniqueOne(reqJson, sqlTable) {
|
|
56
56
|
const cfgModel = {
|
|
@@ -75,7 +75,7 @@ class CrudProQuick {
|
|
|
75
75
|
* 获取数据列表
|
|
76
76
|
* @param reqJson
|
|
77
77
|
* @param sqlTable 数据库表名称
|
|
78
|
-
* @returns
|
|
78
|
+
* @returns 返回多条数据对象组成的数组
|
|
79
79
|
*/
|
|
80
80
|
async getList(reqJson, sqlTable) {
|
|
81
81
|
const cfgModel = {
|
|
@@ -143,5 +143,21 @@ class CrudProQuick {
|
|
|
143
143
|
};
|
|
144
144
|
return await this.curdPro.executeSQL(sqlCfgModel);
|
|
145
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* 执行数据库的原生SQL语句,不做任何封装的SQL
|
|
148
|
+
* @param executeNativeSql
|
|
149
|
+
* @param args
|
|
150
|
+
*/
|
|
151
|
+
async executeNativeSQL(executeNativeSql, args) {
|
|
152
|
+
const sqlCfgModel = {
|
|
153
|
+
isNativeSQL: true,
|
|
154
|
+
executeSql: executeNativeSql,
|
|
155
|
+
executeSqlArgs: args,
|
|
156
|
+
sqlDatabase: this.sqlDatabase,
|
|
157
|
+
sqlDbType: this.sqlDbType,
|
|
158
|
+
maxLimit: this.baseCfgModel.maxLimit || DEFAULT_MAX_LIMIT,
|
|
159
|
+
};
|
|
160
|
+
return await this.curdPro.executeSQL(sqlCfgModel);
|
|
161
|
+
}
|
|
146
162
|
}
|
|
147
163
|
exports.CrudProQuick = CrudProQuick;
|