midway-fatcms 0.0.1-beta.2 → 0.0.1-beta.20
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/.eslintrc.json +12 -0
- package/.prettierrc.js +4 -0
- package/README.md +7 -0
- package/dist/config/config.default.js +52 -15
- package/dist/configuration.d.ts +1 -0
- package/dist/configuration.js +33 -8
- package/dist/controller/base/BaseApiController.d.ts +1 -1
- package/dist/controller/base/BaseApiController.js +9 -6
- package/dist/controller/gateway/AsyncTaskController.d.ts +14 -0
- package/dist/controller/gateway/AsyncTaskController.js +108 -0
- package/dist/controller/gateway/CrudMtdGatewayController.d.ts +3 -3
- package/dist/controller/gateway/CrudMtdGatewayController.js +9 -6
- package/dist/controller/gateway/DocGatewayController.js +14 -9
- package/dist/controller/gateway/PublicApiController.js +4 -6
- package/dist/controller/gateway/StaticController.d.ts +2 -0
- package/dist/controller/gateway/StaticController.js +59 -40
- package/dist/controller/helpers.controller.d.ts +1 -1
- package/dist/controller/home.controller.js +2 -2
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +1 -1
- package/dist/controller/manage/CrudStandardDesignApi.js +78 -75
- package/dist/controller/manage/DataDictManageApi.d.ts +1 -1
- package/dist/controller/manage/DeployManageApi.d.ts +1 -1
- package/dist/controller/manage/DeployManageApi.js +38 -34
- package/dist/controller/manage/MenuManageApi.js +1 -1
- package/dist/controller/manage/SuperAdminManageApi.d.ts +2 -2
- package/dist/controller/manage/SuperAdminManageApi.js +12 -8
- package/dist/controller/manage/SysConfigMangeApi.d.ts +1 -1
- package/dist/controller/manage/SysConfigMangeApi.js +6 -4
- package/dist/controller/manage/SystemInfoManageApi.d.ts +1 -1
- package/dist/controller/manage/SystemInfoManageApi.js +7 -1
- package/dist/controller/manage/UserAccountManageApi.d.ts +2 -2
- package/dist/controller/manage/UserAccountManageApi.js +5 -0
- package/dist/controller/manage/WorkbenchMangeApi.js +1 -1
- package/dist/controller/myinfo/AuthController.d.ts +0 -4
- package/dist/controller/myinfo/AuthController.js +1 -54
- package/dist/controller/render/AppRenderController.js +10 -4
- package/dist/controller/test.controller.d.ts +1 -1
- package/dist/controller/test.controller.js +5 -5
- package/dist/index.d.ts +34 -4
- package/dist/index.js +34 -4
- package/dist/libs/crud-pro/CrudPro.d.ts +1 -0
- package/dist/libs/crud-pro/CrudPro.js +5 -0
- package/dist/libs/crud-pro/defaultConfigs.js +2 -0
- package/dist/libs/crud-pro/interfaces.d.ts +7 -1
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +2 -1
- package/dist/libs/crud-pro/models/ExecuteContextFunc.d.ts +8 -1
- package/dist/libs/crud-pro/models/ExecuteContextFunc.js +8 -0
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +1 -1
- 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/SqlCfgModel.d.ts +1 -1
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +1 -1
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.d.ts +1 -0
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +22 -11
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +10 -9
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +1 -1
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +10 -12
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +14 -23
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +7 -6
- package/dist/libs/crud-pro/services/CrudProServiceBase.d.ts +2 -6
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +3 -2
- package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +1 -0
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +31 -7
- package/dist/libs/crud-pro/utils/DatabaseName.js +24 -3
- package/dist/libs/crud-pro/utils/MixinUtils.js +1 -1
- package/dist/libs/crud-pro/utils/ValidateUtils.js +1 -1
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +2 -2
- 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/errorToString.d.ts +2 -0
- package/dist/libs/utils/errorToString.js +57 -0
- package/dist/libs/utils/fatcms-request.js +2 -2
- package/dist/middleware/forbidden.middleware.js +4 -20
- package/dist/middleware/global.middleware.js +8 -1
- package/dist/models/AsyncTaskModel.d.ts +69 -0
- package/dist/models/AsyncTaskModel.js +26 -0
- package/dist/models/RedisKeys.d.ts +8 -0
- package/dist/models/RedisKeys.js +11 -0
- package/dist/models/SystemTables.d.ts +1 -3
- package/dist/models/SystemTables.js +2 -4
- package/dist/schedule/anonymousContext.d.ts +13 -0
- package/dist/schedule/anonymousContext.js +59 -0
- package/dist/schedule/index.d.ts +4 -3
- package/dist/schedule/index.js +8 -67
- package/dist/schedule/runSchedule.d.ts +15 -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.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/UserSessionService.js +2 -1
- package/dist/service/VisitStatService.d.ts +1 -1
- package/dist/service/VisitStatService.js +20 -27
- package/dist/service/WorkbenchService.js +4 -2
- package/dist/service/anyapi/AnyApiService.js +4 -2
- package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +37 -0
- package/dist/service/asyncTask/AsyncTaskRunnerService.js +226 -0
- package/dist/service/asyncTask/AsyncTaskService.d.ts +7 -0
- package/dist/service/asyncTask/AsyncTaskService.js +34 -0
- package/dist/service/crudstd/CrudStdService.d.ts +1 -0
- package/dist/service/crudstd/CrudStdService.js +34 -3
- package/dist/service/curd/CrudProQuick.d.ts +24 -0
- package/dist/service/curd/CrudProQuick.js +105 -0
- package/dist/service/curd/CurdMixByAccountService.js +12 -6
- package/dist/service/curd/CurdMixByDictService.js +4 -2
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +10 -1
- package/dist/service/curd/CurdMixByLinkToCustomService.js +72 -24
- 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 +65 -28
- package/dist/service/curd/CurdProService.d.ts +2 -10
- package/dist/service/curd/CurdProService.js +31 -146
- package/dist/service/curd/fixCfgModel.d.ts +3 -0
- package/dist/service/curd/fixCfgModel.js +107 -0
- 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 +9 -2
- package/src/config/config.default.ts +58 -27
- package/src/configuration.ts +42 -9
- package/src/controller/base/BaseApiController.ts +19 -19
- package/src/controller/gateway/AnyApiGatewayController.ts +1 -1
- package/src/controller/gateway/AsyncTaskController.ts +83 -0
- package/src/controller/gateway/CrudMtdGatewayController.ts +17 -13
- package/src/controller/gateway/CrudStdGatewayController.ts +4 -4
- package/src/controller/gateway/DocGatewayController.ts +25 -17
- package/src/controller/gateway/FileController.ts +8 -9
- package/src/controller/gateway/ProxyApiGatewayController.ts +4 -4
- package/src/controller/gateway/PublicApiController.ts +19 -22
- package/src/controller/gateway/StaticController.ts +234 -242
- package/src/controller/helpers.controller.ts +1 -1
- package/src/controller/home.controller.ts +8 -15
- package/src/controller/manage/AnyApiMangeApi.ts +9 -9
- package/src/controller/manage/AppLogMangeApi.ts +3 -3
- package/src/controller/manage/AppMangeApi.ts +5 -5
- package/src/controller/manage/AppPageMangeApi.ts +3 -3
- package/src/controller/manage/AppSchemaHistoryApi.ts +1 -1
- package/src/controller/manage/CrudMethodsMangeApi.ts +3 -3
- package/src/controller/manage/CrudStandardDesignApi.ts +106 -113
- package/src/controller/manage/DataDictManageApi.ts +4 -4
- package/src/controller/manage/DeployManageApi.ts +85 -89
- package/src/controller/manage/DocLibManageApi.ts +3 -3
- package/src/controller/manage/DocManageApi.ts +8 -8
- package/src/controller/manage/MenuManageApi.ts +9 -14
- package/src/controller/manage/SuperAdminManageApi.ts +14 -13
- package/src/controller/manage/SysConfigMangeApi.ts +9 -9
- package/src/controller/manage/SystemInfoManageApi.ts +11 -6
- package/src/controller/manage/UserAccountManageApi.ts +8 -2
- package/src/controller/manage/WorkbenchMangeApi.ts +6 -6
- package/src/controller/myinfo/AuthController.ts +6 -72
- package/src/controller/render/AppRenderController.ts +24 -21
- package/src/controller/test.controller.ts +18 -18
- package/src/index.ts +38 -4
- package/src/libs/crud-pro/CrudPro.ts +7 -0
- package/src/libs/crud-pro/defaultConfigs.ts +2 -0
- package/src/libs/crud-pro/interfaces.ts +10 -3
- package/src/libs/crud-pro/models/ExecuteContext.ts +3 -3
- package/src/libs/crud-pro/models/ExecuteContextFunc.ts +11 -1
- package/src/libs/crud-pro/models/RequestCfgModel.ts +1 -1
- package/src/libs/crud-pro/models/RequestModel.ts +1 -1
- package/src/libs/crud-pro/models/ResModel.ts +19 -0
- package/src/libs/crud-pro/models/SqlCfgModel.ts +2 -2
- package/src/libs/crud-pro/models/Transaction.ts +8 -9
- package/src/libs/crud-pro/models/TransactionPostgres.ts +1 -1
- package/src/libs/crud-pro/models/TransactionSqlServer.ts +8 -13
- package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +26 -19
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +38 -50
- package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +26 -45
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +23 -40
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +25 -29
- package/src/libs/crud-pro/services/CrudProServiceBase.ts +5 -9
- package/src/libs/crud-pro/services/CrudProTableMetaService.ts +35 -9
- package/src/libs/crud-pro/utils/DatabaseName.ts +35 -15
- package/src/libs/crud-pro/utils/DateTimeUtils.ts +2 -2
- package/src/libs/crud-pro/utils/MixinUtils.ts +1 -1
- package/src/libs/crud-pro/utils/ValidateUtils.ts +1 -3
- package/src/libs/crud-pro/utils/pool/MySQLUtils.ts +1 -1
- package/src/libs/crud-pro/utils/pool/PostgresUtils.ts +3 -3
- package/src/libs/crud-pro/utils/pool/SqlServerUtils.ts +3 -3
- package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +2 -2
- package/src/libs/global-config/global-config.ts +78 -0
- package/src/libs/utils/crypto-utils.ts +2 -4
- package/src/libs/utils/errorToString.ts +61 -0
- package/src/libs/utils/fatcms-request.ts +9 -21
- package/src/libs/utils/ordernum-utils.ts +2 -6
- package/src/libs/utils/parseConfig.ts +7 -15
- package/src/middleware/forbidden.middleware.ts +6 -25
- package/src/middleware/global.middleware.ts +18 -16
- package/src/models/AsyncTaskModel.ts +79 -0
- package/src/models/RedisKeys.ts +13 -0
- package/src/models/SystemTables.ts +1 -4
- package/src/models/bizmodels.ts +1 -2
- package/src/schedule/anonymousContext.ts +79 -0
- package/src/schedule/index.ts +11 -72
- package/src/schedule/runSchedule.ts +83 -0
- package/src/schedule/scheduleNames.ts +21 -0
- 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/UserSessionService.ts +5 -4
- package/src/service/VisitStatService.ts +57 -70
- package/src/service/WorkbenchService.ts +7 -2
- package/src/service/anyapi/AnyApiService.ts +11 -8
- package/src/service/asyncTask/AsyncTaskRunnerService.ts +249 -0
- package/src/service/asyncTask/AsyncTaskService.ts +21 -0
- package/src/service/base/BaseService.ts +2 -2
- package/src/service/crudstd/CrudStdService.ts +43 -5
- package/src/service/curd/CrudProQuick.ts +137 -0
- package/src/service/curd/CurdMixByAccountService.ts +14 -6
- package/src/service/curd/CurdMixByDictService.ts +8 -2
- package/src/service/curd/CurdMixByLinkToCustomService.ts +101 -50
- package/src/service/curd/CurdMixBySysConfigService.ts +7 -2
- package/src/service/curd/CurdMixByWorkbenchService.ts +6 -2
- package/src/service/curd/CurdMixService.ts +3 -3
- package/src/service/curd/CurdMixUtils.ts +82 -39
- package/src/service/curd/CurdProService.ts +45 -189
- package/src/service/curd/fixCfgModel.ts +139 -0
- package/src/service/proxyapi/ProxyApiLoadService.ts +12 -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/tsconfig.json +32 -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
|
@@ -3,24 +3,25 @@ import { tmpdir } from 'os';
|
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
import { readFileSync } from 'fs';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
6
|
export default (appInfo: any) => {
|
|
9
7
|
return {
|
|
10
|
-
|
|
11
8
|
siteFile: {
|
|
12
9
|
favicon: readFileSync(join(__dirname, '../views/static/favicon.ico')),
|
|
13
10
|
},
|
|
14
11
|
|
|
15
|
-
encryptedFieldList: [
|
|
16
|
-
|
|
17
|
-
],
|
|
12
|
+
encryptedFieldList: [],
|
|
18
13
|
|
|
19
14
|
/**
|
|
20
15
|
* 内置超级管理员用户
|
|
21
16
|
* 可以使用这个工具生成:http://127.0.0.1:7002/ns/api/helpers/generateDatabasePassword?loginName=xxxx&pw0=xxxx
|
|
22
17
|
*/
|
|
23
|
-
superAdminList: [
|
|
18
|
+
superAdminList: [
|
|
19
|
+
{
|
|
20
|
+
pwd_salt: 'c837f8c6de7261de228ec58b1b3ca9fa1htbvgm88',
|
|
21
|
+
pwd_md5: 'e334410fca1fd49972f63bf91f3be1be',
|
|
22
|
+
login_name: 'superadmin',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
24
25
|
|
|
25
26
|
// use for cookie sign key, should change to your own and keep security
|
|
26
27
|
keys: '1715169944707_323',
|
|
@@ -40,7 +41,11 @@ export default (appInfo: any) => {
|
|
|
40
41
|
jsonLimit: '1mb',
|
|
41
42
|
textLimit: '1mb',
|
|
42
43
|
xmlLimit: '1mb',
|
|
43
|
-
ignore: [
|
|
44
|
+
ignore: [
|
|
45
|
+
'/ns/gw/proxy/*',
|
|
46
|
+
'/ns/gw/file/uploadFile',
|
|
47
|
+
'/ns/api/manage/deploy/uploadAssets',
|
|
48
|
+
], // 忽略代理路径的 body 解析
|
|
44
49
|
},
|
|
45
50
|
|
|
46
51
|
mysql2: {
|
|
@@ -57,7 +62,7 @@ export default (appInfo: any) => {
|
|
|
57
62
|
},
|
|
58
63
|
},
|
|
59
64
|
postgres2: {
|
|
60
|
-
|
|
65
|
+
postgres_test_fatcms_inner_demo_config: {
|
|
61
66
|
user: 'postgres',
|
|
62
67
|
host: '127.0.0.1',
|
|
63
68
|
database: 'postgres',
|
|
@@ -66,12 +71,11 @@ export default (appInfo: any) => {
|
|
|
66
71
|
max: 20, // 连接池最大连接数
|
|
67
72
|
idleTimeoutMillis: 30000, // 空闲连接超时时间(毫秒)
|
|
68
73
|
connectionTimeoutMillis: 2000, // 连接超时时间(毫秒)
|
|
69
|
-
}
|
|
74
|
+
},
|
|
70
75
|
},
|
|
71
76
|
|
|
72
|
-
|
|
73
77
|
sqlserver2: {
|
|
74
|
-
|
|
78
|
+
sqlserver_master_fatcms_inner_demo_config: {
|
|
75
79
|
user: 'sa',
|
|
76
80
|
password: '123456', // 你的SA密码
|
|
77
81
|
server: '127.0.0.1',
|
|
@@ -79,20 +83,20 @@ export default (appInfo: any) => {
|
|
|
79
83
|
database: 'master', // 默认数据库
|
|
80
84
|
options: {
|
|
81
85
|
encrypt: false, // Docker容器内通常不需要加密
|
|
82
|
-
trustServerCertificate: true // 信任自签名证书
|
|
86
|
+
trustServerCertificate: true, // 信任自签名证书
|
|
83
87
|
},
|
|
84
88
|
pool: {
|
|
85
|
-
max: 30,
|
|
86
|
-
min: 1,
|
|
87
|
-
idleTimeoutMillis: 30000
|
|
88
|
-
}
|
|
89
|
-
}
|
|
89
|
+
max: 30, // 最大连接数
|
|
90
|
+
min: 1, // 最小连接数
|
|
91
|
+
idleTimeoutMillis: 30000, // 连接空闲超时时间(毫秒)
|
|
92
|
+
},
|
|
93
|
+
},
|
|
90
94
|
},
|
|
91
95
|
|
|
92
96
|
redis: {
|
|
93
97
|
client: {
|
|
94
98
|
port: 6379, // Redis port
|
|
95
|
-
host:
|
|
99
|
+
host: '127.0.0.1', // Redis host
|
|
96
100
|
},
|
|
97
101
|
},
|
|
98
102
|
|
|
@@ -122,7 +126,34 @@ export default (appInfo: any) => {
|
|
|
122
126
|
fileSize: '20mb',
|
|
123
127
|
limit: '20mb',
|
|
124
128
|
// whitelist: string[],文件扩展名白名单
|
|
125
|
-
whitelist: [
|
|
129
|
+
whitelist: [
|
|
130
|
+
'.jpg',
|
|
131
|
+
'.jpeg',
|
|
132
|
+
'.png',
|
|
133
|
+
'.gif',
|
|
134
|
+
'.pdf',
|
|
135
|
+
'.zip',
|
|
136
|
+
'.xlsx',
|
|
137
|
+
'.docx',
|
|
138
|
+
'.pptx',
|
|
139
|
+
'.txt',
|
|
140
|
+
'.md',
|
|
141
|
+
'.json',
|
|
142
|
+
'.js',
|
|
143
|
+
'.cjs',
|
|
144
|
+
'.ejs',
|
|
145
|
+
'.jsx',
|
|
146
|
+
'.css',
|
|
147
|
+
'.java',
|
|
148
|
+
'.ts',
|
|
149
|
+
'.tsx',
|
|
150
|
+
'.less',
|
|
151
|
+
'.scss',
|
|
152
|
+
'.html',
|
|
153
|
+
'.ttf',
|
|
154
|
+
'.map',
|
|
155
|
+
'.svg',
|
|
156
|
+
],
|
|
126
157
|
// tmpdir: string,上传的文件临时存储路径
|
|
127
158
|
tmpdir: join(tmpdir(), 'fatcms-upload-files'),
|
|
128
159
|
// cleanTimeout: number,上传的文件在临时目录中多久之后自动删除,默认为 5 分钟
|
|
@@ -148,25 +179,25 @@ export default (appInfo: any) => {
|
|
|
148
179
|
ejs: {},
|
|
149
180
|
|
|
150
181
|
info: {
|
|
151
|
-
infoPath: `/_my_info_${Date.now()}_${Math.floor(
|
|
182
|
+
infoPath: `/_my_info_${Date.now()}_${Math.floor(
|
|
183
|
+
Math.random() * 1000000
|
|
184
|
+
)}`, // 实际上隐藏了info路径
|
|
152
185
|
},
|
|
153
186
|
|
|
154
187
|
// 使用浏览器插件配置header信息:插件名:ModHeader - Modify HTTP headers
|
|
155
188
|
// 默认值:配置key:fatcmsdebug, 配置value: headerSecret的值
|
|
156
189
|
fatcmsDebug: {
|
|
157
|
-
headerKey: '
|
|
158
|
-
headerSecret: '
|
|
190
|
+
headerKey: 'fatcmsDebug',
|
|
191
|
+
headerSecret: '111',
|
|
159
192
|
},
|
|
160
193
|
|
|
161
194
|
// 是否开启SA账号。只有账号密码没有用,必须通过ModHeader插件设置如下字段
|
|
162
195
|
fatcmsSAEnable: {
|
|
163
|
-
headerKey: '
|
|
164
|
-
headerSecret: '
|
|
196
|
+
headerKey: 'fatcmsSAEnable',
|
|
197
|
+
headerSecret: '222',
|
|
165
198
|
},
|
|
166
199
|
|
|
167
200
|
// 是否启用内置的定时任务
|
|
168
201
|
fatcmsScheduleService: true,
|
|
169
|
-
|
|
170
|
-
|
|
171
202
|
} as MidwayConfig;
|
|
172
203
|
};
|
package/src/configuration.ts
CHANGED
|
@@ -13,10 +13,11 @@ import { join } from 'path';
|
|
|
13
13
|
// import { NotFoundFilter } from './filter/notfound.filter';
|
|
14
14
|
import { GlobalMiddleware } from './middleware/global.middleware';
|
|
15
15
|
import { ForbiddenMiddleware } from './middleware/forbidden.middleware';
|
|
16
|
-
import {
|
|
16
|
+
import { SCHEDULE_QUEUE , ANONYMOUS_CONTEXT, INNER_SCHEDULE_INTERVAL } from './schedule';
|
|
17
17
|
import { privateAES } from './libs/utils/crypto-utils';
|
|
18
18
|
|
|
19
19
|
@Configuration({
|
|
20
|
+
// namespace: 'fatcms',
|
|
20
21
|
imports: [
|
|
21
22
|
koa,
|
|
22
23
|
validate,
|
|
@@ -62,16 +63,16 @@ export class ContainerLifeCycle {
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
async onReady() {
|
|
65
|
-
const logger = this.app.getLogger();
|
|
66
|
-
const config = this.app.getConfig();
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
logger.info('ContainerLifeCycle ==> onReady 启动定时任务 ' );
|
|
73
|
-
}
|
|
67
|
+
/**
|
|
68
|
+
* 让ANONYMOUS_CONTEXT获取app对象
|
|
69
|
+
*/
|
|
70
|
+
ANONYMOUS_CONTEXT.setApp(this.app);
|
|
74
71
|
|
|
72
|
+
/**
|
|
73
|
+
* 启动定时任务
|
|
74
|
+
*/
|
|
75
|
+
await this.startScheduleOnReady();
|
|
75
76
|
|
|
76
77
|
// add middleware
|
|
77
78
|
this.app.useMiddleware(ForbiddenMiddleware);
|
|
@@ -80,4 +81,36 @@ export class ContainerLifeCycle {
|
|
|
80
81
|
// add filter
|
|
81
82
|
// this.app.useFilter([NotFoundFilter, DefaultErrorFilter]);
|
|
82
83
|
}
|
|
84
|
+
|
|
85
|
+
private async startScheduleOnReady() {
|
|
86
|
+
const logger = this.app.getLogger();
|
|
87
|
+
const config = this.app.getConfig();
|
|
88
|
+
const fatcmsScheduleService: boolean | any = config.fatcmsScheduleService;
|
|
89
|
+
|
|
90
|
+
// 关闭定时任务
|
|
91
|
+
if (fatcmsScheduleService === false || fatcmsScheduleService === null) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let scheduleIntervalCfg = INNER_SCHEDULE_INTERVAL;
|
|
96
|
+
if (typeof fatcmsScheduleService === "object") {
|
|
97
|
+
scheduleIntervalCfg = fatcmsScheduleService
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const keys = Object.keys(scheduleIntervalCfg);
|
|
101
|
+
for (let i = 0; i < keys.length; i++) {
|
|
102
|
+
const service = keys[i];
|
|
103
|
+
const interval = scheduleIntervalCfg[service];
|
|
104
|
+
if (typeof interval !== "number") {
|
|
105
|
+
throw new Error('Invalid scheduleIntervalCfg ' + service + ", interval must be a number");
|
|
106
|
+
}
|
|
107
|
+
SCHEDULE_QUEUE.setScheduleTask(service, interval);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
await SCHEDULE_QUEUE.startScheduleLoop();
|
|
111
|
+
logger.info('ContainerLifeCycle ==> onReady 启动定时任务 : ' + JSON.stringify(scheduleIntervalCfg));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
83
116
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Controller, Inject } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { CurdMixService } from '
|
|
4
|
-
import { IFuncCfgModel, IRequestCfgModel, IValidatorCfgItem } from '
|
|
5
|
-
import {KeyOfCrudTypes, KeysOfSimpleSQL} from '
|
|
6
|
-
import {
|
|
7
|
-
import { UserAccountService } from '
|
|
8
|
-
import { RelatedType } from '
|
|
9
|
-
import { BaseService } from '
|
|
3
|
+
import { CurdMixService } from '@/service/curd/CurdMixService';
|
|
4
|
+
import { IFuncCfgModel, IRequestCfgModel, IValidatorCfgItem } from '@/libs/crud-pro/interfaces';
|
|
5
|
+
import { KeyOfCrudTypes, KeysOfSimpleSQL } from '@/libs/crud-pro/models/keys';
|
|
6
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
7
|
+
import { UserAccountService } from '@/service/UserAccountService';
|
|
8
|
+
import { RelatedType } from '@/service/curd/CurdMixUtils';
|
|
9
|
+
import { BaseService } from '@/service/base/BaseService';
|
|
10
10
|
|
|
11
11
|
export interface IExecuteSimpleSqlParams {
|
|
12
12
|
updateCfg?: Record<string, IFuncCfgModel>;
|
|
@@ -27,7 +27,6 @@ export class BaseApiController extends BaseService {
|
|
|
27
27
|
@Inject()
|
|
28
28
|
protected userAccountService: UserAccountService;
|
|
29
29
|
|
|
30
|
-
|
|
31
30
|
protected getUserSessionInfo() {
|
|
32
31
|
if (!this.ctx.userSession) {
|
|
33
32
|
return null;
|
|
@@ -35,16 +34,15 @@ export class BaseApiController extends BaseService {
|
|
|
35
34
|
return this.ctx.userSession.getSessionInfo();
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
async executeSysSQL(executeSql:string, executeSqlArgs: any[]){
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
);
|
|
37
|
+
async executeSysSQL(executeSql: string, executeSqlArgs: any[]) {
|
|
38
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
39
|
+
return await this.curdMixService.executeSQL({
|
|
40
|
+
executeSql: executeSql,
|
|
41
|
+
executeSqlArgs: executeSqlArgs,
|
|
42
|
+
sqlDatabase: SystemDbName,
|
|
43
|
+
sqlDbType: SystemDbType,
|
|
44
|
+
crudType: KeyOfCrudTypes.SYS_QUERY,
|
|
45
|
+
});
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
/**
|
|
@@ -55,6 +53,7 @@ export class BaseApiController extends BaseService {
|
|
|
55
53
|
* @protected
|
|
56
54
|
*/
|
|
57
55
|
protected async executeSysSimpleSQL(sqlTable: string, sqlSimpleName: KeysOfSimpleSQL, params?: IExecuteSimpleSqlParams) {
|
|
56
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
58
57
|
const body = this.ctx.request.body as any;
|
|
59
58
|
const req = this.ctx.req;
|
|
60
59
|
const cfgModel: IRequestCfgModel = {
|
|
@@ -62,7 +61,7 @@ export class BaseApiController extends BaseService {
|
|
|
62
61
|
sqlTable,
|
|
63
62
|
sqlSimpleName,
|
|
64
63
|
sqlDatabase: SystemDbName,
|
|
65
|
-
|
|
64
|
+
sqlDbType: SystemDbType,
|
|
66
65
|
updateCfg: {},
|
|
67
66
|
};
|
|
68
67
|
|
|
@@ -80,6 +79,7 @@ export class BaseApiController extends BaseService {
|
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
protected get sysDBUtil() {
|
|
82
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
83
83
|
return this.curdMixService.getBbUtil(SystemDbName, SystemDbType);
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -2,7 +2,7 @@ import { All, Controller, Inject, Param } from '@midwayjs/core';
|
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
4
|
import * as _ from 'lodash';
|
|
5
|
-
import { AnyApiService } from '
|
|
5
|
+
import { AnyApiService } from '@/service/anyapi/AnyApiService';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* FaaS方式配置的接口
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Controller, Inject, Post, Query } from '@midwayjs/core';
|
|
2
|
+
|
|
3
|
+
import { Context } from '@midwayjs/koa';
|
|
4
|
+
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
+
import { AsyncTaskService } from '@/service/asyncTask/AsyncTaskService';
|
|
6
|
+
import { SysAsyncTaskEntity, SysAsyncTaskStatus } from '@/models/AsyncTaskModel';
|
|
7
|
+
import { KeysOfSimpleSQL } from '@/libs/crud-pro/models/keys';
|
|
8
|
+
import { SystemTables } from '@/models/SystemTables';
|
|
9
|
+
import { CommonException } from '@/libs/crud-pro/exceptions';
|
|
10
|
+
import { checkLogin } from '@/middleware/permission.middleware';
|
|
11
|
+
|
|
12
|
+
function fixMyTasksCondition(body: any, ctx: Context) {
|
|
13
|
+
if (!body.condition) {
|
|
14
|
+
throw new CommonException('参数不正确');
|
|
15
|
+
}
|
|
16
|
+
body.condition.created_by = ctx.userSession.getSessionInfo().accountId;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function fixCancelBodyData(body: any, id: number) {
|
|
20
|
+
if (!body.data || !body.condition) {
|
|
21
|
+
throw new CommonException('参数不正确');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// fix condition
|
|
25
|
+
const conditionObj: SysAsyncTaskEntity = (body.condition || {}) as any;
|
|
26
|
+
conditionObj.id = id;
|
|
27
|
+
body.condition = conditionObj;
|
|
28
|
+
|
|
29
|
+
// fix data
|
|
30
|
+
const dataObj: SysAsyncTaskEntity = (body.data || {}) as any;
|
|
31
|
+
dataObj.task_status = SysAsyncTaskStatus.CANCELLED;
|
|
32
|
+
body.data = dataObj;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function fixCreateBodyData(body: any, ctx: Context) {
|
|
36
|
+
if (!body.data) {
|
|
37
|
+
throw new CommonException('参数不正确');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const sessionInfo = ctx.userSession.getSessionInfo();
|
|
41
|
+
// fix data
|
|
42
|
+
const dataObj: SysAsyncTaskEntity = (body.data || {}) as any;
|
|
43
|
+
dataObj.task_status = SysAsyncTaskStatus.PENDING;
|
|
44
|
+
dataObj.created_by = sessionInfo.accountId;
|
|
45
|
+
dataObj.created_user_session = JSON.stringify(sessionInfo); // 创建人的session信息。用于执行时的鉴权。
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 异步任务框架
|
|
50
|
+
*/
|
|
51
|
+
@Controller('/ns/gw/AsyncTask', { middleware: [checkLogin()] })
|
|
52
|
+
export class AsyncTaskController extends BaseApiController {
|
|
53
|
+
@Inject()
|
|
54
|
+
protected ctx: Context;
|
|
55
|
+
|
|
56
|
+
@Inject()
|
|
57
|
+
private asyncTaskService: AsyncTaskService;
|
|
58
|
+
|
|
59
|
+
// 获取任务列表
|
|
60
|
+
@Post('/getMyTasks')
|
|
61
|
+
async getMyTasks() {
|
|
62
|
+
fixMyTasksCondition(this.ctx.request.body, this.ctx);
|
|
63
|
+
return this.executeSysSimpleSQL(SystemTables.sys_async_tasks, KeysOfSimpleSQL.SIMPLE_QUERY_PAGE);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 创建任务
|
|
67
|
+
@Post('/createTask')
|
|
68
|
+
async createTask() {
|
|
69
|
+
fixCreateBodyData(this.ctx.request.body, this.ctx);
|
|
70
|
+
const res = await this.executeSysSimpleSQL(SystemTables.sys_async_tasks, KeysOfSimpleSQL.SIMPLE_INSERT);
|
|
71
|
+
await this.asyncTaskService.startTask();
|
|
72
|
+
return res;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 取消任务
|
|
76
|
+
@Post('/cancelTask')
|
|
77
|
+
async cancelTask(@Query('id') id: number) {
|
|
78
|
+
fixCancelBodyData(this.ctx.request.body, id);
|
|
79
|
+
await this.asyncTaskService.cancelTask(id);
|
|
80
|
+
await this.executeSysSimpleSQL(SystemTables.sys_async_tasks, KeysOfSimpleSQL.SIMPLE_UPDATE);
|
|
81
|
+
return { success: true };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -2,13 +2,14 @@ import * as _ from 'lodash';
|
|
|
2
2
|
import { decamelizeKeys } from 'humps';
|
|
3
3
|
import { Controller, Inject, Param, All } from '@midwayjs/core';
|
|
4
4
|
import { Context } from '@midwayjs/koa';
|
|
5
|
-
import { CommonResult } from '
|
|
6
|
-
import { WorkbenchService } from '
|
|
7
|
-
import { API_BASE_TYPE, ApiBaseService } from '
|
|
8
|
-
import { CurdProService } from '
|
|
9
|
-
import { CurdMixService } from '
|
|
10
|
-
import { IRequestCfgModel2 } from '
|
|
11
|
-
import {parseDatabaseName} from
|
|
5
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
6
|
+
import { WorkbenchService } from '@/service/WorkbenchService';
|
|
7
|
+
import { API_BASE_TYPE, ApiBaseService } from '@/service/base/ApiBaseService';
|
|
8
|
+
import { CurdProService } from '@/service/curd/CurdProService';
|
|
9
|
+
import { CurdMixService } from '@/service/curd/CurdMixService';
|
|
10
|
+
import { IRequestCfgModel2 } from '@/models/bizmodels';
|
|
11
|
+
import { parseDatabaseName } from '@/libs/crud-pro/utils/DatabaseName';
|
|
12
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
12
13
|
|
|
13
14
|
const QUERY_AS_LIST = ['condition', 'data'];
|
|
14
15
|
|
|
@@ -20,11 +21,11 @@ function pickAsQuery(query_as_pick: string, query: any): any {
|
|
|
20
21
|
return query;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
// /ns/gw/
|
|
24
|
+
// /ns/gw/crudApi/getUser?__query_as_condition__=id&_query_as_data__=name&&id=1&name=22
|
|
24
25
|
/**
|
|
25
|
-
* query形式1:GET: /ns/gw/
|
|
26
|
-
* query形式2:GET: /ns/gw/
|
|
27
|
-
* query形式3:GET: /ns/gw/
|
|
26
|
+
* query形式1:GET: /ns/gw/crudApi/getUser?__query_json__=%7B%22condition%22%3A%7B%22id%22%3A2%7D%7D
|
|
27
|
+
* query形式2:GET: /ns/gw/crudApi/getUser?__query_as__=condition&id=1&name=22
|
|
28
|
+
* query形式3:GET: /ns/gw/crudApi/createUser?__query_as__=data&__query_pick__=id,name&id=1&name=22
|
|
28
29
|
*
|
|
29
30
|
* 执行单个配置的接口
|
|
30
31
|
*/
|
|
@@ -56,7 +57,7 @@ export class CrudMtdGatewayController extends ApiBaseService {
|
|
|
56
57
|
return CommonResult.errorRes('接口不存在或已下线: ' + methodCode);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
this.logInfo(
|
|
60
|
+
this.logInfo('methodInfo=== ', methodInfo);
|
|
60
61
|
|
|
61
62
|
const workbench_code_array = methodInfo.workbench_code_array || methodInfo.workbenchCodeArray;
|
|
62
63
|
const isSupport = await this.workbenchService.isSupportCurrentWorkbench(workbench_code_array);
|
|
@@ -100,7 +101,10 @@ export class CrudMtdGatewayController extends ApiBaseService {
|
|
|
100
101
|
const cfgModel = methodInfo as IRequestCfgModel2;
|
|
101
102
|
const { dbType, dbName } = parseDatabaseName(cfgModel.sqlDatabase);
|
|
102
103
|
cfgModel.sqlDatabase = dbName;
|
|
103
|
-
cfgModel.
|
|
104
|
+
cfgModel.sqlDbType = dbType;
|
|
105
|
+
|
|
106
|
+
// 业务系统自定义的修改cfgModel
|
|
107
|
+
await GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudMtd(reqJson, cfgModel, methodInfo, this.ctx);
|
|
104
108
|
|
|
105
109
|
return this.curdMixService.executeCrudByCfg(reqJson, cfgModel);
|
|
106
110
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Controller, Inject, Post } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
-
import { CrudStdService, SPECIAL_SETTING_KEY } from '
|
|
5
|
-
import { KeysOfSimpleSQL } from '
|
|
6
|
-
import { IRequestModel } from '
|
|
7
|
-
import { CommonResult } from '
|
|
4
|
+
import { CrudStdService, SPECIAL_SETTING_KEY } from '@/service/crudstd/CrudStdService';
|
|
5
|
+
import { KeysOfSimpleSQL } from '@/libs/crud-pro/models/keys';
|
|
6
|
+
import { IRequestModel } from '@/libs/crud-pro/interfaces';
|
|
7
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
8
8
|
|
|
9
9
|
interface ICrudStdActionParams {
|
|
10
10
|
appCode: string;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {Get, Controller, Inject, Query} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
3
|
-
import {BaseApiController} from '../base/BaseApiController';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { Get, Controller, Inject, Query } from '@midwayjs/core';
|
|
2
|
+
import { Context } from '@midwayjs/koa';
|
|
3
|
+
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
+
import { SystemTables } from '@/models/SystemTables';
|
|
5
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
6
|
+
import { KeysOfSimpleSQL } from '@/libs/crud-pro/models/keys';
|
|
7
|
+
import { WorkbenchService } from '@/service/WorkbenchService';
|
|
8
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
8
9
|
|
|
9
10
|
function checkIsNumber(value: string, name: string) {
|
|
10
11
|
if (!value) {
|
|
@@ -27,19 +28,21 @@ export class DocGatewayController extends BaseApiController {
|
|
|
27
28
|
@Inject()
|
|
28
29
|
protected workbenchService: WorkbenchService;
|
|
29
30
|
|
|
30
|
-
|
|
31
31
|
private async updateDocPV(docId: string, docLibId: string, pv: number) {
|
|
32
32
|
const ip = this.ctx.headers['x-real-ip'];
|
|
33
33
|
const lockKey = `doc_ip_pv_${docId}_${ip}`;
|
|
34
34
|
const EXPIRE_TIME = 5 * 60 * 1000; // 在五分钟内,同一个IP地址重复刷新同一篇文章,认为是一个PV
|
|
35
|
-
const nxRes = await this.redisService.set(lockKey, 1, 'EX', EXPIRE_TIME, 'NX')
|
|
35
|
+
const nxRes = await this.redisService.set(lockKey, 1, 'EX', EXPIRE_TIME, 'NX');
|
|
36
36
|
if (nxRes !== 'OK') {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
41
|
+
|
|
42
|
+
await this.curdMixService.executeCrudByCfg(
|
|
43
|
+
{
|
|
41
44
|
data: {
|
|
42
|
-
pv: pv + 1
|
|
45
|
+
pv: pv + 1,
|
|
43
46
|
},
|
|
44
47
|
condition: {
|
|
45
48
|
id: parseInt(docId),
|
|
@@ -50,11 +53,11 @@ export class DocGatewayController extends BaseApiController {
|
|
|
50
53
|
sqlTable: SystemTables.sys_doc,
|
|
51
54
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
52
55
|
sqlDatabase: SystemDbName,
|
|
53
|
-
|
|
54
|
-
}
|
|
56
|
+
sqlDbType: SystemDbType,
|
|
57
|
+
}
|
|
58
|
+
);
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
|
|
58
61
|
/**
|
|
59
62
|
* @param docId
|
|
60
63
|
* @param docLibId 文档库
|
|
@@ -69,6 +72,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
69
72
|
return docLibInfoRes;
|
|
70
73
|
}
|
|
71
74
|
|
|
75
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
72
76
|
|
|
73
77
|
const res = await this.curdMixService.executeCrudByCfg(
|
|
74
78
|
{
|
|
@@ -81,7 +85,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
81
85
|
sqlTable: SystemTables.sys_doc,
|
|
82
86
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
83
87
|
sqlDatabase: SystemDbName,
|
|
84
|
-
|
|
88
|
+
sqlDbType: SystemDbType,
|
|
85
89
|
}
|
|
86
90
|
);
|
|
87
91
|
|
|
@@ -107,6 +111,8 @@ export class DocGatewayController extends BaseApiController {
|
|
|
107
111
|
return docLibInfoRes;
|
|
108
112
|
}
|
|
109
113
|
|
|
114
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
115
|
+
|
|
110
116
|
return this.curdMixService.executeCrudByCfg(
|
|
111
117
|
{
|
|
112
118
|
columns: 'id,title,doc_category_code,sort_index',
|
|
@@ -122,7 +128,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
122
128
|
sqlTable: SystemTables.sys_doc,
|
|
123
129
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
|
|
124
130
|
sqlDatabase: SystemDbName,
|
|
125
|
-
|
|
131
|
+
sqlDbType: SystemDbType,
|
|
126
132
|
}
|
|
127
133
|
);
|
|
128
134
|
}
|
|
@@ -135,6 +141,8 @@ export class DocGatewayController extends BaseApiController {
|
|
|
135
141
|
async getDocLibInfo(@Query('docLibId') docLibId: string) {
|
|
136
142
|
checkIsNumber(docLibId, 'docLibId');
|
|
137
143
|
|
|
144
|
+
const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
145
|
+
|
|
138
146
|
const s = await this.curdMixService.executeCrudByCfg(
|
|
139
147
|
{
|
|
140
148
|
condition: {
|
|
@@ -145,7 +153,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
145
153
|
sqlTable: SystemTables.sys_doc_lib,
|
|
146
154
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
|
|
147
155
|
sqlDatabase: SystemDbName,
|
|
148
|
-
|
|
156
|
+
sqlDbType: SystemDbType,
|
|
149
157
|
}
|
|
150
158
|
);
|
|
151
159
|
const docLibInfo = s.getOneObj();
|
|
@@ -2,18 +2,17 @@ import { Get, Post, Inject, Controller, Files, Fields, Param, Query } from '@mid
|
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import * as _ from 'lodash';
|
|
4
4
|
import { BaseApiController } from '../base/BaseApiController';
|
|
5
|
-
import { BizException } from '
|
|
6
|
-
import {AccessType, FILE_GET_TYPES} from '
|
|
7
|
-
import { FileCenterService, PATH_PREFIX, toDownloadPaths, isImageFile } from '
|
|
8
|
-
import { checkPermission } from '
|
|
9
|
-
import { CommonResult } from '
|
|
10
|
-
import {SystemFuncCode} from
|
|
5
|
+
import { BizException } from '@/models/devops';
|
|
6
|
+
import { AccessType, FILE_GET_TYPES } from '@/models/bizmodels';
|
|
7
|
+
import { FileCenterService, PATH_PREFIX, toDownloadPaths, isImageFile } from '@/service/FileCenterService';
|
|
8
|
+
import { checkPermission } from '@/middleware/permission.middleware';
|
|
9
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
10
|
+
import { SystemFuncCode } from '@/models/SystemPerm';
|
|
11
11
|
|
|
12
12
|
function isTrue(obj: any) {
|
|
13
13
|
return obj === true || obj === 'true';
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
/**
|
|
18
17
|
* 文件上传下载服务
|
|
19
18
|
*/
|
|
@@ -31,7 +30,7 @@ export class FileController extends BaseApiController {
|
|
|
31
30
|
* @param fields
|
|
32
31
|
* @param queryData
|
|
33
32
|
*/
|
|
34
|
-
@Post('/uploadFile',
|
|
33
|
+
@Post('/uploadFile', { middleware: [checkPermission([SystemFuncCode.DocMangeWrite, SystemFuncCode.FileMangeWrite, SystemFuncCode.UserAccountMangeWrite])] })
|
|
35
34
|
async uploadFile(@Files() files, @Fields() fields, @Query() queryData): Promise<CommonResult> {
|
|
36
35
|
const accessType = queryData?.accessType || fields?.accessType || AccessType.open;
|
|
37
36
|
const referer = this.ctx.req.headers.referer;
|
|
@@ -64,7 +63,7 @@ export class FileController extends BaseApiController {
|
|
|
64
63
|
* @param streaming 是否直接返回流,默认返回 302 跳转
|
|
65
64
|
*/
|
|
66
65
|
@Get('/get/:byMethod/:fileKey*')
|
|
67
|
-
async downloadFile(@Param('byMethod') byMethod: string
|
|
66
|
+
async downloadFile(@Param('byMethod') byMethod: string, @Param('fileKey') fileKey: string) {
|
|
68
67
|
if (!fileKey) {
|
|
69
68
|
throw new BizException('fileKey不能为空');
|
|
70
69
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { All, Controller, Inject, Query } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
-
import { ProxyApiService } from '
|
|
5
|
-
import { WorkbenchService } from '
|
|
6
|
-
import { CommonResult } from '
|
|
7
|
-
import { ProxyApiLoadService } from '
|
|
4
|
+
import { ProxyApiService } from '@/service/proxyapi/ProxyApiService';
|
|
5
|
+
import { WorkbenchService } from '@/service/WorkbenchService';
|
|
6
|
+
import { CommonResult } from '@/libs/utils/common-dto';
|
|
7
|
+
import { ProxyApiLoadService } from '@/service/proxyapi/ProxyApiLoadService';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* 只支持前缀匹配
|