midway-fatcms 0.0.1-beta.26 → 0.0.1-beta.29
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 +6 -4
- package/dist/controller/home.controller.js +2 -1
- package/dist/controller/manage/CrudStandardDesignApi.js +8 -8
- package/dist/controller/render/AppRenderController.js +2 -1
- package/dist/middleware/global.middleware.js +22 -9
- package/dist/models/AsyncTaskModel.d.ts +2 -0
- package/dist/models/AsyncTaskModel.js +3 -1
- package/dist/models/RedisKeys.d.ts +2 -0
- package/dist/models/RedisKeys.js +2 -0
- package/dist/models/bizmodels.d.ts +1 -0
- package/dist/service/UserSessionService.d.ts +21 -0
- package/dist/service/UserSessionService.js +71 -1
- package/dist/service/WorkbenchService.d.ts +32 -0
- package/dist/service/WorkbenchService.js +54 -11
- package/dist/service/anyapi/AnyApiSandboxService.js +12 -12
- package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +14 -1
- package/dist/service/asyncTask/AsyncTaskRunnerService.js +70 -25
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.js +1 -1
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.js +11 -2
- package/dist/service/base/RedisCacheService.d.ts +7 -0
- package/dist/service/base/RedisCacheService.js +7 -0
- package/dist/service/crudstd/CrudStdService.d.ts +0 -6
- package/dist/service/crudstd/CrudStdService.js +13 -33
- package/package.json +1 -5
- package/src/config/config.default.ts +0 -207
- package/src/config/seed/aeskey.txt +0 -1
- package/src/config/utils.ts +0 -22
- package/src/configuration.ts +0 -109
- package/src/controller/base/BaseApiController.ts +0 -170
- package/src/controller/gateway/AnyApiGatewayController.ts +0 -33
- package/src/controller/gateway/AsyncTaskController.ts +0 -157
- package/src/controller/gateway/CrudMtdGatewayController.ts +0 -111
- package/src/controller/gateway/CrudStdGatewayController.ts +0 -101
- package/src/controller/gateway/DocGatewayController.ts +0 -173
- package/src/controller/gateway/FileController.ts +0 -109
- package/src/controller/gateway/ProxyApiGatewayController.ts +0 -47
- package/src/controller/gateway/PublicApiController.ts +0 -142
- package/src/controller/gateway/StaticController.ts +0 -298
- package/src/controller/helpers.controller.ts +0 -161
- package/src/controller/home.controller.ts +0 -64
- package/src/controller/manage/AnyApiMangeApi.ts +0 -66
- package/src/controller/manage/AppLogMangeApi.ts +0 -53
- package/src/controller/manage/AppMangeApi.ts +0 -53
- package/src/controller/manage/AppPageMangeApi.ts +0 -52
- package/src/controller/manage/AppSchemaHistoryApi.ts +0 -49
- package/src/controller/manage/CrudMethodsMangeApi.ts +0 -49
- package/src/controller/manage/CrudStandardDesignApi.ts +0 -346
- package/src/controller/manage/DataDictManageApi.ts +0 -78
- package/src/controller/manage/DeployManageApi.ts +0 -175
- package/src/controller/manage/DocLibManageApi.ts +0 -69
- package/src/controller/manage/DocManageApi.ts +0 -99
- package/src/controller/manage/FileManageApi.ts +0 -45
- package/src/controller/manage/LowCodeTplManageApi.ts +0 -52
- package/src/controller/manage/MenuManageApi.ts +0 -58
- package/src/controller/manage/ProxyApiMangeApi.ts +0 -52
- package/src/controller/manage/SuperAdminManageApi.ts +0 -139
- package/src/controller/manage/SysConfigMangeApi.ts +0 -95
- package/src/controller/manage/SystemInfoManageApi.ts +0 -53
- package/src/controller/manage/UserAccountManageApi.ts +0 -94
- package/src/controller/manage/WorkbenchMangeApi.ts +0 -72
- package/src/controller/myinfo/AuthController.ts +0 -108
- package/src/controller/myinfo/MyInfoController.ts +0 -32
- package/src/controller/render/AppRenderController.ts +0 -79
- package/src/controller/test.controller.ts +0 -37
- package/src/filter/default.filter.ts +0 -13
- package/src/filter/notfound.filter.ts +0 -10
- package/src/index.ts +0 -106
- package/src/interface.ts +0 -31
- package/src/libs/crud-pro/CrudPro.ts +0 -165
- package/src/libs/crud-pro/defaultConfigs.ts +0 -15
- package/src/libs/crud-pro/exceptions.ts +0 -124
- package/src/libs/crud-pro/interfaces.ts +0 -190
- package/src/libs/crud-pro/models/ExecuteContext.ts +0 -120
- package/src/libs/crud-pro/models/ExecuteContextFunc.ts +0 -96
- package/src/libs/crud-pro/models/FuncContext.ts +0 -21
- package/src/libs/crud-pro/models/RequestCfgModel.ts +0 -141
- package/src/libs/crud-pro/models/RequestModel.ts +0 -141
- package/src/libs/crud-pro/models/ResModel.ts +0 -19
- package/src/libs/crud-pro/models/ServiceHub.ts +0 -32
- package/src/libs/crud-pro/models/SqlCfgModel.ts +0 -52
- package/src/libs/crud-pro/models/SqlSegArg.ts +0 -13
- package/src/libs/crud-pro/models/Transaction.ts +0 -73
- package/src/libs/crud-pro/models/TransactionMySQL.ts +0 -79
- package/src/libs/crud-pro/models/TransactionPostgres.ts +0 -91
- package/src/libs/crud-pro/models/TransactionSqlServer.ts +0 -102
- package/src/libs/crud-pro/models/keys.ts +0 -159
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +0 -83
- package/src/libs/crud-pro/services/CrudProExecuteFuncService.ts +0 -128
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +0 -262
- package/src/libs/crud-pro/services/CrudProFieldUpdateService.ts +0 -60
- package/src/libs/crud-pro/services/CrudProFieldValidateService.ts +0 -180
- package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +0 -354
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +0 -185
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +0 -393
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +0 -94
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +0 -86
- package/src/libs/crud-pro/services/CurdProServiceHub.ts +0 -92
- package/src/libs/crud-pro/sql.txt +0 -120
- package/src/libs/crud-pro/utils/CompareUtils.ts +0 -23
- package/src/libs/crud-pro/utils/DatabaseName.ts +0 -60
- package/src/libs/crud-pro/utils/DateTimeUtils.ts +0 -20
- package/src/libs/crud-pro/utils/MemoryRefreshCache.ts +0 -64
- package/src/libs/crud-pro/utils/MessageParseUtils.ts +0 -33
- package/src/libs/crud-pro/utils/MixinUtils.ts +0 -285
- package/src/libs/crud-pro/utils/ModelUtils.ts +0 -55
- package/src/libs/crud-pro/utils/MultiKeyMap.ts +0 -72
- package/src/libs/crud-pro/utils/SqlFuncUtils.ts +0 -29
- package/src/libs/crud-pro/utils/TypeUtils.ts +0 -188
- package/src/libs/crud-pro/utils/ValidateUtils.ts +0 -165
- package/src/libs/crud-pro/utils/pool/MySQLUtils.ts +0 -20
- package/src/libs/crud-pro/utils/pool/PostgresUtils.ts +0 -22
- package/src/libs/crud-pro/utils/pool/SqlServerUtils.ts +0 -22
- package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +0 -26
- package/src/libs/crud-pro/utils/sqlConvert/convertMix.ts +0 -26
- package/src/libs/crud-pro/utils/sqlConvert/convertMsSql.ts +0 -11
- package/src/libs/crud-pro/utils/sqlConvert/convertPgSql.ts +0 -11
- package/src/libs/crud-pro/utils/sqlConvert/convertPgType.ts +0 -129
- package/src/libs/global-config/global-config.ts +0 -78
- package/src/libs/utils/common-dto.ts +0 -52
- package/src/libs/utils/crypto-utils.ts +0 -50
- package/src/libs/utils/errorToString.ts +0 -61
- package/src/libs/utils/fatcms-request.ts +0 -103
- package/src/libs/utils/functions.ts +0 -73
- package/src/libs/utils/ordernum-utils.ts +0 -14
- package/src/libs/utils/parseConfig.ts +0 -54
- package/src/libs/utils/parseCreateSql.ts +0 -91
- package/src/libs/utils/render-utils.ts +0 -184
- package/src/middleware/forbidden.middleware.ts +0 -52
- package/src/middleware/global.middleware.ts +0 -280
- package/src/middleware/permission.middleware.ts +0 -80
- package/src/middleware/tx.middleware.ts +0 -30
- package/src/models/AsyncTaskModel.ts +0 -82
- package/src/models/RedisKeys.ts +0 -13
- package/src/models/SystemEntities.ts +0 -115
- package/src/models/SystemPerm.ts +0 -105
- package/src/models/SystemTables.ts +0 -27
- package/src/models/bizmodels.ts +0 -120
- package/src/models/contextLogger.ts +0 -132
- package/src/models/devops.ts +0 -17
- package/src/models/userSession.ts +0 -216
- package/src/schedule/anonymousContext.ts +0 -73
- package/src/schedule/index.ts +0 -12
- package/src/schedule/runSchedule.ts +0 -82
- package/src/schedule/scheduleNames.ts +0 -21
- package/src/service/AuthService.ts +0 -272
- package/src/service/EnumInfoService.ts +0 -130
- package/src/service/FileCenterService.ts +0 -395
- package/src/service/SysConfigService.ts +0 -37
- package/src/service/UserAccountService.ts +0 -107
- package/src/service/UserSessionService.ts +0 -78
- package/src/service/VisitStatService.ts +0 -166
- package/src/service/WorkbenchService.ts +0 -165
- package/src/service/anyapi/AnyApiSandboxService.ts +0 -121
- package/src/service/anyapi/AnyApiService.ts +0 -186
- package/src/service/asyncTask/AsyncTaskRunnerService.ts +0 -266
- package/src/service/asyncTask/AsyncTaskService.ts +0 -21
- package/src/service/asyncTask/handler/ExcelInfoModel.ts +0 -11
- package/src/service/asyncTask/handler/ExportExcelAsyncTaskHandler.ts +0 -245
- package/src/service/asyncTask/handler/ExportExcelByInnerHttpHandler.ts +0 -147
- package/src/service/asyncTask/handler/ExportExcelByStdCrudHandler.ts +0 -138
- package/src/service/base/ApiBaseService.ts +0 -42
- package/src/service/base/ApiRateLimiter.ts +0 -59
- package/src/service/base/BaseService.ts +0 -100
- package/src/service/base/RedisCacheService.ts +0 -38
- package/src/service/crudstd/CrudStdActionService.ts +0 -27
- package/src/service/crudstd/CrudStdConstant.ts +0 -62
- package/src/service/crudstd/CrudStdRelationService.ts +0 -78
- package/src/service/crudstd/CrudStdService.ts +0 -283
- package/src/service/curd/CrudProQuick.ts +0 -131
- package/src/service/curd/CurdMixByAccountService.ts +0 -90
- package/src/service/curd/CurdMixByDictService.ts +0 -114
- package/src/service/curd/CurdMixByLinkToCustomService.ts +0 -219
- package/src/service/curd/CurdMixBySysConfigService.ts +0 -78
- package/src/service/curd/CurdMixByWorkbenchService.ts +0 -71
- package/src/service/curd/CurdMixService.ts +0 -97
- package/src/service/curd/CurdMixUtils.ts +0 -311
- package/src/service/curd/CurdProService.ts +0 -229
- package/src/service/curd/fixCfgModel.ts +0 -139
- package/src/service/proxyapi/ProxyApiLoadService.ts +0 -174
- package/src/service/proxyapi/ProxyApiService.ts +0 -262
- package/src/service/proxyapi/ProxyApiUtils.ts +0 -32
- package/src/service/proxyapi/RouteHandler.ts +0 -8
- package/src/service/proxyapi/RouteTrie.ts +0 -74
- package/src/service/proxyapi/WeightedRandom.ts +0 -37
- package/src/service/proxyapi/WeightedRoundRobin.ts +0 -44
- package/src/views/404_app.html +0 -31
- package/src/views/404_workbench.html +0 -34
- package/src/views/static/favicon.ico +0 -0
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { Inject, Provide, App } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { RedisService } from '@midwayjs/redis';
|
|
4
|
-
import { OSSService, OSSServiceFactory } from '@midwayjs/oss';
|
|
5
|
-
import * as koa from '@midwayjs/koa';
|
|
6
|
-
import { consoleLogger, ContextLogger, ILoggerContext } from '@/models/contextLogger';
|
|
7
|
-
import { isEnableDebug, isLocalEnv } from '@/libs/utils/fatcms-request';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@Provide()
|
|
11
|
-
export class BaseService {
|
|
12
|
-
@Inject()
|
|
13
|
-
protected ctx: Context;
|
|
14
|
-
|
|
15
|
-
@App()
|
|
16
|
-
protected app: koa.Application;
|
|
17
|
-
|
|
18
|
-
@Inject()
|
|
19
|
-
protected redisService: RedisService;
|
|
20
|
-
|
|
21
|
-
@Inject()
|
|
22
|
-
protected ossServiceFactory: OSSServiceFactory;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 请求级别的内存缓存
|
|
27
|
-
* @param key
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
30
|
-
protected getFromCtxCache(key: string): any {
|
|
31
|
-
if (!this.ctx.ctxCacheMap) {
|
|
32
|
-
this.ctx.ctxCacheMap = {};
|
|
33
|
-
}
|
|
34
|
-
return this.ctx.ctxCacheMap[key];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 请求级别的内存缓存
|
|
40
|
-
* @param key
|
|
41
|
-
* @param obj
|
|
42
|
-
*/
|
|
43
|
-
protected setToCtxCache(key: string, obj: any): void {
|
|
44
|
-
if (!this.ctx.ctxCacheMap) {
|
|
45
|
-
this.ctx.ctxCacheMap = {};
|
|
46
|
-
}
|
|
47
|
-
this.ctx.ctxCacheMap[key] = obj;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 用户自己上传的文件,使用私有的bucket。
|
|
53
|
-
* @protected
|
|
54
|
-
*/
|
|
55
|
-
protected getPrivateOSSService(): OSSService {
|
|
56
|
-
return this.ossServiceFactory.get<OSSService>('privateBucket');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 公共读的bucket,如js文件等使用它
|
|
61
|
-
* @protected
|
|
62
|
-
*/
|
|
63
|
-
protected getPublicOSSService(): OSSService {
|
|
64
|
-
return this.ossServiceFactory.get<OSSService>('publicBucket');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
protected getContextLogger(): ILoggerContext {
|
|
69
|
-
return this.ctx.contextLogger || consoleLogger;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
protected getPrefixContextLogger(prefix: string) {
|
|
73
|
-
const s = this.ctx.contextLogger as ContextLogger;
|
|
74
|
-
return s.getPrefixContextLogger(prefix);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
protected logInfo(msg: string, ...args: any) {
|
|
78
|
-
this.getContextLogger().info(msg, ...args);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
protected logError(msg: string, ...args: any) {
|
|
82
|
-
this.getContextLogger().error(msg, ...args);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
protected logWarn(msg: string, ...args: any) {
|
|
86
|
-
this.getContextLogger().warn(msg, ...args);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
protected logDebug(msg: string, ...args: any) {
|
|
90
|
-
this.getContextLogger().debug(msg, ...args);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
protected isLocalEnv(): boolean {
|
|
94
|
-
return isLocalEnv(this.ctx);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
protected isEnableDebug(): boolean {
|
|
98
|
-
return isEnableDebug(this.ctx);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Inject, Provide, App } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { RedisService } from '@midwayjs/redis';
|
|
4
|
-
import { OSSServiceFactory } from '@midwayjs/oss';
|
|
5
|
-
import * as koa from '@midwayjs/koa';
|
|
6
|
-
import {parseJsonObject} from "../../libs/utils/functions";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@Provide()
|
|
10
|
-
export class RedisCacheService {
|
|
11
|
-
@Inject()
|
|
12
|
-
protected ctx: Context;
|
|
13
|
-
|
|
14
|
-
@App()
|
|
15
|
-
protected app: koa.Application;
|
|
16
|
-
|
|
17
|
-
@Inject()
|
|
18
|
-
protected redisService: RedisService;
|
|
19
|
-
|
|
20
|
-
@Inject()
|
|
21
|
-
protected ossServiceFactory: OSSServiceFactory;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
async getJsonObject(key: string): Promise<any> {
|
|
25
|
-
const str = await this.redisService.get(key);
|
|
26
|
-
return parseJsonObject(str)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async setJsonObject(key: string, obj: any, expireSecond: number): Promise<any> {
|
|
30
|
-
const str = JSON.stringify(obj);
|
|
31
|
-
return this.redisService.set(key, str, 'EX', expireSecond);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async removeItem(key: string): Promise<any> {
|
|
35
|
-
return await this.redisService.del(key);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Inject, Provide } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import * as _ from 'lodash';
|
|
4
|
-
import { CurdMixService } from '../curd/CurdMixService';
|
|
5
|
-
import { IRequestModel } from '../../libs/crud-pro/interfaces';
|
|
6
|
-
import { ICrudStdAppInfo } from '../../models/bizmodels';
|
|
7
|
-
import { BaseService } from '../base/BaseService';
|
|
8
|
-
|
|
9
|
-
interface IHandleStdActionByReq {
|
|
10
|
-
actionsMap: any;
|
|
11
|
-
appInfo: ICrudStdAppInfo;
|
|
12
|
-
params: IRequestModel;
|
|
13
|
-
actionCfg: any;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@Provide()
|
|
17
|
-
export class CrudStdActionService extends BaseService {
|
|
18
|
-
@Inject()
|
|
19
|
-
protected ctx: Context;
|
|
20
|
-
|
|
21
|
-
@Inject()
|
|
22
|
-
protected curdMixService: CurdMixService;
|
|
23
|
-
|
|
24
|
-
public async handleStdActionByReq({ appInfo, params, actionCfg }: IHandleStdActionByReq) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 工具栏的动作。一般都是批量操作
|
|
3
|
-
*/
|
|
4
|
-
const toolbarOptions = {
|
|
5
|
-
ToolbarCreateFormPro: 'ToolbarCreateFormPro', // 新建
|
|
6
|
-
ToolbarBatchEditFormPro: 'ToolbarBatchEditFormPro', // 批量编辑
|
|
7
|
-
ToolbarBatchDelete: 'ToolbarBatchDelete', //批量删除
|
|
8
|
-
ToolbarBatchCreate: 'ToolbarBatchCreate', // 批量新建
|
|
9
|
-
ToolbarSpecializedScene: 'ToolbarSpecializedScene',
|
|
10
|
-
ToolbarOpenURL: 'ToolbarOpenURL',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 操作列的可选项
|
|
15
|
-
* @type {{}}
|
|
16
|
-
*/
|
|
17
|
-
const actionColumnOptions = {
|
|
18
|
-
ActionDialogEditFormPro: 'ActionDialogEditFormPro',
|
|
19
|
-
ActionDialogDelete: 'ActionDialogDelete',
|
|
20
|
-
ActionLinkTo: 'ActionLinkTo', // 跳转链接(自动拼参数)
|
|
21
|
-
ActionLinkToCustom: 'ActionLinkToCustom', // 跳转链接(完全自定义)
|
|
22
|
-
ActionDialogEditJSON: 'ActionDialogEditJSON',
|
|
23
|
-
ActionDialogEditHTML: 'ActionDialogEditHTML',
|
|
24
|
-
ActionDialogEditText: 'ActionDialogEditText',
|
|
25
|
-
ActionDialogEditRichText: 'ActionDialogEditRichText',
|
|
26
|
-
ActionDialogEditExcel: 'ActionDialogEditExcel',
|
|
27
|
-
ActionDrawerRelationCrud: 'ActionDrawerRelationCrud', // 关联对象CRUD
|
|
28
|
-
ActionSpecializedScene: 'ActionSpecializedScene',
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 表格列展示字段
|
|
33
|
-
* @type {{}}
|
|
34
|
-
*/
|
|
35
|
-
const tableColumnRenders = {
|
|
36
|
-
RenderString: 'RenderString',
|
|
37
|
-
RenderDictEnumText: 'RenderDictEnumText',
|
|
38
|
-
RenderDictEnumStatus: 'RenderDictEnumStatus',
|
|
39
|
-
RenderEntityStatus: 'RenderEntityStatus',
|
|
40
|
-
RenderDateTime: 'RenderDateTime',
|
|
41
|
-
RenderDate: 'RenderDate',
|
|
42
|
-
RenderImage: 'RenderImage',
|
|
43
|
-
RenderLink: 'RenderLink',
|
|
44
|
-
RenderHTML: 'RenderHTML',
|
|
45
|
-
RenderJSON: 'RenderJSON',
|
|
46
|
-
RenderDialogText: 'RenderDialogText',
|
|
47
|
-
RenderDialogHTML: 'RenderDialogHTML',
|
|
48
|
-
RenderDialogJSON: 'RenderDialogJSON',
|
|
49
|
-
RenderUserInfo: 'RenderUserInfo',
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* 字段关联数据类型
|
|
54
|
-
* @type {{}}
|
|
55
|
-
*/
|
|
56
|
-
const fieldLinkToTypes = {
|
|
57
|
-
linkToDict: 'linkToDict',
|
|
58
|
-
linkToSysCfgEnum: 'linkToSysCfgEnum',
|
|
59
|
-
linkToCustom: 'linkToCustom',
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export { toolbarOptions, actionColumnOptions, tableColumnRenders, fieldLinkToTypes };
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Inject, Provide } from '@midwayjs/core';
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import * as _ from 'lodash';
|
|
4
|
-
import { CurdMixService } from '../curd/CurdMixService';
|
|
5
|
-
import { IRequestCfgModel } from '../../libs/crud-pro/interfaces';
|
|
6
|
-
import { ICrudStdAppInfoForSettingKey } from '../../models/bizmodels';
|
|
7
|
-
import { BaseService } from '../base/BaseService';
|
|
8
|
-
import { tableColumnRenders, fieldLinkToTypes } from './CrudStdConstant';
|
|
9
|
-
import { RelatedType } from '../curd/CurdMixUtils';
|
|
10
|
-
|
|
11
|
-
@Provide()
|
|
12
|
-
export class CrudStdRelationService extends BaseService {
|
|
13
|
-
@Inject()
|
|
14
|
-
protected ctx: Context;
|
|
15
|
-
|
|
16
|
-
@Inject()
|
|
17
|
-
protected curdMixService: CurdMixService;
|
|
18
|
-
|
|
19
|
-
async addCfgModelColumnsRelation(cfgModel: IRequestCfgModel, appInfo: ICrudStdAppInfoForSettingKey) {
|
|
20
|
-
const tableColumns = appInfo?.stdCrudCfgObj?.tableColumns;
|
|
21
|
-
const tableFields = appInfo?.stdCrudCfgObj?.tableFields || [];
|
|
22
|
-
|
|
23
|
-
if (!Array.isArray(tableColumns)) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const columnsRelation = [];
|
|
28
|
-
cfgModel.columnsRelation = columnsRelation;
|
|
29
|
-
for (let i = 0; i < tableColumns.length; i++) {
|
|
30
|
-
const tableColumn = tableColumns[i];
|
|
31
|
-
const dataIndex = _.get(tableColumn, 'dataIndex');
|
|
32
|
-
const componentName = _.get(tableColumn, 'component.componentName');
|
|
33
|
-
|
|
34
|
-
// 关联用户信息
|
|
35
|
-
if (componentName === tableColumnRenders.RenderUserInfo) {
|
|
36
|
-
columnsRelation.push({
|
|
37
|
-
relatedType: RelatedType.accountBasic,
|
|
38
|
-
sourceColumn: dataIndex,
|
|
39
|
-
targetColumns: [], // 使用默认
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// 关联枚举文案/状态标签颜色
|
|
44
|
-
if (componentName === tableColumnRenders.RenderDictEnumText || componentName === tableColumnRenders.RenderDictEnumStatus) {
|
|
45
|
-
const fieldCfg = tableFields.find(f => {
|
|
46
|
-
return f.fieldIndex === dataIndex;
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
if (fieldCfg && fieldCfg.linkToType === fieldLinkToTypes.linkToCustom) {
|
|
50
|
-
columnsRelation.push({
|
|
51
|
-
relatedType: RelatedType.linkToCustom,
|
|
52
|
-
relatedCode: fieldCfg.linkToCustom,
|
|
53
|
-
sourceColumn: dataIndex,
|
|
54
|
-
targetColumns: [], // 使用默认
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (fieldCfg && fieldCfg.linkToType === fieldLinkToTypes.linkToSysCfgEnum) {
|
|
59
|
-
columnsRelation.push({
|
|
60
|
-
relatedType: RelatedType.sysCfgEnum,
|
|
61
|
-
relatedCode: fieldCfg.linkToSysCfgEnumCode,
|
|
62
|
-
sourceColumn: dataIndex,
|
|
63
|
-
targetColumns: [], // 使用默认
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (fieldCfg && fieldCfg.linkToType === fieldLinkToTypes.linkToDict) {
|
|
68
|
-
columnsRelation.push({
|
|
69
|
-
relatedType: RelatedType.dict,
|
|
70
|
-
relatedCode: fieldCfg.linkToDictCode,
|
|
71
|
-
sourceColumn: dataIndex,
|
|
72
|
-
targetColumns: [], // 使用默认
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import * as _ from 'lodash';
|
|
2
|
-
import axios from 'axios';
|
|
3
|
-
import { Inject, Provide } from '@midwayjs/core';
|
|
4
|
-
import { Context } from '@midwayjs/koa';
|
|
5
|
-
import { CurdMixService } from '../curd/CurdMixService';
|
|
6
|
-
import { IRequestCfgModel, IRequestModel } from '../../libs/crud-pro/interfaces';
|
|
7
|
-
import { KeysOfAuthType, KeysOfSimpleSQL, SqlDbType } from '../../libs/crud-pro/models/keys';
|
|
8
|
-
import { parseJsonObject } from '../../libs/utils/functions';
|
|
9
|
-
import { ICrudStdAppInfo, ICrudStdAppInfoForSettingKey } from '../../models/bizmodels';
|
|
10
|
-
import { BizException } from '../../models/devops';
|
|
11
|
-
import { ExecuteContext } from '../../libs/crud-pro/models/ExecuteContext';
|
|
12
|
-
import { SystemTables } from '../../models/SystemTables';
|
|
13
|
-
import { CrudStdActionService } from './CrudStdActionService';
|
|
14
|
-
import { CrudStdRelationService } from './CrudStdRelationService';
|
|
15
|
-
import { ApiBaseService } from '../base/ApiBaseService';
|
|
16
|
-
import { parseDatabaseName } from '../../libs/crud-pro/utils/DatabaseName';
|
|
17
|
-
import { GLOBAL_STATIC_CONFIG } from '../../libs/global-config/global-config';
|
|
18
|
-
import { MixinUtils } from '@/libs/crud-pro/utils/MixinUtils';
|
|
19
|
-
|
|
20
|
-
export const SPECIAL_SETTING_KEY = {
|
|
21
|
-
QUERY_LIST: 'QUERY_LIST',
|
|
22
|
-
QUERY_ONE: 'QUERY_ONE',
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const INNER_HTTP_POTOCAL = "innerHttp://"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@Provide()
|
|
29
|
-
export class CrudStdService extends ApiBaseService {
|
|
30
|
-
|
|
31
|
-
@Inject()
|
|
32
|
-
protected ctx: Context;
|
|
33
|
-
|
|
34
|
-
@Inject()
|
|
35
|
-
protected curdMixService: CurdMixService;
|
|
36
|
-
|
|
37
|
-
@Inject()
|
|
38
|
-
protected crudStdActionService: CrudStdActionService;
|
|
39
|
-
|
|
40
|
-
@Inject()
|
|
41
|
-
protected crudStdRelationService: CrudStdRelationService;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* 执行普通CRUD
|
|
45
|
-
*/
|
|
46
|
-
public async executeStdQuery(appCode: string, settingKey: string, params: IRequestModel, sqlSimpleName: KeysOfSimpleSQL): Promise<ExecuteContext> {
|
|
47
|
-
const appInfo = await this.getParsedCrudStdAppForSettingKey(appCode, settingKey);
|
|
48
|
-
const stdCrudCfgObj = appInfo.stdCrudCfgObj;
|
|
49
|
-
|
|
50
|
-
if (!appInfo || appInfo.status !== 1) {
|
|
51
|
-
throw new BizException('应用不存在或已下线:' + appCode);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// 查询列表功能
|
|
56
|
-
if (settingKey === SPECIAL_SETTING_KEY.QUERY_LIST) {
|
|
57
|
-
// 正确启用了自定义查询功能
|
|
58
|
-
const customQueryApi: string = _.get(stdCrudCfgObj, 'othersSetting.values.customQueryApi');
|
|
59
|
-
if (typeof customQueryApi === 'string' && customQueryApi.startsWith(INNER_HTTP_POTOCAL)) {
|
|
60
|
-
return this.executeStdQueryByInnerHttp(customQueryApi, params);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const databaseName = stdCrudCfgObj.tableBaseInfo.databaseName;
|
|
66
|
-
|
|
67
|
-
const { dbType, dbName } = parseDatabaseName(databaseName);
|
|
68
|
-
|
|
69
|
-
const cfgModel: IRequestCfgModel = {
|
|
70
|
-
sqlDatabase: dbName,
|
|
71
|
-
sqlDbType: dbType,
|
|
72
|
-
sqlTable: stdCrudCfgObj.tableBaseInfo.tableName,
|
|
73
|
-
sqlSimpleName,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// 接口返回最大值
|
|
77
|
-
const maxLimit = _.get(stdCrudCfgObj, 'othersSetting.values.maxLimit');
|
|
78
|
-
if (typeof maxLimit === 'number' && maxLimit > 0) {
|
|
79
|
-
cfgModel.maxLimit = maxLimit;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (!appInfo.settingKeyActionCfg.hasOperationPerm) {
|
|
83
|
-
throw new BizException('没有权限');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// 根据用户配置,设置关联查询的数据信息。
|
|
87
|
-
await this.crudStdRelationService.addCfgModelColumnsRelation(cfgModel, appInfo);
|
|
88
|
-
|
|
89
|
-
// 根据表结构的数据类型,修正数据类型
|
|
90
|
-
await this.fixDataFieldTypeBySqlTableField(params, cfgModel, appInfo, { dbType, dbName });
|
|
91
|
-
|
|
92
|
-
// 业务系统自定义的修改cfgModel
|
|
93
|
-
await GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudStd(params, cfgModel, appInfo, this.ctx);
|
|
94
|
-
|
|
95
|
-
return await this.curdMixService.executeCrudByCfg(params, cfgModel);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* 内部请求
|
|
101
|
-
* @param customQueryApi
|
|
102
|
-
* @param params
|
|
103
|
-
*/
|
|
104
|
-
private async executeStdQueryByInnerHttp(customQueryApi: string, params: IRequestModel): Promise<ExecuteContext> {
|
|
105
|
-
const queryApi = customQueryApi.substring(INNER_HTTP_POTOCAL.length);
|
|
106
|
-
const port = this.app.getConfig().koa.port;
|
|
107
|
-
const response = await axios({
|
|
108
|
-
method: 'POST',
|
|
109
|
-
url: `http://127.0.0.1:${port}/${queryApi}`,
|
|
110
|
-
data: this.ctx.request?.body || params,
|
|
111
|
-
headers: this.ctx.innerHeaders || this.ctx.headers,
|
|
112
|
-
responseType: 'json',
|
|
113
|
-
validateStatus: () => true,
|
|
114
|
-
});
|
|
115
|
-
if (response.status !== 200) {
|
|
116
|
-
throw new Error('executeStdQueryByInnerHttp请求错误失败')
|
|
117
|
-
}
|
|
118
|
-
return Promise.resolve(response.data);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* 获取appInfo 并且拿到当前settingKey相关的信息
|
|
124
|
-
* @param appCode
|
|
125
|
-
* @param settingKey
|
|
126
|
-
* @private
|
|
127
|
-
*/
|
|
128
|
-
private async getParsedCrudStdAppForSettingKey(appCode: string, settingKey: string): Promise<ICrudStdAppInfoForSettingKey> {
|
|
129
|
-
if (!appCode) {
|
|
130
|
-
throw new BizException('缺少参数:curdStdAppCode');
|
|
131
|
-
}
|
|
132
|
-
const appInfo: ICrudStdAppInfoForSettingKey = await this.getParsedCrudStdAppInfo(appCode);
|
|
133
|
-
if (!appInfo) {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const actionsMap = appInfo.actionsMap;
|
|
138
|
-
const appSchema = appInfo.stdCrudCfgObj;
|
|
139
|
-
|
|
140
|
-
if (settingKey === SPECIAL_SETTING_KEY.QUERY_LIST || settingKey === SPECIAL_SETTING_KEY.QUERY_ONE) {
|
|
141
|
-
const authSettingValues = _.get(appSchema, 'authSetting.values');
|
|
142
|
-
const { auth_type, auth_config_by_func_code, auth_config_by_role_code } = authSettingValues || {};
|
|
143
|
-
const authConfig = auth_type === 'byFuncCode' ? auth_config_by_func_code : auth_config_by_role_code;
|
|
144
|
-
const hasOperationPerm = this.ctx.userSession.isAuthPass(auth_type as any, authConfig);
|
|
145
|
-
appInfo.settingKeyActionCfg = { settingKey, hasOperationPerm };
|
|
146
|
-
} else {
|
|
147
|
-
const actionCfg = actionsMap[settingKey];
|
|
148
|
-
if (!actionCfg) {
|
|
149
|
-
throw new BizException('没有找到相关配置:' + JSON.stringify({ appCode, settingKey }));
|
|
150
|
-
}
|
|
151
|
-
const componentNameCfg = _.get(actionCfg, 'component.componentName');
|
|
152
|
-
if (!componentNameCfg) {
|
|
153
|
-
throw new BizException('没有配置动作组件:' + JSON.stringify({ appCode, settingKey }));
|
|
154
|
-
}
|
|
155
|
-
appInfo.settingKeyActionCfg = actionCfg;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return appInfo;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* 执行动作
|
|
163
|
-
* @param appCode
|
|
164
|
-
* @param settingKey
|
|
165
|
-
* @param params
|
|
166
|
-
*/
|
|
167
|
-
public async executeStdActionByReq(appCode: string, settingKey: string, params: IRequestModel): Promise<ExecuteContext> {
|
|
168
|
-
const appInfo = await this.getParsedCrudStdAppForSettingKey(appCode, settingKey);
|
|
169
|
-
if (!appInfo || appInfo.status !== 1) {
|
|
170
|
-
throw new BizException('应用不存在或已下线:' + appCode);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const actionsMap = appInfo.actionsMap;
|
|
174
|
-
const actionCfg = appInfo.settingKeyActionCfg;
|
|
175
|
-
|
|
176
|
-
return this.crudStdActionService.handleStdActionByReq({ appInfo, params, actionsMap, actionCfg });
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* 查询APP信息
|
|
181
|
-
* @param appCode
|
|
182
|
-
* @private
|
|
183
|
-
*/
|
|
184
|
-
private async getCrudStdAppInfo(appCode?: string) {
|
|
185
|
-
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
186
|
-
|
|
187
|
-
this.logInfo('getCrudStdAppInfo', appCode);
|
|
188
|
-
|
|
189
|
-
const ss = {
|
|
190
|
-
sqlTable: SystemTables.sys_app,
|
|
191
|
-
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
192
|
-
sqlDatabase: SystemDbName,
|
|
193
|
-
sqlDbType: SystemDbType,
|
|
194
|
-
};
|
|
195
|
-
return await this.curdMixService.executeCrudByCfg({ condition: { app_code: appCode } }, ss);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* 查询APP信息
|
|
201
|
-
* @param appCode
|
|
202
|
-
* @private
|
|
203
|
-
*/
|
|
204
|
-
public async getParsedCrudStdAppInfo(appCode: string): Promise<ICrudStdAppInfo> {
|
|
205
|
-
const cacheKey = "getParsedCrudStdAppInfo:" + appCode;
|
|
206
|
-
let appInfo: ICrudStdAppInfo = this.getFromCtxCache(cacheKey) as any;
|
|
207
|
-
if (!appInfo) {
|
|
208
|
-
appInfo = await this.getParsedCrudStdAppInfoPrivate(appCode);
|
|
209
|
-
this.setToCtxCache(cacheKey, appInfo);
|
|
210
|
-
}
|
|
211
|
-
return appInfo;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* 查询APP信息
|
|
217
|
-
* @param appCode
|
|
218
|
-
* @private
|
|
219
|
-
*/
|
|
220
|
-
private async getParsedCrudStdAppInfoPrivate(appCode: string): Promise<ICrudStdAppInfo> {
|
|
221
|
-
const a = await this.getCrudStdAppInfo(appCode);
|
|
222
|
-
const { row } = a.getResModel();
|
|
223
|
-
if (!row) {
|
|
224
|
-
return null;
|
|
225
|
-
}
|
|
226
|
-
const { app_schema, ...others } = row;
|
|
227
|
-
const stdCrudCfgObj = parseJsonObject(app_schema);
|
|
228
|
-
|
|
229
|
-
// 为了方便查找到action对象
|
|
230
|
-
const actionsMap = {};
|
|
231
|
-
const keys = Object.keys(stdCrudCfgObj);
|
|
232
|
-
for (let i = 0; i < keys.length; i++) {
|
|
233
|
-
const key = keys[i];
|
|
234
|
-
const arrayCfg = stdCrudCfgObj[key];
|
|
235
|
-
if (Array.isArray(arrayCfg)) {
|
|
236
|
-
for (let j = 0; j < arrayCfg.length; j++) {
|
|
237
|
-
const actionCfg = arrayCfg[j];
|
|
238
|
-
actionCfg.hasOperationPerm = this.hasOperationPerm(actionCfg);
|
|
239
|
-
if (actionCfg.settingKey) {
|
|
240
|
-
actionsMap[actionCfg.settingKey] = actionCfg;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return { ...others, stdCrudCfgObj, actionsMap };
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
private hasOperationPerm(actionCfg: any): boolean {
|
|
250
|
-
const permissionCode = _.get(actionCfg, 'permissionCode');
|
|
251
|
-
if (permissionCode) {
|
|
252
|
-
return this.ctx.userSession.isAuthPass(KeysOfAuthType.byFuncCode, permissionCode);
|
|
253
|
-
}
|
|
254
|
-
return true; // 无需鉴权
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
private async fixDataFieldTypeBySqlTableField(params: IRequestModel, cfgModel: IRequestCfgModel, appInfo: ICrudStdAppInfoForSettingKey, arg3: { dbType: SqlDbType; dbName: string }) {
|
|
258
|
-
const tableFields = _.get(appInfo, 'stdCrudCfgObj.tableFields');
|
|
259
|
-
|
|
260
|
-
const tableFieldMap = MixinUtils.toMap(tableFields, (e: any) => {
|
|
261
|
-
return e.fieldIndex;
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
if (arg3.dbType === SqlDbType.postgres) {
|
|
265
|
-
if (cfgModel.sqlSimpleName === KeysOfSimpleSQL.SIMPLE_INSERT || cfgModel.sqlSimpleName === KeysOfSimpleSQL.SIMPLE_UPDATE) {
|
|
266
|
-
const data = params.data || {};
|
|
267
|
-
const dataKeys = Object.keys(data);
|
|
268
|
-
for (let index = 0; index < dataKeys.length; index++) {
|
|
269
|
-
const dataKey = dataKeys[index];
|
|
270
|
-
const dataValue = data[dataKey];
|
|
271
|
-
const fieldInfo = tableFieldMap[dataKey];
|
|
272
|
-
const fieldType = ('' + _.get(fieldInfo, 'type')).toUpperCase();
|
|
273
|
-
if (fieldType === 'ARRAY') {
|
|
274
|
-
const dataValueArray = parseJsonObject(dataValue);
|
|
275
|
-
if (Array.isArray(dataValueArray)) {
|
|
276
|
-
data[dataKey] = `{${dataValueArray.map(v => `"${v}"`).join(',')}}`;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|