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.
Files changed (188) hide show
  1. package/dist/config/config.default.js +6 -4
  2. package/dist/controller/home.controller.js +2 -1
  3. package/dist/controller/manage/CrudStandardDesignApi.js +8 -8
  4. package/dist/controller/render/AppRenderController.js +2 -1
  5. package/dist/middleware/global.middleware.js +22 -9
  6. package/dist/models/AsyncTaskModel.d.ts +2 -0
  7. package/dist/models/AsyncTaskModel.js +3 -1
  8. package/dist/models/RedisKeys.d.ts +2 -0
  9. package/dist/models/RedisKeys.js +2 -0
  10. package/dist/models/bizmodels.d.ts +1 -0
  11. package/dist/service/UserSessionService.d.ts +21 -0
  12. package/dist/service/UserSessionService.js +71 -1
  13. package/dist/service/WorkbenchService.d.ts +32 -0
  14. package/dist/service/WorkbenchService.js +54 -11
  15. package/dist/service/anyapi/AnyApiSandboxService.js +12 -12
  16. package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +14 -1
  17. package/dist/service/asyncTask/AsyncTaskRunnerService.js +70 -25
  18. package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.js +1 -1
  19. package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.js +11 -2
  20. package/dist/service/base/RedisCacheService.d.ts +7 -0
  21. package/dist/service/base/RedisCacheService.js +7 -0
  22. package/dist/service/crudstd/CrudStdService.d.ts +0 -6
  23. package/dist/service/crudstd/CrudStdService.js +13 -33
  24. package/package.json +1 -5
  25. package/src/config/config.default.ts +0 -207
  26. package/src/config/seed/aeskey.txt +0 -1
  27. package/src/config/utils.ts +0 -22
  28. package/src/configuration.ts +0 -109
  29. package/src/controller/base/BaseApiController.ts +0 -170
  30. package/src/controller/gateway/AnyApiGatewayController.ts +0 -33
  31. package/src/controller/gateway/AsyncTaskController.ts +0 -157
  32. package/src/controller/gateway/CrudMtdGatewayController.ts +0 -111
  33. package/src/controller/gateway/CrudStdGatewayController.ts +0 -101
  34. package/src/controller/gateway/DocGatewayController.ts +0 -173
  35. package/src/controller/gateway/FileController.ts +0 -109
  36. package/src/controller/gateway/ProxyApiGatewayController.ts +0 -47
  37. package/src/controller/gateway/PublicApiController.ts +0 -142
  38. package/src/controller/gateway/StaticController.ts +0 -298
  39. package/src/controller/helpers.controller.ts +0 -161
  40. package/src/controller/home.controller.ts +0 -64
  41. package/src/controller/manage/AnyApiMangeApi.ts +0 -66
  42. package/src/controller/manage/AppLogMangeApi.ts +0 -53
  43. package/src/controller/manage/AppMangeApi.ts +0 -53
  44. package/src/controller/manage/AppPageMangeApi.ts +0 -52
  45. package/src/controller/manage/AppSchemaHistoryApi.ts +0 -49
  46. package/src/controller/manage/CrudMethodsMangeApi.ts +0 -49
  47. package/src/controller/manage/CrudStandardDesignApi.ts +0 -346
  48. package/src/controller/manage/DataDictManageApi.ts +0 -78
  49. package/src/controller/manage/DeployManageApi.ts +0 -175
  50. package/src/controller/manage/DocLibManageApi.ts +0 -69
  51. package/src/controller/manage/DocManageApi.ts +0 -99
  52. package/src/controller/manage/FileManageApi.ts +0 -45
  53. package/src/controller/manage/LowCodeTplManageApi.ts +0 -52
  54. package/src/controller/manage/MenuManageApi.ts +0 -58
  55. package/src/controller/manage/ProxyApiMangeApi.ts +0 -52
  56. package/src/controller/manage/SuperAdminManageApi.ts +0 -139
  57. package/src/controller/manage/SysConfigMangeApi.ts +0 -95
  58. package/src/controller/manage/SystemInfoManageApi.ts +0 -53
  59. package/src/controller/manage/UserAccountManageApi.ts +0 -94
  60. package/src/controller/manage/WorkbenchMangeApi.ts +0 -72
  61. package/src/controller/myinfo/AuthController.ts +0 -108
  62. package/src/controller/myinfo/MyInfoController.ts +0 -32
  63. package/src/controller/render/AppRenderController.ts +0 -79
  64. package/src/controller/test.controller.ts +0 -37
  65. package/src/filter/default.filter.ts +0 -13
  66. package/src/filter/notfound.filter.ts +0 -10
  67. package/src/index.ts +0 -106
  68. package/src/interface.ts +0 -31
  69. package/src/libs/crud-pro/CrudPro.ts +0 -165
  70. package/src/libs/crud-pro/defaultConfigs.ts +0 -15
  71. package/src/libs/crud-pro/exceptions.ts +0 -124
  72. package/src/libs/crud-pro/interfaces.ts +0 -190
  73. package/src/libs/crud-pro/models/ExecuteContext.ts +0 -120
  74. package/src/libs/crud-pro/models/ExecuteContextFunc.ts +0 -96
  75. package/src/libs/crud-pro/models/FuncContext.ts +0 -21
  76. package/src/libs/crud-pro/models/RequestCfgModel.ts +0 -141
  77. package/src/libs/crud-pro/models/RequestModel.ts +0 -141
  78. package/src/libs/crud-pro/models/ResModel.ts +0 -19
  79. package/src/libs/crud-pro/models/ServiceHub.ts +0 -32
  80. package/src/libs/crud-pro/models/SqlCfgModel.ts +0 -52
  81. package/src/libs/crud-pro/models/SqlSegArg.ts +0 -13
  82. package/src/libs/crud-pro/models/Transaction.ts +0 -73
  83. package/src/libs/crud-pro/models/TransactionMySQL.ts +0 -79
  84. package/src/libs/crud-pro/models/TransactionPostgres.ts +0 -91
  85. package/src/libs/crud-pro/models/TransactionSqlServer.ts +0 -102
  86. package/src/libs/crud-pro/models/keys.ts +0 -159
  87. package/src/libs/crud-pro/services/CrudProCachedCfgService.ts +0 -83
  88. package/src/libs/crud-pro/services/CrudProExecuteFuncService.ts +0 -128
  89. package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +0 -262
  90. package/src/libs/crud-pro/services/CrudProFieldUpdateService.ts +0 -60
  91. package/src/libs/crud-pro/services/CrudProFieldValidateService.ts +0 -180
  92. package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +0 -354
  93. package/src/libs/crud-pro/services/CrudProGenSqlService.ts +0 -185
  94. package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +0 -393
  95. package/src/libs/crud-pro/services/CrudProServiceBase.ts +0 -94
  96. package/src/libs/crud-pro/services/CrudProTableMetaService.ts +0 -86
  97. package/src/libs/crud-pro/services/CurdProServiceHub.ts +0 -92
  98. package/src/libs/crud-pro/sql.txt +0 -120
  99. package/src/libs/crud-pro/utils/CompareUtils.ts +0 -23
  100. package/src/libs/crud-pro/utils/DatabaseName.ts +0 -60
  101. package/src/libs/crud-pro/utils/DateTimeUtils.ts +0 -20
  102. package/src/libs/crud-pro/utils/MemoryRefreshCache.ts +0 -64
  103. package/src/libs/crud-pro/utils/MessageParseUtils.ts +0 -33
  104. package/src/libs/crud-pro/utils/MixinUtils.ts +0 -285
  105. package/src/libs/crud-pro/utils/ModelUtils.ts +0 -55
  106. package/src/libs/crud-pro/utils/MultiKeyMap.ts +0 -72
  107. package/src/libs/crud-pro/utils/SqlFuncUtils.ts +0 -29
  108. package/src/libs/crud-pro/utils/TypeUtils.ts +0 -188
  109. package/src/libs/crud-pro/utils/ValidateUtils.ts +0 -165
  110. package/src/libs/crud-pro/utils/pool/MySQLUtils.ts +0 -20
  111. package/src/libs/crud-pro/utils/pool/PostgresUtils.ts +0 -22
  112. package/src/libs/crud-pro/utils/pool/SqlServerUtils.ts +0 -22
  113. package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +0 -26
  114. package/src/libs/crud-pro/utils/sqlConvert/convertMix.ts +0 -26
  115. package/src/libs/crud-pro/utils/sqlConvert/convertMsSql.ts +0 -11
  116. package/src/libs/crud-pro/utils/sqlConvert/convertPgSql.ts +0 -11
  117. package/src/libs/crud-pro/utils/sqlConvert/convertPgType.ts +0 -129
  118. package/src/libs/global-config/global-config.ts +0 -78
  119. package/src/libs/utils/common-dto.ts +0 -52
  120. package/src/libs/utils/crypto-utils.ts +0 -50
  121. package/src/libs/utils/errorToString.ts +0 -61
  122. package/src/libs/utils/fatcms-request.ts +0 -103
  123. package/src/libs/utils/functions.ts +0 -73
  124. package/src/libs/utils/ordernum-utils.ts +0 -14
  125. package/src/libs/utils/parseConfig.ts +0 -54
  126. package/src/libs/utils/parseCreateSql.ts +0 -91
  127. package/src/libs/utils/render-utils.ts +0 -184
  128. package/src/middleware/forbidden.middleware.ts +0 -52
  129. package/src/middleware/global.middleware.ts +0 -280
  130. package/src/middleware/permission.middleware.ts +0 -80
  131. package/src/middleware/tx.middleware.ts +0 -30
  132. package/src/models/AsyncTaskModel.ts +0 -82
  133. package/src/models/RedisKeys.ts +0 -13
  134. package/src/models/SystemEntities.ts +0 -115
  135. package/src/models/SystemPerm.ts +0 -105
  136. package/src/models/SystemTables.ts +0 -27
  137. package/src/models/bizmodels.ts +0 -120
  138. package/src/models/contextLogger.ts +0 -132
  139. package/src/models/devops.ts +0 -17
  140. package/src/models/userSession.ts +0 -216
  141. package/src/schedule/anonymousContext.ts +0 -73
  142. package/src/schedule/index.ts +0 -12
  143. package/src/schedule/runSchedule.ts +0 -82
  144. package/src/schedule/scheduleNames.ts +0 -21
  145. package/src/service/AuthService.ts +0 -272
  146. package/src/service/EnumInfoService.ts +0 -130
  147. package/src/service/FileCenterService.ts +0 -395
  148. package/src/service/SysConfigService.ts +0 -37
  149. package/src/service/UserAccountService.ts +0 -107
  150. package/src/service/UserSessionService.ts +0 -78
  151. package/src/service/VisitStatService.ts +0 -166
  152. package/src/service/WorkbenchService.ts +0 -165
  153. package/src/service/anyapi/AnyApiSandboxService.ts +0 -121
  154. package/src/service/anyapi/AnyApiService.ts +0 -186
  155. package/src/service/asyncTask/AsyncTaskRunnerService.ts +0 -266
  156. package/src/service/asyncTask/AsyncTaskService.ts +0 -21
  157. package/src/service/asyncTask/handler/ExcelInfoModel.ts +0 -11
  158. package/src/service/asyncTask/handler/ExportExcelAsyncTaskHandler.ts +0 -245
  159. package/src/service/asyncTask/handler/ExportExcelByInnerHttpHandler.ts +0 -147
  160. package/src/service/asyncTask/handler/ExportExcelByStdCrudHandler.ts +0 -138
  161. package/src/service/base/ApiBaseService.ts +0 -42
  162. package/src/service/base/ApiRateLimiter.ts +0 -59
  163. package/src/service/base/BaseService.ts +0 -100
  164. package/src/service/base/RedisCacheService.ts +0 -38
  165. package/src/service/crudstd/CrudStdActionService.ts +0 -27
  166. package/src/service/crudstd/CrudStdConstant.ts +0 -62
  167. package/src/service/crudstd/CrudStdRelationService.ts +0 -78
  168. package/src/service/crudstd/CrudStdService.ts +0 -283
  169. package/src/service/curd/CrudProQuick.ts +0 -131
  170. package/src/service/curd/CurdMixByAccountService.ts +0 -90
  171. package/src/service/curd/CurdMixByDictService.ts +0 -114
  172. package/src/service/curd/CurdMixByLinkToCustomService.ts +0 -219
  173. package/src/service/curd/CurdMixBySysConfigService.ts +0 -78
  174. package/src/service/curd/CurdMixByWorkbenchService.ts +0 -71
  175. package/src/service/curd/CurdMixService.ts +0 -97
  176. package/src/service/curd/CurdMixUtils.ts +0 -311
  177. package/src/service/curd/CurdProService.ts +0 -229
  178. package/src/service/curd/fixCfgModel.ts +0 -139
  179. package/src/service/proxyapi/ProxyApiLoadService.ts +0 -174
  180. package/src/service/proxyapi/ProxyApiService.ts +0 -262
  181. package/src/service/proxyapi/ProxyApiUtils.ts +0 -32
  182. package/src/service/proxyapi/RouteHandler.ts +0 -8
  183. package/src/service/proxyapi/RouteTrie.ts +0 -74
  184. package/src/service/proxyapi/WeightedRandom.ts +0 -37
  185. package/src/service/proxyapi/WeightedRoundRobin.ts +0 -44
  186. package/src/views/404_app.html +0 -31
  187. package/src/views/404_workbench.html +0 -34
  188. package/src/views/static/favicon.ico +0 -0
@@ -1,173 +0,0 @@
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';
9
-
10
- function checkIsNumber(value: string, name: string) {
11
- if (!value) {
12
- throw `${name}参数不存在`;
13
- }
14
- if (!parseInt(value)) {
15
- throw `${name}参数不是一个整数`;
16
- }
17
- }
18
-
19
- /**
20
- * C端用户接口。
21
- * 对外开发接口。
22
- */
23
- @Controller('/ns/gw/doc')
24
- export class DocGatewayController extends BaseApiController {
25
- @Inject()
26
- protected ctx: Context;
27
-
28
- @Inject()
29
- protected workbenchService: WorkbenchService;
30
-
31
- private async updateDocPV(docId: string, docLibId: string, pv: number) {
32
- const ip = this.ctx.headers['x-real-ip'];
33
- const lockKey = `doc_ip_pv_${docId}_${ip}`;
34
- const EXPIRE_TIME = 5 * 60 * 1000; // 在五分钟内,同一个IP地址重复刷新同一篇文章,认为是一个PV
35
- const nxRes = await this.redisService.set(lockKey, 1, 'EX', EXPIRE_TIME, 'NX');
36
- if (nxRes !== 'OK') {
37
- return;
38
- }
39
-
40
- const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
41
-
42
- await this.curdMixService.executeCrudByCfg(
43
- {
44
- data: {
45
- pv: pv + 1,
46
- },
47
- condition: {
48
- id: parseInt(docId),
49
- doc_lib_id: parseInt(docLibId),
50
- },
51
- },
52
- {
53
- sqlTable: SystemTables.sys_doc,
54
- sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE,
55
- sqlDatabase: SystemDbName,
56
- sqlDbType: SystemDbType,
57
- }
58
- );
59
- }
60
-
61
- /**
62
- * @param docId
63
- * @param docLibId 文档库
64
- */
65
- @Get('/getDocInfo')
66
- async getDocInfo(@Query('docId') docId: string, @Query('docLibId') docLibId: string) {
67
- checkIsNumber(docId, 'docId');
68
- checkIsNumber(docLibId, 'docLibId');
69
-
70
- const docLibInfoRes = await this.getDocLibInfo(docLibId);
71
- if (!docLibInfoRes.success) {
72
- return docLibInfoRes;
73
- }
74
-
75
- const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
76
-
77
- const res = await this.curdMixService.executeCrudByCfg(
78
- {
79
- condition: {
80
- id: parseInt(docId),
81
- doc_lib_id: parseInt(docLibId),
82
- },
83
- },
84
- {
85
- sqlTable: SystemTables.sys_doc,
86
- sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
87
- sqlDatabase: SystemDbName,
88
- sqlDbType: SystemDbType,
89
- }
90
- );
91
-
92
- // 更新PV数据
93
- const docObj = res.getOneObj();
94
- if (docObj) {
95
- const pv: number = parseInt(docObj.pv) || 0;
96
- await this.updateDocPV(docId, docLibId, pv);
97
- }
98
-
99
- return res;
100
- }
101
-
102
- /**
103
- * @param docLibId
104
- */
105
- @Get('/getDocList')
106
- async getDocList(@Query('docLibId') docLibId: string) {
107
- checkIsNumber(docLibId, 'docLibId');
108
-
109
- const docLibInfoRes = await this.getDocLibInfo(docLibId);
110
- if (!docLibInfoRes.success) {
111
- return docLibInfoRes;
112
- }
113
-
114
- const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
115
-
116
- return this.curdMixService.executeCrudByCfg(
117
- {
118
- columns: 'id,title,doc_category_code,sort_index',
119
- orderBy: 'sort_index+,id-',
120
- condition: {
121
- doc_lib_id: parseInt(docLibId),
122
- doc_category_code: {
123
- $notNull: '',
124
- },
125
- },
126
- },
127
- {
128
- sqlTable: SystemTables.sys_doc,
129
- sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
130
- sqlDatabase: SystemDbName,
131
- sqlDbType: SystemDbType,
132
- }
133
- );
134
- }
135
-
136
- /**
137
- * TODO 权限控制
138
- * @param docLibId
139
- */
140
- @Get('/getDocLibInfo')
141
- async getDocLibInfo(@Query('docLibId') docLibId: string) {
142
- checkIsNumber(docLibId, 'docLibId');
143
-
144
- const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
145
-
146
- const s = await this.curdMixService.executeCrudByCfg(
147
- {
148
- condition: {
149
- id: parseInt(docLibId),
150
- },
151
- },
152
- {
153
- sqlTable: SystemTables.sys_doc_lib,
154
- sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
155
- sqlDatabase: SystemDbName,
156
- sqlDbType: SystemDbType,
157
- }
158
- );
159
- const docLibInfo = s.getOneObj();
160
-
161
- if (!docLibInfo) {
162
- throw '此文档库查询失败';
163
- }
164
-
165
- const workbench_code_array = docLibInfo.workbench_code_array;
166
- const isSupportCurrentWorkbench = await this.workbenchService.isSupportCurrentWorkbench(workbench_code_array);
167
- if (!isSupportCurrentWorkbench) {
168
- throw '此文档库不支持在当前站点打开';
169
- }
170
-
171
- return CommonResult.successRes(docLibInfo);
172
- }
173
- }
@@ -1,109 +0,0 @@
1
- import { Get, Post, Inject, Controller, Files, Fields, Param, Query } from '@midwayjs/core';
2
- import { Context } from '@midwayjs/koa';
3
- import * as _ from 'lodash';
4
- import { BaseApiController } from '../base/BaseApiController';
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
-
12
- function isTrue(obj: any) {
13
- return obj === true || obj === 'true';
14
- }
15
-
16
- /**
17
- * 文件上传下载服务
18
- */
19
- @Controller(PATH_PREFIX)
20
- export class FileController extends BaseApiController {
21
- @Inject()
22
- ctx: Context;
23
-
24
- @Inject()
25
- private fileCenterService: FileCenterService;
26
-
27
- /**
28
- * 上传普通文件。必须是登录用户才能上传。
29
- * @param files
30
- * @param fields
31
- * @param queryData
32
- */
33
- @Post('/uploadFile', { middleware: [checkPermission([SystemFuncCode.DocMangeWrite, SystemFuncCode.FileMangeWrite, SystemFuncCode.UserAccountMangeWrite])] })
34
- async uploadFile(@Files() files, @Fields() fields, @Query() queryData): Promise<CommonResult> {
35
- const accessType = queryData?.accessType || fields?.accessType || AccessType.open;
36
- const referer = this.ctx.req.headers.referer;
37
-
38
- if (!Object.keys(AccessType).includes(accessType)) {
39
- throw new BizException(`仅支持 ${Object.keys(AccessType).join('、')} 上传模式`);
40
- }
41
-
42
- const { fileKey, filename, storageUrl } = await this.fileCenterService.uploadFileToOSS(files, accessType, referer);
43
-
44
- const origin = this.ctx.request.origin;
45
-
46
- const downloadUrls = toDownloadPaths(origin, fileKey);
47
-
48
- const data = {
49
- fileKey,
50
- filename,
51
- storageUrl,
52
- ...downloadUrls,
53
- };
54
- return CommonResult.successRes(data);
55
- }
56
-
57
- // http://localhost:5173/ns/gw/file/get/download/6114718c6e2cb192bf6e99c3ede2b6d41743401594182.png&process=doc/preview
58
- /**
59
- * 文件下载或预览
60
- * @param byMethod
61
- * @param fileKey
62
- * @param process 图片处理:https://help.aliyun.com/document_detail/44688.html
63
- * @param streaming 是否直接返回流,默认返回 302 跳转
64
- */
65
- @Get('/get/:byMethod/:fileKey*')
66
- async downloadFile(@Param('byMethod') byMethod: string, @Param('fileKey') fileKey: string) {
67
- if (!fileKey) {
68
- throw new BizException('fileKey不能为空');
69
- }
70
-
71
- const byMethodSet = new Set<string>(FILE_GET_TYPES);
72
- if (!byMethodSet.has(byMethod)) {
73
- throw new BizException('byMethod不正确');
74
- }
75
-
76
- // eslint-disable-next-line prefer-const
77
- let { process, preview, streaming } = (this.ctx.query || {}) as any;
78
-
79
- const isThumbnail = this.ctx.path.startsWith(`${PATH_PREFIX}/get/thumbnail/`);
80
- const isPreview = this.ctx.path.startsWith(`${PATH_PREFIX}/get/preview/`) || isTrue(preview);
81
- const isStreaming = isTrue(streaming);
82
-
83
- if (isThumbnail && isImageFile(fileKey) && !process) {
84
- // x-oss-process=image/resize,w_200,p_10/quality,q_60
85
- process = 'image/resize,w_200'; //图片缩略图(小图片)
86
- }
87
-
88
- const isOutByStreaming = isStreaming || isPreview || isThumbnail;
89
-
90
- const result = await this.fileCenterService.downloadFile(fileKey, isOutByStreaming, process);
91
-
92
- if (isOutByStreaming) {
93
- // 移除这些属性
94
- const headers: any = _.omitBy(result.res.headers, (_v, key) => {
95
- if (key === 'content-length') {
96
- return true;
97
- }
98
- if ((isPreview || isThumbnail) && key.toLowerCase() === 'content-disposition') {
99
- return true;
100
- }
101
- return key.startsWith('x-oss-meta-');
102
- });
103
- this.ctx.set(headers);
104
- this.ctx.body = result.stream;
105
- } else {
106
- this.ctx.redirect(result.downloadURL);
107
- }
108
- }
109
- }
@@ -1,47 +0,0 @@
1
- import { All, Controller, Inject, Query } from '@midwayjs/core';
2
- import { Context } from '@midwayjs/koa';
3
- import { BaseApiController } from '../base/BaseApiController';
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
-
9
- /**
10
- * 只支持前缀匹配
11
- * 【/ns/gw/proxy/[upstreamName]/】api/userinfo ==> http://127.0.0.1:3000/api/userinfo
12
- * FaaS方式配置的接口
13
- */
14
- @Controller('/ns/gw/proxy')
15
- export class ProxyApiGatewayController extends BaseApiController {
16
- @Inject()
17
- protected ctx: Context;
18
-
19
- @Inject()
20
- private proxyApiService: ProxyApiService;
21
-
22
- @Inject()
23
- private workbenchService: WorkbenchService;
24
-
25
- @Inject()
26
- private proxyApiLoadService: ProxyApiLoadService;
27
- /**
28
- * 执行配置出来的接口的接口。此接口本身不需要鉴权。鉴权信息在配置中由curdPro底层进行鉴权
29
- */
30
- @All('/*')
31
- async executeProxyApi() {
32
- const workbenchInfo = await this.workbenchService.getCurrentHostWorkbenchInfo();
33
- if (!workbenchInfo) {
34
- return CommonResult.errorRes('域名站点不存在');
35
- }
36
- const workbench_code = workbenchInfo.workbench_code;
37
- // const path_prefix2 = '/' + entity.upstream_code + entity.path_prefix;
38
- // 路由树的结构是 /${entity.upstream_code}${entity.path_prefix}
39
- const path2 = this.ctx.path.replace(/^\/ns\/gw\/proxy/, '');
40
- return this.proxyApiService.handleProxyRequest(workbench_code, path2);
41
- }
42
-
43
- @All('/buildRouteTrie')
44
- async buildRouteTrie(@Query('workbench_code') workbench_code: string) {
45
- return this.proxyApiLoadService.buildRouteTrie(workbench_code);
46
- }
47
- }
@@ -1,142 +0,0 @@
1
- import { Controller, Get, Inject, Post } from '@midwayjs/core';
2
- import { Context } from '@midwayjs/koa';
3
- import * as _ from 'lodash';
4
- import { BaseApiController } from '../base/BaseApiController';
5
- import { SystemTables } from '@/models/SystemTables';
6
- import { EnumInfoService } from '@/service/EnumInfoService';
7
- import { CommonResult } from '@/libs/utils/common-dto';
8
- import { parseJsonObject } from '@/libs/utils/functions';
9
- import { WorkbenchService } from '@/service/WorkbenchService';
10
- import { SystemRoleCode } from '@/models/SystemPerm';
11
- import { KeysOfAuthType } from '@/libs/crud-pro/models/keys';
12
-
13
- /**
14
- * 公开的API,无需鉴权,所有人可以直接访问
15
- */
16
- @Controller('/ns/gw/api/publicApi')
17
- export class PublicApiController extends BaseApiController {
18
- @Inject()
19
- protected ctx: Context;
20
-
21
- @Inject()
22
- private enumInfoService: EnumInfoService;
23
-
24
- @Inject()
25
- private workbenchService: WorkbenchService;
26
-
27
- /**
28
- * 获取所有站点列表
29
- */
30
- @Get('/getAllWorkbenchInfoList')
31
- async getAllWorkbenchInfoList(): Promise<CommonResult> {
32
- const entities = await this.workbenchService.getAllWorkbenchInfoList(false);
33
- const entities2 = entities.map(e => {
34
- return {
35
- workbench_domain: e.workbench_domain,
36
- workbench_code: e.workbench_code,
37
- workbench_desc: e.workbench_desc,
38
- workbench_name: e.workbench_name,
39
- };
40
- });
41
- return CommonResult.successRes(entities2);
42
- }
43
-
44
- /**
45
- * 获取菜单信息
46
- */
47
- @Get('/getWorkbenchMenu')
48
- async getWorkbenchMenu(): Promise<CommonResult> {
49
- const query = this.ctx.query || {};
50
- const workbenchMenuCode = query.workbenchMenuCode;
51
- if (!workbenchMenuCode) {
52
- return CommonResult.errorRes('param workbenchMenuCode is null');
53
- }
54
-
55
- const workbenchMenuCodeStr = '' + workbenchMenuCode;
56
- const workbenchMenuCodeArray = workbenchMenuCodeStr.split(',');
57
-
58
- const condition = {
59
- menu_code: {
60
- $in: workbenchMenuCodeArray,
61
- },
62
- };
63
- const rows = await this.sysDBUtil.getList({ condition }, SystemTables.sys_menus);
64
- if (!rows || rows.length === 0) {
65
- return CommonResult.errorRes('sys_config is null', '', { condition });
66
- }
67
-
68
- const map = {};
69
- for (let i = 0; i < rows.length; i++) {
70
- const rowElement = rows[i];
71
- const menu_code = rowElement.menu_code;
72
- const view_auth_config = rowElement.view_auth_config;
73
- const view_auth_type = rowElement.view_auth_type;
74
-
75
- const hasPermission = this.ctx.userSession.isAuthPass(view_auth_type, view_auth_config);
76
-
77
- const menu_config_content = rowElement.menu_config_content;
78
- delete rowElement.menu_config_content;
79
- const menu_list = parseJsonObject(menu_config_content) || [];
80
- map[menu_code] = { ...rowElement, menu_list, hasPermission };
81
- }
82
-
83
- // 特殊的devops菜单
84
- map['devops'] = {
85
- menu_list: [], // 这个特殊的菜单在前端写死。
86
- hasPermission: this.ctx.userSession.isAuthPass(KeysOfAuthType.byRoleCode, [SystemRoleCode.DevOpsWriter, SystemRoleCode.DevOpsViewer, SystemRoleCode.SuperAdmin]),
87
- };
88
-
89
- return CommonResult.successRes(map);
90
- }
91
-
92
- /**
93
- * 获取页面信息
94
- */
95
- @Post('/getNavPageInfo')
96
- async getNavPageInfo(): Promise<CommonResult> {
97
- const body = this.ctx.request.body as any;
98
- const { workbenchCode, appCode, pathname } = body;
99
- const resultData: any = {};
100
- const getOne = async (condition: any, tablenName: string, key: string) => {
101
- const values = Object.values(condition).filter(Boolean);
102
- // 查询条件不能为空
103
- if (values.length > 0) {
104
- const oneData = await this.sysDBUtil.getOne({ condition }, tablenName);
105
- if (oneData && oneData['app_schema']) {
106
- oneData['app_schema'] = parseJsonObject(oneData['app_schema']);
107
- }
108
- resultData[key] = oneData;
109
- }
110
- };
111
-
112
- await getOne({ app_code: appCode }, SystemTables.sys_app, 'appData');
113
- await getOne({ page_path: pathname, workbench_code: workbenchCode }, SystemTables.sys_app_page, 'pageData');
114
-
115
- return CommonResult.successRes(resultData);
116
- }
117
-
118
- /**
119
- * 获取配置的枚举项信息: 都是无需鉴权的
120
- */
121
- @Post('/getEnumInfo')
122
- async getEnumInfo(): Promise<CommonResult> {
123
- const body = this.ctx.request.body as any;
124
- const query = this.ctx.query || {};
125
- let codeList = _.get(body, 'codeList');
126
- const refreshCache = `${_.get(body, 'refreshCache')}` === 'true' || query.refreshCache === 'true';
127
-
128
- if (query.codeList) {
129
- //codeList=dict@@SexEnum,sysCfgEnum@@EntityStatusEnum
130
- const codeListStr: string = query.codeList as string;
131
- codeList = codeListStr.split(',').map(str => {
132
- const ss = str.split('@@');
133
- return {
134
- type: ss[0],
135
- code: ss[1],
136
- };
137
- });
138
- }
139
- const enumInfos = await this.enumInfoService.queryEnumInfo(codeList, refreshCache);
140
- return CommonResult.successRes(enumInfos);
141
- }
142
- }