midway-fatcms 0.0.1-beta.1 → 0.0.1-beta.11
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 +52 -15
- package/dist/controller/base/BaseApiController.js +9 -6
- package/dist/controller/gateway/CrudMtdGatewayController.js +4 -1
- package/dist/controller/gateway/DocGatewayController.js +13 -8
- package/dist/controller/gateway/StaticController.d.ts +3 -0
- package/dist/controller/gateway/StaticController.js +41 -21
- package/dist/controller/home.controller.js +2 -2
- package/dist/controller/manage/CrudStandardDesignApi.js +89 -74
- package/dist/controller/manage/DeployManageApi.js +6 -4
- package/dist/controller/manage/SuperAdminManageApi.js +12 -8
- package/dist/controller/manage/SysConfigMangeApi.js +3 -1
- package/dist/controller/manage/UserAccountManageApi.d.ts +1 -1
- package/dist/controller/manage/UserAccountManageApi.js +5 -0
- package/dist/controller/myinfo/AuthController.d.ts +0 -4
- package/dist/controller/myinfo/AuthController.js +0 -53
- package/dist/controller/render/AppRenderController.js +4 -2
- package/dist/controller/test.controller.js +1 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.js +28 -4
- package/dist/libs/crud-pro/interfaces.d.ts +1 -1
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +1 -1
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +1 -1
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +4 -4
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +4 -4
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +8 -8
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +2 -2
- package/dist/libs/global-config/global-config.d.ts +39 -0
- package/dist/libs/global-config/global-config.js +32 -0
- package/dist/models/SystemTables.d.ts +0 -3
- package/dist/models/SystemTables.js +1 -4
- package/dist/service/AuthService.js +8 -5
- package/dist/service/EnumInfoService.js +7 -4
- package/dist/service/FileCenterService.js +13 -9
- package/dist/service/SysConfigService.js +4 -2
- package/dist/service/UserAccountService.js +10 -6
- package/dist/service/VisitStatService.js +4 -2
- package/dist/service/WorkbenchService.js +4 -2
- package/dist/service/anyapi/AnyApiService.js +4 -2
- package/dist/service/crudstd/CrudStdService.js +7 -3
- package/dist/service/curd/CurdMixByAccountService.js +12 -6
- package/dist/service/curd/CurdMixByDictService.js +4 -2
- package/dist/service/curd/CurdMixByLinkToCustomService.js +1 -1
- package/dist/service/curd/CurdMixBySysConfigService.js +4 -2
- package/dist/service/curd/CurdMixByWorkbenchService.js +4 -2
- package/dist/service/curd/CurdMixService.d.ts +1 -1
- package/dist/service/curd/CurdMixService.js +2 -2
- package/dist/service/curd/CurdMixUtils.d.ts +7 -0
- package/dist/service/curd/CurdMixUtils.js +31 -1
- package/dist/service/curd/CurdProService.d.ts +3 -3
- package/dist/service/curd/CurdProService.js +9 -9
- package/dist/service/proxyapi/ProxyApiLoadService.js +7 -4
- package/dist/views/404_app.html +31 -0
- package/dist/views/404_workbench.html +34 -0
- package/dist/views/static/favicon.ico +0 -0
- package/package.json +5 -1
- package/src/config/config.default.ts +58 -27
- package/src/controller/base/BaseApiController.ts +14 -14
- package/src/controller/gateway/CrudMtdGatewayController.ts +6 -2
- package/src/controller/gateway/DocGatewayController.ts +13 -5
- package/src/controller/gateway/StaticController.ts +50 -25
- package/src/controller/home.controller.ts +8 -10
- package/src/controller/manage/CrudStandardDesignApi.ts +145 -100
- package/src/controller/manage/DeployManageApi.ts +6 -3
- package/src/controller/manage/SuperAdminManageApi.ts +15 -6
- package/src/controller/manage/SysConfigMangeApi.ts +4 -1
- package/src/controller/manage/UserAccountManageApi.ts +6 -0
- package/src/controller/myinfo/AuthController.ts +4 -66
- package/src/controller/render/AppRenderController.ts +18 -15
- package/src/controller/test.controller.ts +1 -1
- package/src/index.ts +33 -4
- package/src/libs/crud-pro/interfaces.ts +1 -1
- package/src/libs/crud-pro/models/RequestCfgModel.ts +1 -1
- package/src/libs/crud-pro/models/SqlCfgModel.ts +1 -1
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +4 -4
- package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +4 -4
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +8 -8
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +2 -2
- package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +2 -2
- package/src/libs/global-config/global-config.ts +72 -0
- package/src/models/SystemTables.ts +0 -4
- package/src/service/AuthService.ts +13 -8
- package/src/service/EnumInfoService.ts +8 -3
- package/src/service/FileCenterService.ts +12 -6
- package/src/service/SysConfigService.ts +10 -6
- package/src/service/UserAccountService.ts +14 -4
- package/src/service/VisitStatService.ts +6 -2
- package/src/service/WorkbenchService.ts +7 -2
- package/src/service/anyapi/AnyApiService.ts +5 -2
- package/src/service/crudstd/CrudStdService.ts +13 -3
- package/src/service/curd/CurdMixByAccountService.ts +14 -6
- package/src/service/curd/CurdMixByDictService.ts +8 -2
- package/src/service/curd/CurdMixByLinkToCustomService.ts +1 -1
- package/src/service/curd/CurdMixBySysConfigService.ts +7 -2
- package/src/service/curd/CurdMixByWorkbenchService.ts +6 -2
- package/src/service/curd/CurdMixService.ts +2 -2
- package/src/service/curd/CurdMixUtils.ts +42 -12
- package/src/service/curd/CurdProService.ts +10 -10
- package/src/service/proxyapi/ProxyApiLoadService.ts +11 -3
- package/src/views/404_app.html +31 -0
- package/src/views/404_workbench.html +34 -0
- package/src/views/static/favicon.ico +0 -0
- package/dist/controller/medstatistic/MedAdminController.d.ts +0 -35
- package/dist/controller/medstatistic/MedAdminController.js +0 -205
- package/dist/controller/medstatistic/MedClientController.d.ts +0 -28
- package/dist/controller/medstatistic/MedClientController.js +0 -188
- package/dist/controller/medstatistic/MedMessageService.d.ts +0 -19
- package/dist/controller/medstatistic/MedMessageService.js +0 -95
- package/dist/controller/medstatistic/MedScoreService.d.ts +0 -21
- package/dist/controller/medstatistic/MedScoreService.js +0 -107
- package/dist/controller/medstatistic/constants.d.ts +0 -32
- package/dist/controller/medstatistic/constants.js +0 -43
- package/src/controller/medstatistic/MedAdminController.ts +0 -221
- package/src/controller/medstatistic/MedClientController.ts +0 -188
- package/src/controller/medstatistic/MedMessageService.ts +0 -89
- package/src/controller/medstatistic/MedScoreService.ts +0 -108
- package/src/controller/medstatistic/constants.ts +0 -63
|
@@ -6,8 +6,9 @@ import { CurdMixService } from './curd/CurdMixService';
|
|
|
6
6
|
import { createUniqueId } from '../libs/utils/functions';
|
|
7
7
|
import { CommonException, Exceptions } from '../libs/crud-pro/exceptions';
|
|
8
8
|
import { IRequestCfgModel, IRequestModel } from '../libs/crud-pro/interfaces';
|
|
9
|
-
import {
|
|
9
|
+
import {SystemTables} from '../models/SystemTables';
|
|
10
10
|
import { CommonResult } from '../libs/utils/common-dto';
|
|
11
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
11
12
|
|
|
12
13
|
@Provide()
|
|
13
14
|
export class UserAccountService {
|
|
@@ -21,6 +22,9 @@ export class UserAccountService {
|
|
|
21
22
|
* @param loginName
|
|
22
23
|
*/
|
|
23
24
|
public async queryUserAccountByLoginName(loginName: string) {
|
|
25
|
+
|
|
26
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
27
|
+
|
|
24
28
|
const query = await this.curdMixService.executeCrudByCfg(
|
|
25
29
|
{
|
|
26
30
|
condition: { login_name: loginName },
|
|
@@ -30,7 +34,7 @@ export class UserAccountService {
|
|
|
30
34
|
sqlTable: SystemTables.sys_user_account,
|
|
31
35
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
32
36
|
sqlDatabase: SystemDbName,
|
|
33
|
-
|
|
37
|
+
sqlDbType: SystemDbType,
|
|
34
38
|
}
|
|
35
39
|
);
|
|
36
40
|
const { row } = query.getResModel();
|
|
@@ -47,6 +51,9 @@ export class UserAccountService {
|
|
|
47
51
|
return [];
|
|
48
52
|
}
|
|
49
53
|
|
|
54
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
55
|
+
|
|
56
|
+
|
|
50
57
|
const accountIds = accountIdList.map(userId => {
|
|
51
58
|
return `${userId}`;
|
|
52
59
|
});
|
|
@@ -56,7 +63,7 @@ export class UserAccountService {
|
|
|
56
63
|
sqlTable: SystemTables.sys_user_account,
|
|
57
64
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
58
65
|
sqlDatabase: SystemDbName,
|
|
59
|
-
|
|
66
|
+
sqlDbType: SystemDbType,
|
|
60
67
|
};
|
|
61
68
|
|
|
62
69
|
const reqJson: IRequestModel = {
|
|
@@ -81,6 +88,9 @@ export class UserAccountService {
|
|
|
81
88
|
if (!loginName) {
|
|
82
89
|
throw new CommonException(Exceptions.OTHER_EXCEPTION, 'loginName不存在');
|
|
83
90
|
}
|
|
91
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
92
|
+
|
|
93
|
+
|
|
84
94
|
const pwd_salt = createUniqueId();
|
|
85
95
|
const pwd_md5 = md5(unsaltedPwd + pwd_salt);
|
|
86
96
|
const res1 = await this.curdMixService.executeCrudByCfg(
|
|
@@ -92,7 +102,7 @@ export class UserAccountService {
|
|
|
92
102
|
sqlTable: SystemTables.sys_user_account,
|
|
93
103
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
94
104
|
sqlDatabase: SystemDbName,
|
|
95
|
-
|
|
105
|
+
sqlDbType: SystemDbType,
|
|
96
106
|
}
|
|
97
107
|
);
|
|
98
108
|
return CommonResult.successRes(res1.getResModel());
|
|
@@ -3,10 +3,11 @@ import {Context} from '@midwayjs/koa';
|
|
|
3
3
|
import {IScheduleService} from '../interface';
|
|
4
4
|
import {BaseService} from "./base/BaseService";
|
|
5
5
|
import {CurdProService} from "./curd/CurdProService";
|
|
6
|
-
import {
|
|
6
|
+
import { SystemTables} from "../models/SystemTables";
|
|
7
7
|
import {KeysOfSimpleSQL} from "../libs/crud-pro/models/keys";
|
|
8
8
|
import {FILE_GET_TYPES} from "../models/bizmodels";
|
|
9
9
|
import {CommonResult} from "../libs/utils/common-dto";
|
|
10
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
// 3天 的秒数
|
|
@@ -35,6 +36,9 @@ export class VisitStatService extends BaseService implements IScheduleService {
|
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
async flushVisitStatToDB(): Promise<any> {
|
|
39
|
+
|
|
40
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
41
|
+
|
|
38
42
|
// 统计昨天的数据。
|
|
39
43
|
const stat_date = new Date(Date.now() - 24 * 3600 * 1000).toISOString().split('T')[0];
|
|
40
44
|
|
|
@@ -86,7 +90,7 @@ export class VisitStatService extends BaseService implements IScheduleService {
|
|
|
86
90
|
}, {
|
|
87
91
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
|
|
88
92
|
sqlDatabase: SystemDbName,
|
|
89
|
-
|
|
93
|
+
sqlDbType: SystemDbType,
|
|
90
94
|
sqlTable: SystemTables.sys_visit_stats,
|
|
91
95
|
})
|
|
92
96
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Inject, Provide } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { KeysOfSimpleSQL } from '../libs/crud-pro/models/keys';
|
|
4
|
-
import {
|
|
4
|
+
import { SystemTables} from '../models/SystemTables';
|
|
5
5
|
import { BaseService } from './base/BaseService';
|
|
6
6
|
// import { LRUCache } from 'lru-cache';
|
|
7
7
|
import { CurdProService } from './curd/CurdProService';
|
|
@@ -11,6 +11,7 @@ import { IWorkbenchEntity } from '../models/SystemEntities';
|
|
|
11
11
|
import { IScheduleService } from '../interface';
|
|
12
12
|
import { getDebugWorkbenchCode } from '../libs/utils/fatcms-request';
|
|
13
13
|
import { MixinUtils } from '../libs/crud-pro/utils/MixinUtils';
|
|
14
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
14
15
|
//
|
|
15
16
|
// const lruCache = new LRUCache<string, any>({
|
|
16
17
|
// max: 500,
|
|
@@ -42,6 +43,10 @@ export class WorkbenchService extends BaseService implements IScheduleService {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
public async getAllWorkbenchInfoList(isForceRefresh?: boolean): Promise<IWorkbenchEntity[]> {
|
|
46
|
+
|
|
47
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
48
|
+
|
|
49
|
+
|
|
45
50
|
let listData = lruCache.get(CACHE_KEY_WORKBENCH_LIST);
|
|
46
51
|
if (!listData || isForceRefresh === true) {
|
|
47
52
|
const reqJson = { condition: {}, pageSize: 1000, limit: 1000 };
|
|
@@ -49,7 +54,7 @@ export class WorkbenchService extends BaseService implements IScheduleService {
|
|
|
49
54
|
sqlTable: SystemTables.sys_workbench,
|
|
50
55
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
51
56
|
sqlDatabase: SystemDbName,
|
|
52
|
-
|
|
57
|
+
sqlDbType: SystemDbType,
|
|
53
58
|
});
|
|
54
59
|
listData = res.getResRows();
|
|
55
60
|
lruCache.set(CACHE_KEY_WORKBENCH_LIST, listData);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Inject, Provide } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
4
|
-
import {
|
|
4
|
+
import { SystemTables} from '../../models/SystemTables';
|
|
5
5
|
import { LRUCache } from 'lru-cache';
|
|
6
6
|
import { BizException } from '../../models/devops';
|
|
7
7
|
import { CurdMixService } from '../curd/CurdMixService';
|
|
@@ -13,6 +13,7 @@ import { MixinUtils } from '../../libs/crud-pro/utils/MixinUtils';
|
|
|
13
13
|
import { WorkbenchService } from '../WorkbenchService';
|
|
14
14
|
import { validateByCfgString } from '../../libs/crud-pro/utils/ValidateUtils';
|
|
15
15
|
import { API_BASE_TYPE, ApiBaseService } from '../base/ApiBaseService';
|
|
16
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
16
17
|
|
|
17
18
|
const lruCache = new LRUCache<string, any>({
|
|
18
19
|
max: 500,
|
|
@@ -80,6 +81,8 @@ export class AnyApiService extends ApiBaseService {
|
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
private async _getAnyApiMethod(methodCode: string): Promise<ISysAnyApiEntity> {
|
|
84
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
85
|
+
|
|
83
86
|
const res = await this.curdMixService.executeCrudByCfg(
|
|
84
87
|
{ condition: { method: methodCode } },
|
|
85
88
|
{
|
|
@@ -87,7 +90,7 @@ export class AnyApiService extends ApiBaseService {
|
|
|
87
90
|
method: `get_sys_anyapi_${methodCode}`,
|
|
88
91
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
89
92
|
sqlDatabase: SystemDbName,
|
|
90
|
-
|
|
93
|
+
sqlDbType: SystemDbType,
|
|
91
94
|
updateCfg: {},
|
|
92
95
|
}
|
|
93
96
|
);
|
|
@@ -7,12 +7,13 @@ import { parseJsonObject } from '../../libs/utils/functions';
|
|
|
7
7
|
import { ICrudStdAppInfo, ICrudStdAppInfoForSettingKey } from '../../models/bizmodels';
|
|
8
8
|
import { BizException } from '../../models/devops';
|
|
9
9
|
import { ExecuteContext } from '../../libs/crud-pro/models/ExecuteContext';
|
|
10
|
-
import {
|
|
10
|
+
import { SystemTables} from '../../models/SystemTables';
|
|
11
11
|
import { CrudStdActionService } from './CrudStdActionService';
|
|
12
12
|
import { CrudStdRelationService } from './CrudStdRelationService';
|
|
13
13
|
import * as _ from 'lodash';
|
|
14
14
|
import { ApiBaseService } from '../base/ApiBaseService';
|
|
15
15
|
import {parseDatabaseName} from "../../libs/crud-pro/utils/DatabaseName";
|
|
16
|
+
import { GLOBAL_STATIC_CONFIG } from '../../libs/global-config/global-config';
|
|
16
17
|
|
|
17
18
|
export const SPECIAL_SETTING_KEY = {
|
|
18
19
|
QUERY_LIST: 'QUERY_LIST',
|
|
@@ -50,7 +51,7 @@ export class CrudStdService extends ApiBaseService {
|
|
|
50
51
|
|
|
51
52
|
const cfgModel: IRequestCfgModel = {
|
|
52
53
|
sqlDatabase: dbName,
|
|
53
|
-
|
|
54
|
+
sqlDbType: dbType,
|
|
54
55
|
sqlTable: stdCrudCfgObj.tableBaseInfo.tableName,
|
|
55
56
|
sqlSimpleName,
|
|
56
57
|
};
|
|
@@ -67,6 +68,10 @@ export class CrudStdService extends ApiBaseService {
|
|
|
67
68
|
|
|
68
69
|
// 根据用户配置,设置关联查询的数据信息。
|
|
69
70
|
await this.crudStdRelationService.addCfgModelColumnsRelation(cfgModel, appInfo);
|
|
71
|
+
|
|
72
|
+
// 业务系统自定义的修改cfgModel
|
|
73
|
+
await GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudStd(params, cfgModel, appInfo, this.ctx);
|
|
74
|
+
|
|
70
75
|
return await this.curdMixService.executeCrudByCfg(params, cfgModel);
|
|
71
76
|
}
|
|
72
77
|
|
|
@@ -133,13 +138,18 @@ export class CrudStdService extends ApiBaseService {
|
|
|
133
138
|
* @private
|
|
134
139
|
*/
|
|
135
140
|
private async getCrudStdAppInfo(appCode?: string) {
|
|
141
|
+
|
|
142
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
136
146
|
this.logInfo('getCrudStdAppInfo', appCode);
|
|
137
147
|
|
|
138
148
|
const ss = {
|
|
139
149
|
sqlTable: SystemTables.sys_app,
|
|
140
150
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
141
151
|
sqlDatabase: SystemDbName,
|
|
142
|
-
|
|
152
|
+
sqlDbType: SystemDbType,
|
|
143
153
|
};
|
|
144
154
|
return await this.curdMixService.executeCrudByCfg({ condition: { app_code: appCode } }, ss);
|
|
145
155
|
}
|
|
@@ -4,10 +4,11 @@ import * as _ from 'lodash';
|
|
|
4
4
|
import { CurdProService } from './CurdProService';
|
|
5
5
|
import { ExecuteContext, IExecuteContextHandler } from '../../libs/crud-pro/models/ExecuteContext';
|
|
6
6
|
import { CrudMixUtils, RelatedType } from './CurdMixUtils';
|
|
7
|
-
import {
|
|
7
|
+
import { SystemTables } from '../../models/SystemTables';
|
|
8
8
|
import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
9
9
|
import { ColumnRelation, IRequestCfgModel, IRequestModel } from '../../libs/crud-pro/interfaces';
|
|
10
10
|
import { MixinUtils } from '../../libs/crud-pro/utils/MixinUtils';
|
|
11
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
11
12
|
|
|
12
13
|
const dictMixUtils = new CrudMixUtils(RelatedType.accountBasic);
|
|
13
14
|
|
|
@@ -22,6 +23,8 @@ export class CurdMixByAccountService implements IExecuteContextHandler {
|
|
|
22
23
|
protected curdProService: CurdProService;
|
|
23
24
|
|
|
24
25
|
async handleExecuteContextPrepare(executeContext: ExecuteContext) {
|
|
26
|
+
const { SystemDbName, SystemDbType, toFatcmsUserAccountId } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
27
|
+
|
|
25
28
|
const relations = dictMixUtils.pickColumnRelations(executeContext);
|
|
26
29
|
if (!relations || relations.length === 0) {
|
|
27
30
|
return;
|
|
@@ -30,10 +33,15 @@ export class CurdMixByAccountService implements IExecuteContextHandler {
|
|
|
30
33
|
const accountIds = new Set<string>();
|
|
31
34
|
dictMixUtils.forEachRowAndColumnsRelation(executeContext, (row: any, columnRelation: ColumnRelation) => {
|
|
32
35
|
const { sourceColumn } = columnRelation;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
if (sourceColumn) {
|
|
37
|
+
const accountId = _.get(row, sourceColumn);
|
|
38
|
+
if (accountId) {
|
|
39
|
+
const fatcmsUserAccountId = toFatcmsUserAccountId(accountId);
|
|
40
|
+
accountIds.add(fatcmsUserAccountId);
|
|
41
|
+
row['__fatcmsUserAccountId__'] = fatcmsUserAccountId;
|
|
42
|
+
}
|
|
36
43
|
}
|
|
44
|
+
|
|
37
45
|
});
|
|
38
46
|
|
|
39
47
|
if (accountIds.size === 0) {
|
|
@@ -45,7 +53,7 @@ export class CurdMixByAccountService implements IExecuteContextHandler {
|
|
|
45
53
|
sqlTable: SystemTables.sys_user_account,
|
|
46
54
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
47
55
|
sqlDatabase: SystemDbName,
|
|
48
|
-
|
|
56
|
+
sqlDbType: SystemDbType,
|
|
49
57
|
};
|
|
50
58
|
|
|
51
59
|
const reqJson: IRequestModel = {
|
|
@@ -77,7 +85,7 @@ export class CurdMixByAccountService implements IExecuteContextHandler {
|
|
|
77
85
|
{ from: 'avatar', to: `${sourceColumn}_user.avatar` },
|
|
78
86
|
];
|
|
79
87
|
}
|
|
80
|
-
dictMixUtils.
|
|
88
|
+
dictMixUtils.copyUserInfoToRowNoRelatedCode(row, userInfoMap, columnRelation);
|
|
81
89
|
});
|
|
82
90
|
}
|
|
83
91
|
}
|
|
@@ -3,12 +3,13 @@ import { Context } from '@midwayjs/koa';
|
|
|
3
3
|
import { CurdProService } from './CurdProService';
|
|
4
4
|
import { ExecuteContext, IExecuteContextHandler } from '../../libs/crud-pro/models/ExecuteContext';
|
|
5
5
|
import { CrudMixUtils, RelatedType } from './CurdMixUtils';
|
|
6
|
-
import {
|
|
6
|
+
import { SystemTables} from '../../models/SystemTables';
|
|
7
7
|
import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
8
8
|
import { MultiKeyMap } from '../../libs/crud-pro/utils/MultiKeyMap';
|
|
9
9
|
import { ColumnRelation } from '../../libs/crud-pro/interfaces';
|
|
10
10
|
import * as _ from 'lodash';
|
|
11
11
|
import {RedisCacheService} from "../base/RedisCacheService";
|
|
12
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
12
13
|
|
|
13
14
|
const TMP_CTX_KEY = _.uniqueId('CurdMixByDictService');
|
|
14
15
|
|
|
@@ -46,6 +47,11 @@ export class CurdMixByDictService implements IExecuteContextHandler {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
private async getDictItemRows(codes: string[]) {
|
|
50
|
+
|
|
51
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
49
55
|
const noCacheCodes: string[] = [];
|
|
50
56
|
|
|
51
57
|
// 从缓存里面取
|
|
@@ -72,7 +78,7 @@ export class CurdMixByDictService implements IExecuteContextHandler {
|
|
|
72
78
|
sqlTable: SystemTables.sys_data_dict_item,
|
|
73
79
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
74
80
|
sqlDatabase: SystemDbName,
|
|
75
|
-
|
|
81
|
+
sqlDbType: SystemDbType,
|
|
76
82
|
}
|
|
77
83
|
);
|
|
78
84
|
selectedRows = res1.getResRows();
|
|
@@ -4,11 +4,12 @@ import { CurdProService } from './CurdProService';
|
|
|
4
4
|
import { ExecuteContext, IExecuteContextHandler } from '../../libs/crud-pro/models/ExecuteContext';
|
|
5
5
|
import { CrudMixUtils, RelatedType } from './CurdMixUtils';
|
|
6
6
|
import * as _ from 'lodash';
|
|
7
|
-
import {
|
|
7
|
+
import { SystemTables} from '../../models/SystemTables';
|
|
8
8
|
import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
9
9
|
import { MultiKeyMap } from '../../libs/crud-pro/utils/MultiKeyMap';
|
|
10
10
|
import { ColumnRelation } from '../../libs/crud-pro/interfaces';
|
|
11
11
|
import { parseConfigContentToEnumInfo } from "../../libs/utils/parseConfig";
|
|
12
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
12
13
|
|
|
13
14
|
const dictMixUtils = new CrudMixUtils(RelatedType.sysCfgEnum);
|
|
14
15
|
|
|
@@ -25,6 +26,10 @@ export class CurdMixBySysConfigService implements IExecuteContextHandler {
|
|
|
25
26
|
protected curdProService: CurdProService;
|
|
26
27
|
|
|
27
28
|
async handleExecuteContextPrepare(executeContext: ExecuteContext) {
|
|
29
|
+
|
|
30
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
31
|
+
|
|
32
|
+
|
|
28
33
|
const codes = dictMixUtils.pickColumnRelationCodes(executeContext);
|
|
29
34
|
if (!codes || codes.length === 0) {
|
|
30
35
|
return;
|
|
@@ -38,7 +43,7 @@ export class CurdMixBySysConfigService implements IExecuteContextHandler {
|
|
|
38
43
|
sqlTable: SystemTables.sys_configs,
|
|
39
44
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
40
45
|
sqlDatabase: SystemDbName,
|
|
41
|
-
|
|
46
|
+
sqlDbType: SystemDbType,
|
|
42
47
|
}
|
|
43
48
|
);
|
|
44
49
|
const rows = res1.getResRows();
|
|
@@ -5,10 +5,11 @@ import { LRUCache } from 'lru-cache';
|
|
|
5
5
|
import { CurdProService } from './CurdProService';
|
|
6
6
|
import { ExecuteContext, IExecuteContextHandler } from '../../libs/crud-pro/models/ExecuteContext';
|
|
7
7
|
import { CrudMixUtils, RelatedType } from './CurdMixUtils';
|
|
8
|
-
import {
|
|
8
|
+
import { SystemTables } from '../../models/SystemTables';
|
|
9
9
|
import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
10
10
|
import { ColumnRelation } from '../../libs/crud-pro/interfaces';
|
|
11
11
|
import { MixinUtils } from '../../libs/crud-pro/utils/MixinUtils';
|
|
12
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
12
13
|
|
|
13
14
|
const lruCache = new LRUCache<string, any>({
|
|
14
15
|
max: 500,
|
|
@@ -29,6 +30,9 @@ export class CurdMixByWorkbenchService implements IExecuteContextHandler {
|
|
|
29
30
|
protected curdProService: CurdProService;
|
|
30
31
|
|
|
31
32
|
private async loadWorkbenchListMap() {
|
|
33
|
+
|
|
34
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
35
|
+
|
|
32
36
|
let workbenchListMap = lruCache.get('workbenchListMap');
|
|
33
37
|
if (!workbenchListMap) {
|
|
34
38
|
const reqJson = {
|
|
@@ -39,7 +43,7 @@ export class CurdMixByWorkbenchService implements IExecuteContextHandler {
|
|
|
39
43
|
sqlTable: SystemTables.sys_workbench,
|
|
40
44
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
41
45
|
sqlDatabase: SystemDbName,
|
|
42
|
-
|
|
46
|
+
sqlDbType: SystemDbType,
|
|
43
47
|
});
|
|
44
48
|
const workbenchList = res.getResRows();
|
|
45
49
|
workbenchListMap = MixinUtils.toNewMap(workbenchList, (obj: any) => obj.workbench_code);
|
|
@@ -44,9 +44,9 @@ export class CurdMixService {
|
|
|
44
44
|
return this.curdProService.executeCrudByCfg(reqJson, cfgModel);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
getBbUtil(database: string,
|
|
47
|
+
getBbUtil(database: string, sqlDbType: SqlDbType) {
|
|
48
48
|
this.prepare();
|
|
49
|
-
return this.curdProService.getBbUtil(database,
|
|
49
|
+
return this.curdProService.getBbUtil(database, sqlDbType);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
async executeSQL(sqlCfgModel: ISqlCfgModel) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ColumnRelation, CopyAttr} from '../../libs/crud-pro/interfaces';
|
|
1
|
+
import { ColumnRelation, CopyAttr } from '../../libs/crud-pro/interfaces';
|
|
2
2
|
import { ExecuteContext } from '../../libs/crud-pro/models/ExecuteContext';
|
|
3
3
|
import { KeyOfCrudTypes } from '../../libs/crud-pro/models/keys';
|
|
4
4
|
import { MixinUtils } from '../../libs/crud-pro/utils/MixinUtils';
|
|
@@ -33,7 +33,7 @@ function getColumnsRelationAll(sqlCfg: SqlCfgModel, cfgModel: RequestCfgModel):
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
function copyBySingleSourceValue(row: any, sourceValue:any, targetColumns: CopyAttr[], getValue: any
|
|
36
|
+
function copyBySingleSourceValue(row: any, sourceValue: any, targetColumns: CopyAttr[], getValue: any) {
|
|
37
37
|
// const codeObject = map.get(sourceValue);
|
|
38
38
|
const codeObject = getValue(sourceValue);
|
|
39
39
|
if (typeof codeObject === 'undefined' || codeObject === null) {
|
|
@@ -59,7 +59,7 @@ function copyBySingleSourceValue(row: any, sourceValue:any, targetColumns: CopyA
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
function copyByArraySourceValue(row: any, sourceValue:any, targetColumns: CopyAttr[], getValue: any
|
|
62
|
+
function copyByArraySourceValue(row: any, sourceValue: any, targetColumns: CopyAttr[], getValue: any): boolean {
|
|
63
63
|
let isSetArray = false;
|
|
64
64
|
// 支持关联JSON数组
|
|
65
65
|
if (typeof sourceValue === 'string' && sourceValue.startsWith('[') && sourceValue.endsWith(']')) {
|
|
@@ -80,15 +80,12 @@ function copyByArraySourceValue(row: any, sourceValue:any, targetColumns: CopyAt
|
|
|
80
80
|
_.set(row, toStr, codeObject);
|
|
81
81
|
|
|
82
82
|
isSetArray = true;
|
|
83
|
-
|
|
84
83
|
} else {
|
|
85
|
-
|
|
86
84
|
const dictAttrValue = _.get(codeObject, targetColumn.from);
|
|
87
|
-
if (typeof dictAttrValue !==
|
|
85
|
+
if (typeof dictAttrValue !== 'undefined' && dictAttrValue !== null) {
|
|
88
86
|
const toStr = targetColumn.to.replace('$ARRAY_INDEX', `${codeIndex}`);
|
|
89
87
|
_.set(row, toStr, dictAttrValue);
|
|
90
88
|
isSetArray = true;
|
|
91
|
-
|
|
92
89
|
}
|
|
93
90
|
}
|
|
94
91
|
}
|
|
@@ -101,8 +98,6 @@ function copyByArraySourceValue(row: any, sourceValue:any, targetColumns: CopyAt
|
|
|
101
98
|
return isSetArray;
|
|
102
99
|
}
|
|
103
100
|
|
|
104
|
-
|
|
105
|
-
|
|
106
101
|
class CrudMixUtils {
|
|
107
102
|
private readonly relatedType: RelatedType;
|
|
108
103
|
constructor(relatedType: RelatedType) {
|
|
@@ -134,7 +129,7 @@ class CrudMixUtils {
|
|
|
134
129
|
}
|
|
135
130
|
}
|
|
136
131
|
}
|
|
137
|
-
return _.uniqBy(relationResult,(obj: ColumnRelation)=> {
|
|
132
|
+
return _.uniqBy(relationResult, (obj: ColumnRelation) => {
|
|
138
133
|
return `${obj.relatedCode}_${obj.relatedType}_${obj.sourceColumn}_${JSON.stringify(obj.targetColumns)}`;
|
|
139
134
|
});
|
|
140
135
|
}
|
|
@@ -191,7 +186,7 @@ class CrudMixUtils {
|
|
|
191
186
|
}
|
|
192
187
|
|
|
193
188
|
const sourceValue = _.get(row, sourceColumn);
|
|
194
|
-
if (typeof sourceValue ==='undefined' || sourceValue ===null) {
|
|
189
|
+
if (typeof sourceValue === 'undefined' || sourceValue === null) {
|
|
195
190
|
return;
|
|
196
191
|
}
|
|
197
192
|
|
|
@@ -216,7 +211,7 @@ class CrudMixUtils {
|
|
|
216
211
|
* @param columnRelation
|
|
217
212
|
*/
|
|
218
213
|
public copyColumnRelationToRowNoRelatedCode(row: any, map: Map<string, any>, columnRelation: ColumnRelation) {
|
|
219
|
-
const {sourceColumn, targetColumns} = columnRelation;
|
|
214
|
+
const { sourceColumn, targetColumns } = columnRelation;
|
|
220
215
|
if (!sourceColumn || !targetColumns) {
|
|
221
216
|
return;
|
|
222
217
|
}
|
|
@@ -243,6 +238,41 @@ class CrudMixUtils {
|
|
|
243
238
|
|
|
244
239
|
}
|
|
245
240
|
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* 专门COPY用户信息到row上面。无relatedCode模式
|
|
244
|
+
* @param row
|
|
245
|
+
* @param map
|
|
246
|
+
* @param columnRelation
|
|
247
|
+
*/
|
|
248
|
+
public copyUserInfoToRowNoRelatedCode(row: any, map: Map<string, any>, columnRelation: ColumnRelation) {
|
|
249
|
+
const { targetColumns } = columnRelation;
|
|
250
|
+
if (!targetColumns) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const tmpSourceColumn = '__fatcmsUserAccountId__';
|
|
255
|
+
|
|
256
|
+
const sourceValue = _.get(row, tmpSourceColumn);
|
|
257
|
+
if (!sourceValue) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const getValue = (code: string) => {
|
|
262
|
+
if (!map) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
if (typeof map.get === 'function') {
|
|
266
|
+
return map.get(`${code}`);
|
|
267
|
+
}
|
|
268
|
+
return map[code];
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const isSetArray = copyByArraySourceValue(row, sourceValue, targetColumns, getValue);
|
|
272
|
+
if (!isSetArray) {
|
|
273
|
+
copyBySingleSourceValue(row, sourceValue, targetColumns, getValue);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
246
276
|
}
|
|
247
277
|
|
|
248
278
|
export { CrudMixUtils, RelatedType, FuncRowColumnRelation };
|
|
@@ -82,9 +82,9 @@ class MyContextFunc extends BaseExecuteContextFunc {
|
|
|
82
82
|
throw new CommonException(Exceptions.DB_QUERY_PARAM_EMPTY, '查询语句中未指定数据库');
|
|
83
83
|
}
|
|
84
84
|
const dataBaseName = sqlCfgModel.sqlDatabase;
|
|
85
|
-
const
|
|
85
|
+
const sqlDbType = sqlCfgModel.sqlDbType;
|
|
86
86
|
|
|
87
|
-
if (
|
|
87
|
+
if (sqlDbType === SqlDbType.postgres) {
|
|
88
88
|
const dbConfig = _.get(this.postgres2Config, dataBaseName);
|
|
89
89
|
if (!dbConfig) {
|
|
90
90
|
throw new CommonException(Exceptions.DB_NOT_FOUND, 'postgres配置中不存在此数据库:' + dataBaseName);
|
|
@@ -92,7 +92,7 @@ class MyContextFunc extends BaseExecuteContextFunc {
|
|
|
92
92
|
return getPostgresConnectionPool(dataBaseName, dbConfig);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
if (
|
|
95
|
+
if (sqlDbType === SqlDbType.sqlserver) {
|
|
96
96
|
const dbConfig = _.get(this.sqlserver2Config, dataBaseName);
|
|
97
97
|
if (!dbConfig) {
|
|
98
98
|
throw new CommonException(Exceptions.DB_NOT_FOUND, 'sqlserver配置中不存在此数据库:' + dataBaseName);
|
|
@@ -122,12 +122,12 @@ class MyContextFunc extends BaseExecuteContextFunc {
|
|
|
122
122
|
|
|
123
123
|
export class DBUtils {
|
|
124
124
|
private readonly sqlDatabase: string;
|
|
125
|
-
private readonly
|
|
125
|
+
private readonly sqlDbType: SqlDbType;
|
|
126
126
|
private readonly curdProService: CurdProService;
|
|
127
127
|
|
|
128
|
-
constructor(sqlDatabase: string,
|
|
128
|
+
constructor(sqlDatabase: string, sqlDbType: SqlDbType, curdProService: CurdProService) {
|
|
129
129
|
this.sqlDatabase = sqlDatabase;
|
|
130
|
-
this.
|
|
130
|
+
this.sqlDbType = sqlDbType;
|
|
131
131
|
this.curdProService = curdProService;
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -136,7 +136,7 @@ export class DBUtils {
|
|
|
136
136
|
sqlTable,
|
|
137
137
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
138
138
|
sqlDatabase: this.sqlDatabase,
|
|
139
|
-
|
|
139
|
+
sqlDbType: this.sqlDbType,
|
|
140
140
|
updateCfg: {},
|
|
141
141
|
};
|
|
142
142
|
const res = await this.curdProService.executeCrudByCfg(reqJson, cfgModel);
|
|
@@ -148,7 +148,7 @@ export class DBUtils {
|
|
|
148
148
|
sqlTable,
|
|
149
149
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
150
150
|
sqlDatabase: this.sqlDatabase,
|
|
151
|
-
|
|
151
|
+
sqlDbType: this.sqlDbType,
|
|
152
152
|
updateCfg: {},
|
|
153
153
|
};
|
|
154
154
|
const res = await this.curdProService.executeCrudByCfg(reqJson, cfgModel);
|
|
@@ -367,8 +367,8 @@ export class CurdProService extends BaseService {
|
|
|
367
367
|
|
|
368
368
|
|
|
369
369
|
|
|
370
|
-
getBbUtil(database: string,
|
|
371
|
-
return new DBUtils(database,
|
|
370
|
+
getBbUtil(database: string, sqlDbType: SqlDbType): DBUtils {
|
|
371
|
+
return new DBUtils(database, sqlDbType, this);
|
|
372
372
|
}
|
|
373
373
|
|
|
374
374
|
public async getCachedCfgByMethod(method: string): Promise<IRequestCfgModel> {
|
|
@@ -5,7 +5,7 @@ import { BaseService } from '../base/BaseService';
|
|
|
5
5
|
import { getRouteTrie, RouteTrie } from './RouteTrie';
|
|
6
6
|
import { RouteHandler } from './RouteHandler';
|
|
7
7
|
import { CurdProService } from '../curd/CurdProService';
|
|
8
|
-
import {
|
|
8
|
+
import { SystemTables} from '../../models/SystemTables';
|
|
9
9
|
import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
10
10
|
import { IProxyApiEntity, IUpstreamInfo } from '../../models/SystemEntities';
|
|
11
11
|
import { parseJsonObject } from '../../libs/utils/functions';
|
|
@@ -15,6 +15,7 @@ import { WeightedRoundRobin } from './WeightedRoundRobin';
|
|
|
15
15
|
import { IScheduleService } from '../../interface';
|
|
16
16
|
import { WorkbenchService } from '../WorkbenchService';
|
|
17
17
|
import { CommonException } from '../../libs/crud-pro/exceptions';
|
|
18
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
18
19
|
|
|
19
20
|
function toUpstreamInfo(config_content: any): IUpstreamInfo {
|
|
20
21
|
const obj = parseJsonObject(config_content);
|
|
@@ -85,6 +86,9 @@ export class ProxyApiLoadService extends BaseService implements IScheduleService
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
private async buildUpstreamMap() {
|
|
89
|
+
|
|
90
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
91
|
+
|
|
88
92
|
// biz_tag={'upstream'}
|
|
89
93
|
const res = await this.curdProService.executeCrudByCfg(
|
|
90
94
|
{
|
|
@@ -95,7 +99,7 @@ export class ProxyApiLoadService extends BaseService implements IScheduleService
|
|
|
95
99
|
{
|
|
96
100
|
sqlTable: SystemTables.sys_configs,
|
|
97
101
|
sqlDatabase: SystemDbName,
|
|
98
|
-
|
|
102
|
+
sqlDbType: SystemDbType,
|
|
99
103
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
100
104
|
}
|
|
101
105
|
);
|
|
@@ -110,6 +114,10 @@ export class ProxyApiLoadService extends BaseService implements IScheduleService
|
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
private async loadProxyApiEntity(workbench_code: string, upstreamMap: Record<string, IUpstreamInfo>): Promise<IProxyApiEntity[]> {
|
|
117
|
+
|
|
118
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
119
|
+
|
|
120
|
+
|
|
113
121
|
const res = await this.curdProService.executeCrudByCfg(
|
|
114
122
|
{
|
|
115
123
|
condition: {},
|
|
@@ -117,7 +125,7 @@ export class ProxyApiLoadService extends BaseService implements IScheduleService
|
|
|
117
125
|
{
|
|
118
126
|
sqlTable: SystemTables.sys_proxyapi,
|
|
119
127
|
sqlDatabase: SystemDbName,
|
|
120
|
-
|
|
128
|
+
sqlDbType: SystemDbType,
|
|
121
129
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
122
130
|
}
|
|
123
131
|
);
|