midway-fatcms 0.0.1-beta.30 → 0.0.1-beta.31
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.d.ts +3 -0
- package/dist/config/config.default.js +189 -0
- package/dist/config/seed/aeskey.txt +1 -0
- package/dist/config/utils.d.ts +1 -0
- package/dist/config/utils.js +23 -0
- package/dist/configuration.d.ts +7 -0
- package/dist/configuration.js +113 -0
- package/dist/controller/base/BaseApiController.d.ts +37 -0
- package/dist/controller/base/BaseApiController.js +164 -0
- package/dist/controller/gateway/AnyApiGatewayController.d.ts +13 -0
- package/dist/controller/gateway/AnyApiGatewayController.js +55 -0
- package/dist/controller/gateway/AsyncTaskController.d.ts +20 -0
- package/dist/controller/gateway/AsyncTaskController.js +181 -0
- package/dist/controller/gateway/CrudMtdGatewayController.d.ts +21 -0
- package/dist/controller/gateway/CrudMtdGatewayController.js +119 -0
- package/dist/controller/gateway/CrudStdGatewayController.d.ts +38 -0
- package/dist/controller/gateway/CrudStdGatewayController.js +137 -0
- package/dist/controller/gateway/DocGatewayController.d.ts +27 -0
- package/dist/controller/gateway/DocGatewayController.js +179 -0
- package/dist/controller/gateway/FileController.d.ts +26 -0
- package/dist/controller/gateway/FileController.js +129 -0
- package/dist/controller/gateway/ProxyApiGatewayController.d.ts +18 -0
- package/dist/controller/gateway/ProxyApiGatewayController.js +78 -0
- package/dist/controller/gateway/PublicApiController.d.ts +27 -0
- package/dist/controller/gateway/PublicApiController.js +165 -0
- package/dist/controller/gateway/StaticController.d.ts +24 -0
- package/dist/controller/gateway/StaticController.js +288 -0
- package/dist/controller/helpers.controller.d.ts +39 -0
- package/dist/controller/helpers.controller.js +188 -0
- package/dist/controller/home.controller.d.ts +9 -0
- package/dist/controller/home.controller.js +72 -0
- package/dist/controller/manage/AnyApiMangeApi.d.ts +10 -0
- package/dist/controller/manage/AnyApiMangeApi.js +98 -0
- package/dist/controller/manage/AppLogMangeApi.d.ts +10 -0
- package/dist/controller/manage/AppLogMangeApi.js +88 -0
- package/dist/controller/manage/AppMangeApi.d.ts +10 -0
- package/dist/controller/manage/AppMangeApi.js +88 -0
- package/dist/controller/manage/AppPageMangeApi.d.ts +10 -0
- package/dist/controller/manage/AppPageMangeApi.js +87 -0
- package/dist/controller/manage/AppSchemaHistoryApi.d.ts +10 -0
- package/dist/controller/manage/AppSchemaHistoryApi.js +83 -0
- package/dist/controller/manage/CrudMethodsMangeApi.d.ts +10 -0
- package/dist/controller/manage/CrudMethodsMangeApi.js +84 -0
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +38 -0
- package/dist/controller/manage/CrudStandardDesignApi.js +342 -0
- package/dist/controller/manage/DataDictManageApi.d.ts +15 -0
- package/dist/controller/manage/DataDictManageApi.js +133 -0
- package/dist/controller/manage/DeployManageApi.d.ts +19 -0
- package/dist/controller/manage/DeployManageApi.js +180 -0
- package/dist/controller/manage/DocLibManageApi.d.ts +10 -0
- package/dist/controller/manage/DocLibManageApi.js +104 -0
- package/dist/controller/manage/DocManageApi.d.ts +11 -0
- package/dist/controller/manage/DocManageApi.js +130 -0
- package/dist/controller/manage/FileManageApi.d.ts +13 -0
- package/dist/controller/manage/FileManageApi.js +77 -0
- package/dist/controller/manage/LowCodeTplManageApi.d.ts +13 -0
- package/dist/controller/manage/LowCodeTplManageApi.js +86 -0
- package/dist/controller/manage/MenuManageApi.d.ts +10 -0
- package/dist/controller/manage/MenuManageApi.js +93 -0
- package/dist/controller/manage/ProxyApiMangeApi.d.ts +10 -0
- package/dist/controller/manage/ProxyApiMangeApi.js +87 -0
- package/dist/controller/manage/SuperAdminManageApi.d.ts +24 -0
- package/dist/controller/manage/SuperAdminManageApi.js +153 -0
- package/dist/controller/manage/SysConfigMangeApi.d.ts +11 -0
- package/dist/controller/manage/SysConfigMangeApi.js +126 -0
- package/dist/controller/manage/SystemInfoManageApi.d.ts +12 -0
- package/dist/controller/manage/SystemInfoManageApi.js +72 -0
- package/dist/controller/manage/UserAccountManageApi.d.ts +14 -0
- package/dist/controller/manage/UserAccountManageApi.js +129 -0
- package/dist/controller/manage/WorkbenchMangeApi.d.ts +11 -0
- package/dist/controller/manage/WorkbenchMangeApi.js +103 -0
- package/dist/controller/myinfo/AuthController.d.ts +33 -0
- package/dist/controller/myinfo/AuthController.js +136 -0
- package/dist/controller/myinfo/MyInfoController.d.ts +13 -0
- package/dist/controller/myinfo/MyInfoController.js +51 -0
- package/dist/controller/render/AppRenderController.d.ts +11 -0
- package/dist/controller/render/AppRenderController.js +92 -0
- package/dist/controller/test.controller.d.ts +8 -0
- package/dist/controller/test.controller.js +51 -0
- package/dist/filter/default.filter.d.ts +7 -0
- package/dist/filter/default.filter.js +23 -0
- package/dist/filter/notfound.filter.d.ts +5 -0
- package/dist/filter/notfound.filter.js +20 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +120 -0
- package/dist/interface.d.ts +27 -0
- package/dist/interface.js +3 -0
- package/dist/libs/crud-pro/CrudPro.d.ts +37 -0
- package/dist/libs/crud-pro/CrudPro.js +136 -0
- package/dist/libs/crud-pro/defaultConfigs.d.ts +4 -0
- package/dist/libs/crud-pro/defaultConfigs.js +15 -0
- package/dist/libs/crud-pro/exceptions.d.ts +104 -0
- package/dist/libs/crud-pro/exceptions.js +117 -0
- package/dist/libs/crud-pro/interfaces.d.ts +163 -0
- package/dist/libs/crud-pro/interfaces.js +12 -0
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +49 -0
- package/dist/libs/crud-pro/models/ExecuteContext.js +79 -0
- package/dist/libs/crud-pro/models/ExecuteContextFunc.d.ts +38 -0
- package/dist/libs/crud-pro/models/ExecuteContextFunc.js +72 -0
- package/dist/libs/crud-pro/models/FuncContext.d.ts +18 -0
- package/dist/libs/crud-pro/models/FuncContext.js +6 -0
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +65 -0
- package/dist/libs/crud-pro/models/RequestCfgModel.js +81 -0
- package/dist/libs/crud-pro/models/RequestModel.d.ts +25 -0
- package/dist/libs/crud-pro/models/RequestModel.js +113 -0
- package/dist/libs/crud-pro/models/ResModel.d.ts +16 -0
- package/dist/libs/crud-pro/models/ResModel.js +2 -0
- package/dist/libs/crud-pro/models/ServiceHub.d.ts +20 -0
- package/dist/libs/crud-pro/models/ServiceHub.js +2 -0
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +22 -0
- package/dist/libs/crud-pro/models/SqlCfgModel.js +40 -0
- package/dist/libs/crud-pro/models/SqlSegArg.d.ts +6 -0
- package/dist/libs/crud-pro/models/SqlSegArg.js +12 -0
- package/dist/libs/crud-pro/models/Transaction.d.ts +29 -0
- package/dist/libs/crud-pro/models/Transaction.js +67 -0
- package/dist/libs/crud-pro/models/TransactionMySQL.d.ts +28 -0
- package/dist/libs/crud-pro/models/TransactionMySQL.js +76 -0
- package/dist/libs/crud-pro/models/TransactionPostgres.d.ts +28 -0
- package/dist/libs/crud-pro/models/TransactionPostgres.js +85 -0
- package/dist/libs/crud-pro/models/TransactionSqlServer.d.ts +34 -0
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +92 -0
- package/dist/libs/crud-pro/models/keys.d.ts +106 -0
- package/dist/libs/crud-pro/models/keys.js +149 -0
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.d.ts +11 -0
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +73 -0
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.d.ts +9 -0
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.js +112 -0
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.d.ts +17 -0
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +225 -0
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.d.ts +9 -0
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.js +51 -0
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.d.ts +13 -0
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.js +148 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +24 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +340 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlService.d.ts +25 -0
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +165 -0
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.d.ts +32 -0
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +334 -0
- package/dist/libs/crud-pro/services/CrudProServiceBase.d.ts +24 -0
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +90 -0
- package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +9 -0
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +78 -0
- package/dist/libs/crud-pro/services/CurdProServiceHub.d.ts +32 -0
- package/dist/libs/crud-pro/services/CurdProServiceHub.js +64 -0
- package/dist/libs/crud-pro/sql.txt +120 -0
- package/dist/libs/crud-pro/utils/CompareUtils.d.ts +9 -0
- package/dist/libs/crud-pro/utils/CompareUtils.js +25 -0
- package/dist/libs/crud-pro/utils/DatabaseName.d.ts +9 -0
- package/dist/libs/crud-pro/utils/DatabaseName.js +50 -0
- package/dist/libs/crud-pro/utils/DateTimeUtils.d.ts +7 -0
- package/dist/libs/crud-pro/utils/DateTimeUtils.js +21 -0
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.d.ts +19 -0
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.js +47 -0
- package/dist/libs/crud-pro/utils/MessageParseUtils.d.ts +5 -0
- package/dist/libs/crud-pro/utils/MessageParseUtils.js +33 -0
- package/dist/libs/crud-pro/utils/MixinUtils.d.ts +39 -0
- package/dist/libs/crud-pro/utils/MixinUtils.js +255 -0
- package/dist/libs/crud-pro/utils/ModelUtils.d.ts +11 -0
- package/dist/libs/crud-pro/utils/ModelUtils.js +49 -0
- package/dist/libs/crud-pro/utils/MultiKeyMap.d.ts +11 -0
- package/dist/libs/crud-pro/utils/MultiKeyMap.js +63 -0
- package/dist/libs/crud-pro/utils/SqlFuncUtils.d.ts +5 -0
- package/dist/libs/crud-pro/utils/SqlFuncUtils.js +29 -0
- package/dist/libs/crud-pro/utils/TypeUtils.d.ts +40 -0
- package/dist/libs/crud-pro/utils/TypeUtils.js +166 -0
- package/dist/libs/crud-pro/utils/ValidateUtils.d.ts +3 -0
- package/dist/libs/crud-pro/utils/ValidateUtils.js +165 -0
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.d.ts +3 -0
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.js +19 -0
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.d.ts +3 -0
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.js +20 -0
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.d.ts +3 -0
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.js +20 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.d.ts +4 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +21 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.d.ts +3 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.js +22 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.d.ts +2 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.js +11 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.d.ts +2 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.js +11 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.d.ts +2 -0
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.js +128 -0
- package/dist/libs/global-config/global-config.d.ts +45 -0
- package/dist/libs/global-config/global-config.js +33 -0
- package/dist/libs/utils/common-dto.d.ts +18 -0
- package/dist/libs/utils/common-dto.js +40 -0
- package/dist/libs/utils/crypto-utils.d.ts +3 -0
- package/dist/libs/utils/crypto-utils.js +46 -0
- package/dist/libs/utils/errorToString.d.ts +2 -0
- package/dist/libs/utils/errorToString.js +57 -0
- package/dist/libs/utils/fatcms-request.d.ts +30 -0
- package/dist/libs/utils/fatcms-request.js +104 -0
- package/dist/libs/utils/functions.d.ts +5 -0
- package/dist/libs/utils/functions.js +68 -0
- package/dist/libs/utils/ordernum-utils.d.ts +2 -0
- package/dist/libs/utils/ordernum-utils.js +13 -0
- package/dist/libs/utils/parseConfig.d.ts +7 -0
- package/dist/libs/utils/parseConfig.js +44 -0
- package/dist/libs/utils/parseCreateSql.d.ts +5 -0
- package/dist/libs/utils/parseCreateSql.js +86 -0
- package/dist/libs/utils/render-utils.d.ts +28 -0
- package/dist/libs/utils/render-utils.js +135 -0
- package/dist/middleware/forbidden.middleware.d.ts +10 -0
- package/dist/middleware/forbidden.middleware.js +54 -0
- package/dist/middleware/global.middleware.d.ts +10 -0
- package/dist/middleware/global.middleware.js +266 -0
- package/dist/middleware/permission.middleware.d.ts +18 -0
- package/dist/middleware/permission.middleware.js +74 -0
- package/dist/middleware/tx.middleware.d.ts +9 -0
- package/dist/middleware/tx.middleware.js +40 -0
- package/dist/models/AsyncTaskModel.d.ts +74 -0
- package/dist/models/AsyncTaskModel.js +31 -0
- package/dist/models/RedisKeys.d.ts +14 -0
- package/dist/models/RedisKeys.js +17 -0
- package/dist/models/SystemEntities.d.ts +98 -0
- package/dist/models/SystemEntities.js +2 -0
- package/dist/models/SystemPerm.d.ts +95 -0
- package/dist/models/SystemPerm.js +100 -0
- package/dist/models/SystemTables.d.ts +25 -0
- package/dist/models/SystemTables.js +28 -0
- package/dist/models/bizmodels.d.ts +97 -0
- package/dist/models/bizmodels.js +39 -0
- package/dist/models/contextLogger.d.ts +25 -0
- package/dist/models/contextLogger.js +112 -0
- package/dist/models/devops.d.ts +12 -0
- package/dist/models/devops.js +19 -0
- package/dist/models/userSession.d.ts +61 -0
- package/dist/models/userSession.js +165 -0
- package/dist/schedule/anonymousContext.d.ts +14 -0
- package/dist/schedule/anonymousContext.js +59 -0
- package/dist/schedule/index.d.ts +4 -0
- package/dist/schedule/index.js +10 -0
- package/dist/schedule/runSchedule.d.ts +12 -0
- package/dist/schedule/runSchedule.js +68 -0
- package/dist/schedule/scheduleNames.d.ts +13 -0
- package/dist/schedule/scheduleNames.js +17 -0
- package/dist/service/AuthService.d.ts +70 -0
- package/dist/service/AuthService.js +251 -0
- package/dist/service/EnumInfoService.d.ts +30 -0
- package/dist/service/EnumInfoService.js +127 -0
- package/dist/service/FileCenterService.d.ts +43 -0
- package/dist/service/FileCenterService.js +351 -0
- package/dist/service/SysConfigService.d.ts +7 -0
- package/dist/service/SysConfigService.js +47 -0
- package/dist/service/UserAccountService.d.ts +23 -0
- package/dist/service/UserAccountService.js +107 -0
- package/dist/service/UserSessionService.d.ts +37 -0
- package/dist/service/UserSessionService.js +156 -0
- package/dist/service/VisitStatService.d.ts +14 -0
- package/dist/service/VisitStatService.js +158 -0
- package/dist/service/WorkbenchService.d.ts +52 -0
- package/dist/service/WorkbenchService.js +202 -0
- package/dist/service/anyapi/AnyApiSandboxService.d.ts +15 -0
- package/dist/service/anyapi/AnyApiSandboxService.js +122 -0
- package/dist/service/anyapi/AnyApiService.d.ts +27 -0
- package/dist/service/anyapi/AnyApiService.js +181 -0
- package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +50 -0
- package/dist/service/asyncTask/AsyncTaskRunnerService.js +287 -0
- package/dist/service/asyncTask/AsyncTaskService.d.ts +7 -0
- package/dist/service/asyncTask/AsyncTaskService.js +34 -0
- package/dist/service/asyncTask/handler/ExcelInfoModel.d.ts +10 -0
- package/dist/service/asyncTask/handler/ExcelInfoModel.js +2 -0
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.d.ts +7 -0
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.js +216 -0
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.d.ts +36 -0
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.js +139 -0
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.d.ts +46 -0
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.js +121 -0
- package/dist/service/base/ApiBaseService.d.ts +15 -0
- package/dist/service/base/ApiBaseService.js +50 -0
- package/dist/service/base/ApiRateLimiter.d.ts +10 -0
- package/dist/service/base/ApiRateLimiter.js +51 -0
- package/dist/service/base/BaseService.d.ts +41 -0
- package/dist/service/base/BaseService.js +101 -0
- package/dist/service/base/RedisCacheService.d.ts +20 -0
- package/dist/service/base/RedisCacheService.js +57 -0
- package/dist/service/crudstd/CrudStdActionService.d.ts +17 -0
- package/dist/service/crudstd/CrudStdActionService.js +32 -0
- package/dist/service/crudstd/CrudStdConstant.d.ts +58 -0
- package/dist/service/crudstd/CrudStdConstant.js +64 -0
- package/dist/service/crudstd/CrudStdRelationService.d.ts +10 -0
- package/dist/service/crudstd/CrudStdRelationService.js +85 -0
- package/dist/service/crudstd/CrudStdService.d.ts +57 -0
- package/dist/service/crudstd/CrudStdService.js +239 -0
- package/dist/service/curd/CrudProQuick.d.ts +44 -0
- package/dist/service/curd/CrudProQuick.js +147 -0
- package/dist/service/curd/CurdMixByAccountService.d.ts +9 -0
- package/dist/service/curd/CurdMixByAccountService.js +93 -0
- package/dist/service/curd/CurdMixByDictService.d.ts +13 -0
- package/dist/service/curd/CurdMixByDictService.js +114 -0
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +31 -0
- package/dist/service/curd/CurdMixByLinkToCustomService.js +203 -0
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +9 -0
- package/dist/service/curd/CurdMixBySysConfigService.js +80 -0
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +10 -0
- package/dist/service/curd/CurdMixByWorkbenchService.js +78 -0
- package/dist/service/curd/CurdMixService.d.ts +27 -0
- package/dist/service/curd/CurdMixService.js +100 -0
- package/dist/service/curd/CurdMixUtils.d.ts +51 -0
- package/dist/service/curd/CurdMixUtils.js +275 -0
- package/dist/service/curd/CurdProService.d.ts +32 -0
- package/dist/service/curd/CurdProService.js +210 -0
- package/dist/service/curd/fixCfgModel.d.ts +3 -0
- package/dist/service/curd/fixCfgModel.js +107 -0
- package/dist/service/proxyapi/ProxyApiLoadService.d.ts +21 -0
- package/dist/service/proxyapi/ProxyApiLoadService.js +167 -0
- package/dist/service/proxyapi/ProxyApiService.d.ts +60 -0
- package/dist/service/proxyapi/ProxyApiService.js +260 -0
- package/dist/service/proxyapi/ProxyApiUtils.d.ts +15 -0
- package/dist/service/proxyapi/ProxyApiUtils.js +34 -0
- package/dist/service/proxyapi/RouteHandler.d.ts +5 -0
- package/dist/service/proxyapi/RouteHandler.js +9 -0
- package/dist/service/proxyapi/RouteTrie.d.ts +12 -0
- package/dist/service/proxyapi/RouteTrie.js +63 -0
- package/dist/service/proxyapi/WeightedRandom.d.ts +9 -0
- package/dist/service/proxyapi/WeightedRandom.js +31 -0
- package/dist/service/proxyapi/WeightedRoundRobin.d.ts +8 -0
- package/dist/service/proxyapi/WeightedRoundRobin.js +32 -0
- 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 +1 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { IRequestCfgModel, IVisitor } from '../libs/crud-pro/interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* 实体表公共字段
|
|
4
|
+
*/
|
|
5
|
+
export interface IEntityCommonInfo {
|
|
6
|
+
id?: number;
|
|
7
|
+
created_by?: string;
|
|
8
|
+
modified_by?: string;
|
|
9
|
+
created_at?: string;
|
|
10
|
+
modified_at?: string;
|
|
11
|
+
status?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ITableBaseInfo {
|
|
14
|
+
databaseName: string;
|
|
15
|
+
tableName: string;
|
|
16
|
+
}
|
|
17
|
+
export interface IStdCrudCfgObj {
|
|
18
|
+
tableBaseInfo: ITableBaseInfo;
|
|
19
|
+
authSetting: any;
|
|
20
|
+
actionColumns?: any[];
|
|
21
|
+
queryFormFields?: any[];
|
|
22
|
+
tableColumns?: any[];
|
|
23
|
+
tableFields?: any[];
|
|
24
|
+
toolbarList?: any[];
|
|
25
|
+
}
|
|
26
|
+
export interface ICrudStdAppInfo {
|
|
27
|
+
app_code: string;
|
|
28
|
+
stdCrudCfgObj?: IStdCrudCfgObj;
|
|
29
|
+
actionsMap?: any;
|
|
30
|
+
status: number;
|
|
31
|
+
}
|
|
32
|
+
export interface ICrudStdAppInfoForSettingKey extends ICrudStdAppInfo {
|
|
33
|
+
settingKeyActionCfg?: any;
|
|
34
|
+
authConfig?: string[];
|
|
35
|
+
authType?: string;
|
|
36
|
+
}
|
|
37
|
+
export declare enum AccessType {
|
|
38
|
+
owner = "owner",
|
|
39
|
+
login = "login",
|
|
40
|
+
open = "open"
|
|
41
|
+
}
|
|
42
|
+
export declare enum UploadCategoryType {
|
|
43
|
+
file = "file",
|
|
44
|
+
assets = "assets"
|
|
45
|
+
}
|
|
46
|
+
export declare class PermFunc {
|
|
47
|
+
funcCode: string;
|
|
48
|
+
funcName: string;
|
|
49
|
+
constructor(funcCode: string, funcName: string);
|
|
50
|
+
}
|
|
51
|
+
export declare class PermRole {
|
|
52
|
+
roleCode: string;
|
|
53
|
+
roleName: string;
|
|
54
|
+
constructor(roleCode: string, roleName: string);
|
|
55
|
+
}
|
|
56
|
+
export declare const CTX_VISITOR_ID = "visitor.accountId";
|
|
57
|
+
export declare const CTX_VISITOR_AVATAR = "visitor.avatar";
|
|
58
|
+
export declare const CTX_VISITOR_NICKNAME = "visitor.nickName";
|
|
59
|
+
export declare const CTX_VISITOR_ACCOUNT_TYPE = "visitor.accountType";
|
|
60
|
+
export declare const CTX_WORKBENCH_CODE = "visitor.workbenchCode";
|
|
61
|
+
export interface IRequestCfgModel2 extends IRequestCfgModel {
|
|
62
|
+
enableStandardUpdateCfg?: boolean | string[];
|
|
63
|
+
enableStandardUpdateCfgCondition?: boolean | string[];
|
|
64
|
+
}
|
|
65
|
+
export interface IVisitorExt extends IVisitor {
|
|
66
|
+
workbenchCode: string;
|
|
67
|
+
avatar: string;
|
|
68
|
+
accountType: string;
|
|
69
|
+
}
|
|
70
|
+
export declare const FILE_GET_TYPES: string[];
|
|
71
|
+
/**
|
|
72
|
+
* fat-design中的TablePro组件的查询参数
|
|
73
|
+
*/
|
|
74
|
+
export interface ITableProQueryParams {
|
|
75
|
+
condition: any;
|
|
76
|
+
pageNo: number;
|
|
77
|
+
pageSize: number;
|
|
78
|
+
orderBy: string | any;
|
|
79
|
+
}
|
|
80
|
+
export declare enum StdCrudExportInputParamsAppType {
|
|
81
|
+
STD_CRUD = "STD_CRUD",
|
|
82
|
+
INNER_HTTP = "INNER_HTTP"
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* fat-design中的TablePro组件的查询参数
|
|
86
|
+
*/
|
|
87
|
+
export interface IStdCrudExportInputParams {
|
|
88
|
+
appType: StdCrudExportInputParamsAppType;
|
|
89
|
+
appCode?: string;
|
|
90
|
+
innerHttpUrl?: string;
|
|
91
|
+
columns?: any[];
|
|
92
|
+
lastQueryParams: ITableProQueryParams;
|
|
93
|
+
selectedRowKeys: string[] | number[];
|
|
94
|
+
headers: any;
|
|
95
|
+
primaryKey: any;
|
|
96
|
+
pageSize: number;
|
|
97
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StdCrudExportInputParamsAppType = exports.FILE_GET_TYPES = exports.CTX_WORKBENCH_CODE = exports.CTX_VISITOR_ACCOUNT_TYPE = exports.CTX_VISITOR_NICKNAME = exports.CTX_VISITOR_AVATAR = exports.CTX_VISITOR_ID = exports.PermRole = exports.PermFunc = exports.UploadCategoryType = exports.AccessType = void 0;
|
|
4
|
+
var AccessType;
|
|
5
|
+
(function (AccessType) {
|
|
6
|
+
AccessType["owner"] = "owner";
|
|
7
|
+
AccessType["login"] = "login";
|
|
8
|
+
AccessType["open"] = "open";
|
|
9
|
+
})(AccessType = exports.AccessType || (exports.AccessType = {}));
|
|
10
|
+
var UploadCategoryType;
|
|
11
|
+
(function (UploadCategoryType) {
|
|
12
|
+
UploadCategoryType["file"] = "file";
|
|
13
|
+
UploadCategoryType["assets"] = "assets";
|
|
14
|
+
})(UploadCategoryType = exports.UploadCategoryType || (exports.UploadCategoryType = {}));
|
|
15
|
+
class PermFunc {
|
|
16
|
+
constructor(funcCode, funcName) {
|
|
17
|
+
this.funcName = funcName;
|
|
18
|
+
this.funcCode = funcCode;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.PermFunc = PermFunc;
|
|
22
|
+
class PermRole {
|
|
23
|
+
constructor(roleCode, roleName) {
|
|
24
|
+
this.roleName = roleName;
|
|
25
|
+
this.roleCode = roleCode;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.PermRole = PermRole;
|
|
29
|
+
exports.CTX_VISITOR_ID = 'visitor.accountId';
|
|
30
|
+
exports.CTX_VISITOR_AVATAR = 'visitor.avatar';
|
|
31
|
+
exports.CTX_VISITOR_NICKNAME = 'visitor.nickName';
|
|
32
|
+
exports.CTX_VISITOR_ACCOUNT_TYPE = 'visitor.accountType';
|
|
33
|
+
exports.CTX_WORKBENCH_CODE = 'visitor.workbenchCode';
|
|
34
|
+
exports.FILE_GET_TYPES = ['thumbnail', 'preview', 'download'];
|
|
35
|
+
var StdCrudExportInputParamsAppType;
|
|
36
|
+
(function (StdCrudExportInputParamsAppType) {
|
|
37
|
+
StdCrudExportInputParamsAppType["STD_CRUD"] = "STD_CRUD";
|
|
38
|
+
StdCrudExportInputParamsAppType["INNER_HTTP"] = "INNER_HTTP";
|
|
39
|
+
})(StdCrudExportInputParamsAppType = exports.StdCrudExportInputParamsAppType || (exports.StdCrudExportInputParamsAppType = {}));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ILogger } from '@midwayjs/core';
|
|
2
|
+
import { Context } from '@midwayjs/koa';
|
|
3
|
+
interface ILoggerContext extends ILogger {
|
|
4
|
+
log(msg: any, ...args: any[]): void;
|
|
5
|
+
}
|
|
6
|
+
declare const consoleLogger: ILoggerContext;
|
|
7
|
+
/**
|
|
8
|
+
* 每个Context请求,都会创建一个新的ContextLogger对象
|
|
9
|
+
*/
|
|
10
|
+
declare class ContextLogger implements ILoggerContext {
|
|
11
|
+
private readonly ctx;
|
|
12
|
+
private readonly app;
|
|
13
|
+
private readonly logList;
|
|
14
|
+
constructor(ctx: Context);
|
|
15
|
+
getLogList(): any;
|
|
16
|
+
debug(msg: any, ...args: any[]): void;
|
|
17
|
+
error(msg: any, ...args: any[]): void;
|
|
18
|
+
info(msg: any, ...args: any[]): void;
|
|
19
|
+
warn(msg: any, ...args: any[]): void;
|
|
20
|
+
log(msg: any, ...args: any[]): void;
|
|
21
|
+
private appendLogList;
|
|
22
|
+
private getLogger;
|
|
23
|
+
getPrefixContextLogger(prefix: string): ILoggerContext;
|
|
24
|
+
}
|
|
25
|
+
export { ContextLogger, consoleLogger, ILoggerContext };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.consoleLogger = exports.ContextLogger = void 0;
|
|
4
|
+
const moment = require("moment");
|
|
5
|
+
const fatcms_request_1 = require("../libs/utils/fatcms-request");
|
|
6
|
+
const consoleLogger = {
|
|
7
|
+
info: (msg, ...args) => {
|
|
8
|
+
console.info(msg, ...args);
|
|
9
|
+
},
|
|
10
|
+
debug: (msg, ...args) => {
|
|
11
|
+
console.debug(msg, ...args);
|
|
12
|
+
},
|
|
13
|
+
error: (msg, ...args) => {
|
|
14
|
+
console.error(msg, ...args);
|
|
15
|
+
},
|
|
16
|
+
warn: (msg, ...args) => {
|
|
17
|
+
console.warn(msg, ...args);
|
|
18
|
+
},
|
|
19
|
+
log: (msg, ...args) => {
|
|
20
|
+
console.log(msg, ...args);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
exports.consoleLogger = consoleLogger;
|
|
24
|
+
function getCallerInfo() {
|
|
25
|
+
// 创建一个新的 Error 对象
|
|
26
|
+
const error = new Error();
|
|
27
|
+
// 获取调用栈信息
|
|
28
|
+
const stack = error.stack.split('\n');
|
|
29
|
+
// 跳过前几行
|
|
30
|
+
const callerLine = stack[4];
|
|
31
|
+
// 提取文件名和行号
|
|
32
|
+
const match = callerLine.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);
|
|
33
|
+
if (match) {
|
|
34
|
+
return {
|
|
35
|
+
functionName: match[1],
|
|
36
|
+
fileName: match[2],
|
|
37
|
+
lineNumber: parseInt(match[3]),
|
|
38
|
+
columnNumber: parseInt(match[4]),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 每个Context请求,都会创建一个新的ContextLogger对象
|
|
45
|
+
*/
|
|
46
|
+
class ContextLogger {
|
|
47
|
+
constructor(ctx) {
|
|
48
|
+
this.logList = [];
|
|
49
|
+
this.app = ctx.app;
|
|
50
|
+
this.ctx = ctx;
|
|
51
|
+
this.logList = [];
|
|
52
|
+
}
|
|
53
|
+
getLogList() {
|
|
54
|
+
return this.logList;
|
|
55
|
+
}
|
|
56
|
+
debug(msg, ...args) {
|
|
57
|
+
this.getLogger().debug(msg, ...args);
|
|
58
|
+
this.appendLogList('debug', msg, ...args);
|
|
59
|
+
}
|
|
60
|
+
error(msg, ...args) {
|
|
61
|
+
this.getLogger().error(msg, ...args);
|
|
62
|
+
this.appendLogList('error', msg, ...args);
|
|
63
|
+
}
|
|
64
|
+
info(msg, ...args) {
|
|
65
|
+
this.getLogger().info(msg, ...args);
|
|
66
|
+
this.appendLogList('info', msg, ...args);
|
|
67
|
+
}
|
|
68
|
+
warn(msg, ...args) {
|
|
69
|
+
this.getLogger().warn(msg, ...args);
|
|
70
|
+
this.appendLogList('warn', msg, ...args);
|
|
71
|
+
}
|
|
72
|
+
log(msg, ...args) {
|
|
73
|
+
this.getLogger().info(msg, ...args);
|
|
74
|
+
this.appendLogList('info', msg, ...args);
|
|
75
|
+
}
|
|
76
|
+
appendLogList(level, msg, ...args) {
|
|
77
|
+
const ctx = this.ctx;
|
|
78
|
+
if (!(0, fatcms_request_1.isEnableDebug)(ctx)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const time = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
82
|
+
const caller = getCallerInfo();
|
|
83
|
+
this.logList.push({ level, msg, args, caller, time });
|
|
84
|
+
}
|
|
85
|
+
getLogger() {
|
|
86
|
+
const logger = this.app.getLogger('logger');
|
|
87
|
+
if (logger) {
|
|
88
|
+
return logger;
|
|
89
|
+
}
|
|
90
|
+
return consoleLogger;
|
|
91
|
+
}
|
|
92
|
+
getPrefixContextLogger(prefix) {
|
|
93
|
+
return {
|
|
94
|
+
info: (msg, ...args) => {
|
|
95
|
+
this.info(prefix, msg, ...args);
|
|
96
|
+
},
|
|
97
|
+
debug: (msg, ...args) => {
|
|
98
|
+
this.debug(prefix, msg, ...args);
|
|
99
|
+
},
|
|
100
|
+
error: (msg, ...args) => {
|
|
101
|
+
this.error(prefix, msg, ...args);
|
|
102
|
+
},
|
|
103
|
+
warn: (msg, ...args) => {
|
|
104
|
+
this.warn(prefix, msg, ...args);
|
|
105
|
+
},
|
|
106
|
+
log: (msg, ...args) => {
|
|
107
|
+
this.log(prefix, msg, ...args);
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.ContextLogger = ContextLogger;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BizException = exports.CommonStatusEnum = void 0;
|
|
4
|
+
// 状态;0 未启用, 1 已启用',
|
|
5
|
+
var CommonStatusEnum;
|
|
6
|
+
(function (CommonStatusEnum) {
|
|
7
|
+
CommonStatusEnum[CommonStatusEnum["DISABLED"] = 0] = "DISABLED";
|
|
8
|
+
CommonStatusEnum[CommonStatusEnum["ENABLED"] = 1] = "ENABLED";
|
|
9
|
+
})(CommonStatusEnum = exports.CommonStatusEnum || (exports.CommonStatusEnum = {}));
|
|
10
|
+
/**
|
|
11
|
+
* 业务异常
|
|
12
|
+
*/
|
|
13
|
+
class BizException {
|
|
14
|
+
constructor(message, code) {
|
|
15
|
+
this.message = message;
|
|
16
|
+
this.code = code || 'BizException';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.BizException = BizException;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { KeysOfAuthType } from '../libs/crud-pro/models/keys';
|
|
2
|
+
declare const sessionCookieCfg: {
|
|
3
|
+
signed: boolean;
|
|
4
|
+
encrypt: boolean;
|
|
5
|
+
httpOnly: boolean;
|
|
6
|
+
maxAge: number;
|
|
7
|
+
};
|
|
8
|
+
declare const SESSION_ID_KEY = "fatcmssessionid";
|
|
9
|
+
declare const SYS_ACCOUNT_TYPE = "fatcms";
|
|
10
|
+
interface ISessionInfo {
|
|
11
|
+
nickName: string;
|
|
12
|
+
avatar: string;
|
|
13
|
+
roleCodes: string[];
|
|
14
|
+
functionCodes: string[];
|
|
15
|
+
loginName: string;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
accountId: string;
|
|
18
|
+
workbenchCode: string;
|
|
19
|
+
accountType: string;
|
|
20
|
+
}
|
|
21
|
+
interface IConsumerUserInfo {
|
|
22
|
+
workbenchCode: string;
|
|
23
|
+
accountType: string;
|
|
24
|
+
accountId: string;
|
|
25
|
+
nickName: string;
|
|
26
|
+
loginName: string;
|
|
27
|
+
avatar: string;
|
|
28
|
+
}
|
|
29
|
+
interface IBatchCheckProps {
|
|
30
|
+
permissionCodeList?: string[];
|
|
31
|
+
roleCodeList?: string[];
|
|
32
|
+
}
|
|
33
|
+
interface IBatchCheckRes {
|
|
34
|
+
permissionCodeResult: Record<string, boolean>;
|
|
35
|
+
roleCodeResult: Record<string, boolean>;
|
|
36
|
+
}
|
|
37
|
+
declare class UserSessionInfo {
|
|
38
|
+
private readonly sessionInfo;
|
|
39
|
+
private readonly superAdmin;
|
|
40
|
+
constructor(sessionInfo: ISessionInfo, superAdmin?: boolean);
|
|
41
|
+
getSessionInfo(): ISessionInfo;
|
|
42
|
+
getSessionValue(key: string): any;
|
|
43
|
+
isSuperAdmin(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* 是否是我自己的账号
|
|
46
|
+
* @param accountId
|
|
47
|
+
*/
|
|
48
|
+
isMySelf(accountId: string): boolean;
|
|
49
|
+
isLogin(): boolean;
|
|
50
|
+
hasAnyPermission(funcCodeList: string | string[]): boolean;
|
|
51
|
+
hasPermission(funcCode: string): boolean;
|
|
52
|
+
hasAnyRole(roleCodeList: string | string[]): boolean;
|
|
53
|
+
hasRole(roleCode: string): boolean;
|
|
54
|
+
isAuthPass(authType: KeysOfAuthType, authConfig: string | string[]): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* 批量检查权限
|
|
57
|
+
* @param params
|
|
58
|
+
*/
|
|
59
|
+
batchCheckPermission(params: IBatchCheckProps): IBatchCheckRes;
|
|
60
|
+
}
|
|
61
|
+
export { ISessionInfo, UserSessionInfo, SESSION_ID_KEY, SYS_ACCOUNT_TYPE, IConsumerUserInfo, sessionCookieCfg };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sessionCookieCfg = exports.SYS_ACCOUNT_TYPE = exports.SESSION_ID_KEY = exports.UserSessionInfo = void 0;
|
|
4
|
+
const _ = require("lodash");
|
|
5
|
+
const keys_1 = require("../libs/crud-pro/models/keys");
|
|
6
|
+
const MixinUtils_1 = require("../libs/crud-pro/utils/MixinUtils");
|
|
7
|
+
const exceptions_1 = require("../libs/crud-pro/exceptions");
|
|
8
|
+
const functions_1 = require("../libs/utils/functions");
|
|
9
|
+
const sessionCookieCfg = {
|
|
10
|
+
signed: true,
|
|
11
|
+
encrypt: true,
|
|
12
|
+
httpOnly: true,
|
|
13
|
+
maxAge: 1000 * 3600 * 24 * 365,
|
|
14
|
+
};
|
|
15
|
+
exports.sessionCookieCfg = sessionCookieCfg;
|
|
16
|
+
const SESSION_ID_KEY = 'fatcmssessionid';
|
|
17
|
+
exports.SESSION_ID_KEY = SESSION_ID_KEY;
|
|
18
|
+
const SYS_ACCOUNT_TYPE = 'fatcms';
|
|
19
|
+
exports.SYS_ACCOUNT_TYPE = SYS_ACCOUNT_TYPE;
|
|
20
|
+
function createEmptySessionInfo(superAdmin) {
|
|
21
|
+
return {
|
|
22
|
+
nickName: superAdmin ? 'SA' : '',
|
|
23
|
+
avatar: '',
|
|
24
|
+
roleCodes: [],
|
|
25
|
+
functionCodes: [],
|
|
26
|
+
loginName: '',
|
|
27
|
+
sessionId: '',
|
|
28
|
+
accountId: '',
|
|
29
|
+
workbenchCode: '',
|
|
30
|
+
accountType: '',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
class UserSessionInfo {
|
|
34
|
+
constructor(sessionInfo, superAdmin) {
|
|
35
|
+
this.superAdmin = superAdmin === true;
|
|
36
|
+
if (sessionInfo) {
|
|
37
|
+
this.sessionInfo = sessionInfo;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.sessionInfo = createEmptySessionInfo(superAdmin);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
getSessionInfo() {
|
|
44
|
+
return this.sessionInfo;
|
|
45
|
+
}
|
|
46
|
+
getSessionValue(key) {
|
|
47
|
+
return _.get(this.sessionInfo, key);
|
|
48
|
+
}
|
|
49
|
+
isSuperAdmin() {
|
|
50
|
+
return this.superAdmin;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 是否是我自己的账号
|
|
54
|
+
* @param accountId
|
|
55
|
+
*/
|
|
56
|
+
isMySelf(accountId) {
|
|
57
|
+
const s = this.sessionInfo;
|
|
58
|
+
return s && accountId && s.accountId === accountId;
|
|
59
|
+
}
|
|
60
|
+
isLogin() {
|
|
61
|
+
const s = this.sessionInfo;
|
|
62
|
+
return !!(s && s.sessionId && s.accountId && s.sessionId.length > 1);
|
|
63
|
+
}
|
|
64
|
+
hasAnyPermission(funcCodeList) {
|
|
65
|
+
if (this.isSuperAdmin()) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if (typeof funcCodeList === 'string') {
|
|
69
|
+
return this.hasPermission(funcCodeList);
|
|
70
|
+
}
|
|
71
|
+
if (Array.isArray(funcCodeList)) {
|
|
72
|
+
for (let i = 0; i < funcCodeList.length; i++) {
|
|
73
|
+
const funcCode = funcCodeList[i];
|
|
74
|
+
if (this.hasPermission(funcCode)) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
hasPermission(funcCode) {
|
|
82
|
+
if (this.isSuperAdmin()) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
const ss = this.sessionInfo.functionCodes || [];
|
|
86
|
+
return ss.includes(funcCode);
|
|
87
|
+
}
|
|
88
|
+
hasAnyRole(roleCodeList) {
|
|
89
|
+
if (this.isSuperAdmin()) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
if (typeof roleCodeList === 'string') {
|
|
93
|
+
return this.hasRole(roleCodeList);
|
|
94
|
+
}
|
|
95
|
+
if (Array.isArray(roleCodeList)) {
|
|
96
|
+
for (let i = 0; i < roleCodeList.length; i++) {
|
|
97
|
+
const funcCode = roleCodeList[i];
|
|
98
|
+
if (this.hasRole(funcCode)) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
hasRole(roleCode) {
|
|
106
|
+
if (this.isSuperAdmin()) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
const ss = this.sessionInfo.roleCodes || [];
|
|
110
|
+
return ss.includes(roleCode);
|
|
111
|
+
}
|
|
112
|
+
isAuthPass(authType, authConfig) {
|
|
113
|
+
if (authType === keys_1.KeysOfAuthType.free || !authType) {
|
|
114
|
+
return true; // 无需校验
|
|
115
|
+
}
|
|
116
|
+
if (!this.isLogin()) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (this.isSuperAdmin()) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
if (authType === keys_1.KeysOfAuthType.byFuncCode) {
|
|
123
|
+
const funcCodes = (0, functions_1.parseStringTrimArray)(authConfig);
|
|
124
|
+
if (MixinUtils_1.MixinUtils.isEmpty(funcCodes)) {
|
|
125
|
+
throw new exceptions_1.CommonException(exceptions_1.Exceptions.CFG_AUTH_CODE_EMPTY, '缺少权限编码配置');
|
|
126
|
+
}
|
|
127
|
+
return this.hasAnyPermission(funcCodes);
|
|
128
|
+
}
|
|
129
|
+
if (authType === keys_1.KeysOfAuthType.byRoleCode) {
|
|
130
|
+
const roleCodes = (0, functions_1.parseStringTrimArray)(authConfig);
|
|
131
|
+
if (MixinUtils_1.MixinUtils.isEmpty(roleCodes)) {
|
|
132
|
+
throw new exceptions_1.CommonException(exceptions_1.Exceptions.CFG_AUTH_CODE_EMPTY, '缺少角色编码配置');
|
|
133
|
+
}
|
|
134
|
+
return this.hasAnyRole(roleCodes);
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* 批量检查权限
|
|
140
|
+
* @param params
|
|
141
|
+
*/
|
|
142
|
+
batchCheckPermission(params) {
|
|
143
|
+
const { permissionCodeList, roleCodeList } = params;
|
|
144
|
+
const permissionCodeResult = {};
|
|
145
|
+
const roleCodeResult = {};
|
|
146
|
+
if (Array.isArray(permissionCodeList)) {
|
|
147
|
+
for (let i = 0; i < permissionCodeList.length; i++) {
|
|
148
|
+
const permissionCode = permissionCodeList[i];
|
|
149
|
+
if (permissionCode && typeof permissionCode === 'string') {
|
|
150
|
+
permissionCodeResult[permissionCode] = this.hasPermission(permissionCode);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (Array.isArray(roleCodeList)) {
|
|
155
|
+
for (let i = 0; i < roleCodeList.length; i++) {
|
|
156
|
+
const roleCode = roleCodeList[i];
|
|
157
|
+
if (roleCode && typeof roleCode === 'string') {
|
|
158
|
+
roleCodeResult[roleCode] = this.hasRole(roleCode);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return { permissionCodeResult, roleCodeResult };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.UserSessionInfo = UserSessionInfo;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as koa from '@midwayjs/koa';
|
|
2
|
+
export declare type RunServiceAtAnonymousContextRunner = (ctx: koa.IMidwayKoaContext) => any;
|
|
3
|
+
export interface RunServiceAtAnonymousContextRes {
|
|
4
|
+
result: any;
|
|
5
|
+
error: any;
|
|
6
|
+
}
|
|
7
|
+
declare class AnonymousContext {
|
|
8
|
+
private app;
|
|
9
|
+
setApp(app: koa.Application): void;
|
|
10
|
+
getApp(): koa.IMidwayKoaApplication;
|
|
11
|
+
runServiceAtAnonymousContext(runner: RunServiceAtAnonymousContextRunner): Promise<RunServiceAtAnonymousContextRes>;
|
|
12
|
+
}
|
|
13
|
+
declare const ANONYMOUS_CONTEXT: AnonymousContext;
|
|
14
|
+
export { ANONYMOUS_CONTEXT };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ANONYMOUS_CONTEXT = void 0;
|
|
4
|
+
const contextLogger_1 = require("../models/contextLogger");
|
|
5
|
+
const Transaction_1 = require("../libs/crud-pro/models/Transaction");
|
|
6
|
+
const userSession_1 = require("../models/userSession");
|
|
7
|
+
const anonymousUserInfo = {
|
|
8
|
+
nickName: 'anonymous_user',
|
|
9
|
+
avatar: '',
|
|
10
|
+
roleCodes: [],
|
|
11
|
+
functionCodes: [],
|
|
12
|
+
loginName: 'anonymous_user',
|
|
13
|
+
sessionId: '',
|
|
14
|
+
accountId: '',
|
|
15
|
+
workbenchCode: '',
|
|
16
|
+
accountType: userSession_1.SYS_ACCOUNT_TYPE,
|
|
17
|
+
};
|
|
18
|
+
const anonymousWorkbenchInfo = {
|
|
19
|
+
id: 0,
|
|
20
|
+
workbench_code: 'anonymous_workbench',
|
|
21
|
+
workbench_name: 'anonymous_workbench',
|
|
22
|
+
workbench_domain: 'anonymous_workbench',
|
|
23
|
+
workbench_desc: 'anonymous_workbench',
|
|
24
|
+
html_content: 'anonymous_workbench',
|
|
25
|
+
status: 1,
|
|
26
|
+
workbench_type: 0,
|
|
27
|
+
};
|
|
28
|
+
class AnonymousContext {
|
|
29
|
+
setApp(app) {
|
|
30
|
+
this.app = app;
|
|
31
|
+
}
|
|
32
|
+
getApp() {
|
|
33
|
+
return this.app;
|
|
34
|
+
}
|
|
35
|
+
async runServiceAtAnonymousContext(runner) {
|
|
36
|
+
const app = this.app;
|
|
37
|
+
const ctx = app.createAnonymousContext();
|
|
38
|
+
ctx.app = app;
|
|
39
|
+
ctx.contextLogger = new contextLogger_1.ContextLogger(ctx);
|
|
40
|
+
ctx.transaction = new Transaction_1.Transaction();
|
|
41
|
+
ctx.userSession = new userSession_1.UserSessionInfo(anonymousUserInfo, true);
|
|
42
|
+
ctx.workbenchInfo = anonymousWorkbenchInfo;
|
|
43
|
+
let result = null;
|
|
44
|
+
let error = null;
|
|
45
|
+
try {
|
|
46
|
+
result = await runner(ctx);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
error = e;
|
|
50
|
+
ctx.logger.error('runServiceAtAnonymousContext error ', e);
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
await ctx.transaction.releaseTx();
|
|
54
|
+
}
|
|
55
|
+
return { result: result, error: error };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const ANONYMOUS_CONTEXT = new AnonymousContext();
|
|
59
|
+
exports.ANONYMOUS_CONTEXT = ANONYMOUS_CONTEXT;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SCHEDULE_QUEUE, runScheduleTaskOnce } from './runSchedule';
|
|
2
|
+
import { ANONYMOUS_CONTEXT } from './anonymousContext';
|
|
3
|
+
import { INNER_SCHEDULE_INTERVAL } from './scheduleNames';
|
|
4
|
+
export { INNER_SCHEDULE_INTERVAL, ANONYMOUS_CONTEXT, SCHEDULE_QUEUE, runScheduleTaskOnce };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runScheduleTaskOnce = exports.SCHEDULE_QUEUE = exports.ANONYMOUS_CONTEXT = exports.INNER_SCHEDULE_INTERVAL = void 0;
|
|
4
|
+
const runSchedule_1 = require("./runSchedule");
|
|
5
|
+
Object.defineProperty(exports, "SCHEDULE_QUEUE", { enumerable: true, get: function () { return runSchedule_1.SCHEDULE_QUEUE; } });
|
|
6
|
+
Object.defineProperty(exports, "runScheduleTaskOnce", { enumerable: true, get: function () { return runSchedule_1.runScheduleTaskOnce; } });
|
|
7
|
+
const anonymousContext_1 = require("./anonymousContext");
|
|
8
|
+
Object.defineProperty(exports, "ANONYMOUS_CONTEXT", { enumerable: true, get: function () { return anonymousContext_1.ANONYMOUS_CONTEXT; } });
|
|
9
|
+
const scheduleNames_1 = require("./scheduleNames");
|
|
10
|
+
Object.defineProperty(exports, "INNER_SCHEDULE_INTERVAL", { enumerable: true, get: function () { return scheduleNames_1.INNER_SCHEDULE_INTERVAL; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare function runScheduleTaskOnce(serviceName: string): Promise<import("./anonymousContext").RunServiceAtAnonymousContextRes>;
|
|
2
|
+
declare class ScheduleQueue {
|
|
3
|
+
private scheduleIntervalMap;
|
|
4
|
+
setScheduleTask(serviceName: string, intervalTime: number): void;
|
|
5
|
+
removeScheduleTask(serviceName: string): void;
|
|
6
|
+
private isAlreadyTimeToExecute;
|
|
7
|
+
private runScheduleTaskOnceCheckTime;
|
|
8
|
+
private runScheduleServiceList;
|
|
9
|
+
startScheduleLoop(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
declare const SCHEDULE_QUEUE: ScheduleQueue;
|
|
12
|
+
export { SCHEDULE_QUEUE, runScheduleTaskOnce };
|