midway-fatcms 0.0.1-beta.1 → 0.0.1-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/config.default.js +52 -15
- package/dist/controller/base/BaseApiController.js +9 -6
- package/dist/controller/gateway/CrudMtdGatewayController.js +4 -1
- package/dist/controller/gateway/DocGatewayController.js +13 -8
- package/dist/controller/gateway/StaticController.d.ts +3 -0
- package/dist/controller/gateway/StaticController.js +41 -21
- package/dist/controller/home.controller.js +2 -2
- package/dist/controller/manage/CrudStandardDesignApi.js +89 -74
- package/dist/controller/manage/DeployManageApi.js +6 -4
- package/dist/controller/manage/SuperAdminManageApi.js +12 -8
- package/dist/controller/manage/SysConfigMangeApi.js +3 -1
- package/dist/controller/manage/UserAccountManageApi.d.ts +1 -1
- package/dist/controller/manage/UserAccountManageApi.js +5 -0
- package/dist/controller/myinfo/AuthController.d.ts +0 -4
- package/dist/controller/myinfo/AuthController.js +0 -53
- package/dist/controller/render/AppRenderController.js +4 -2
- package/dist/controller/test.controller.js +1 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.js +28 -4
- package/dist/libs/crud-pro/interfaces.d.ts +1 -1
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +1 -1
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +1 -1
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +4 -4
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +4 -4
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +8 -8
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +2 -2
- package/dist/libs/global-config/global-config.d.ts +39 -0
- package/dist/libs/global-config/global-config.js +32 -0
- package/dist/models/SystemTables.d.ts +0 -3
- package/dist/models/SystemTables.js +1 -4
- package/dist/service/AuthService.js +8 -5
- package/dist/service/EnumInfoService.js +7 -4
- package/dist/service/FileCenterService.js +13 -9
- package/dist/service/SysConfigService.js +4 -2
- package/dist/service/UserAccountService.js +10 -6
- package/dist/service/VisitStatService.js +4 -2
- package/dist/service/WorkbenchService.js +4 -2
- package/dist/service/anyapi/AnyApiService.js +4 -2
- package/dist/service/crudstd/CrudStdService.js +7 -3
- package/dist/service/curd/CurdMixByAccountService.js +12 -6
- package/dist/service/curd/CurdMixByDictService.js +4 -2
- package/dist/service/curd/CurdMixByLinkToCustomService.js +1 -1
- package/dist/service/curd/CurdMixBySysConfigService.js +4 -2
- package/dist/service/curd/CurdMixByWorkbenchService.js +4 -2
- package/dist/service/curd/CurdMixService.d.ts +1 -1
- package/dist/service/curd/CurdMixService.js +2 -2
- package/dist/service/curd/CurdMixUtils.d.ts +7 -0
- package/dist/service/curd/CurdMixUtils.js +31 -1
- package/dist/service/curd/CurdProService.d.ts +3 -3
- package/dist/service/curd/CurdProService.js +9 -9
- package/dist/service/proxyapi/ProxyApiLoadService.js +7 -4
- package/dist/views/404_app.html +31 -0
- package/dist/views/404_workbench.html +34 -0
- package/dist/views/static/favicon.ico +0 -0
- package/package.json +5 -1
- package/src/config/config.default.ts +58 -27
- package/src/controller/base/BaseApiController.ts +14 -14
- package/src/controller/gateway/CrudMtdGatewayController.ts +6 -2
- package/src/controller/gateway/DocGatewayController.ts +13 -5
- package/src/controller/gateway/StaticController.ts +50 -25
- package/src/controller/home.controller.ts +8 -10
- package/src/controller/manage/CrudStandardDesignApi.ts +145 -100
- package/src/controller/manage/DeployManageApi.ts +6 -3
- package/src/controller/manage/SuperAdminManageApi.ts +15 -6
- package/src/controller/manage/SysConfigMangeApi.ts +4 -1
- package/src/controller/manage/UserAccountManageApi.ts +6 -0
- package/src/controller/myinfo/AuthController.ts +4 -66
- package/src/controller/render/AppRenderController.ts +18 -15
- package/src/controller/test.controller.ts +1 -1
- package/src/index.ts +33 -4
- package/src/libs/crud-pro/interfaces.ts +1 -1
- package/src/libs/crud-pro/models/RequestCfgModel.ts +1 -1
- package/src/libs/crud-pro/models/SqlCfgModel.ts +1 -1
- package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +4 -4
- package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +4 -4
- package/src/libs/crud-pro/services/CrudProGenSqlService.ts +8 -8
- package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +2 -2
- package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +2 -2
- package/src/libs/global-config/global-config.ts +72 -0
- package/src/models/SystemTables.ts +0 -4
- package/src/service/AuthService.ts +13 -8
- package/src/service/EnumInfoService.ts +8 -3
- package/src/service/FileCenterService.ts +12 -6
- package/src/service/SysConfigService.ts +10 -6
- package/src/service/UserAccountService.ts +14 -4
- package/src/service/VisitStatService.ts +6 -2
- package/src/service/WorkbenchService.ts +7 -2
- package/src/service/anyapi/AnyApiService.ts +5 -2
- package/src/service/crudstd/CrudStdService.ts +13 -3
- package/src/service/curd/CurdMixByAccountService.ts +14 -6
- package/src/service/curd/CurdMixByDictService.ts +8 -2
- package/src/service/curd/CurdMixByLinkToCustomService.ts +1 -1
- package/src/service/curd/CurdMixBySysConfigService.ts +7 -2
- package/src/service/curd/CurdMixByWorkbenchService.ts +6 -2
- package/src/service/curd/CurdMixService.ts +2 -2
- package/src/service/curd/CurdMixUtils.ts +42 -12
- package/src/service/curd/CurdProService.ts +10 -10
- package/src/service/proxyapi/ProxyApiLoadService.ts +11 -3
- package/src/views/404_app.html +31 -0
- package/src/views/404_workbench.html +34 -0
- package/src/views/static/favicon.ico +0 -0
- package/dist/controller/medstatistic/MedAdminController.d.ts +0 -35
- package/dist/controller/medstatistic/MedAdminController.js +0 -205
- package/dist/controller/medstatistic/MedClientController.d.ts +0 -28
- package/dist/controller/medstatistic/MedClientController.js +0 -188
- package/dist/controller/medstatistic/MedMessageService.d.ts +0 -19
- package/dist/controller/medstatistic/MedMessageService.js +0 -95
- package/dist/controller/medstatistic/MedScoreService.d.ts +0 -21
- package/dist/controller/medstatistic/MedScoreService.js +0 -107
- package/dist/controller/medstatistic/constants.d.ts +0 -32
- package/dist/controller/medstatistic/constants.js +0 -43
- package/src/controller/medstatistic/MedAdminController.ts +0 -221
- package/src/controller/medstatistic/MedClientController.ts +0 -188
- package/src/controller/medstatistic/MedMessageService.ts +0 -89
- package/src/controller/medstatistic/MedScoreService.ts +0 -108
- package/src/controller/medstatistic/constants.ts +0 -63
|
@@ -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
|
};
|
|
@@ -2,8 +2,8 @@ import { Controller, Inject } from '@midwayjs/core';
|
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { CurdMixService } from '../../service/curd/CurdMixService';
|
|
4
4
|
import { IFuncCfgModel, IRequestCfgModel, IValidatorCfgItem } from '../../libs/crud-pro/interfaces';
|
|
5
|
-
import {KeyOfCrudTypes, KeysOfSimpleSQL} from '../../libs/crud-pro/models/keys';
|
|
6
|
-
import {
|
|
5
|
+
import { KeyOfCrudTypes, KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
|
|
6
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
7
7
|
import { UserAccountService } from '../../service/UserAccountService';
|
|
8
8
|
import { RelatedType } from '../../service/curd/CurdMixUtils';
|
|
9
9
|
import { BaseService } from '../../service/base/BaseService';
|
|
@@ -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
|
|
|
@@ -8,7 +8,8 @@ import { API_BASE_TYPE, ApiBaseService } from '../../service/base/ApiBaseService
|
|
|
8
8
|
import { CurdProService } from '../../service/curd/CurdProService';
|
|
9
9
|
import { CurdMixService } from '../../service/curd/CurdMixService';
|
|
10
10
|
import { IRequestCfgModel2 } from '../../models/bizmodels';
|
|
11
|
-
import {parseDatabaseName} from "../../libs/crud-pro/utils/DatabaseName";
|
|
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
|
|
|
@@ -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,7 +1,8 @@
|
|
|
1
1
|
import {Get, Controller, Inject, Query} from '@midwayjs/core';
|
|
2
2
|
import {Context} from '@midwayjs/koa';
|
|
3
3
|
import {BaseApiController} from '../base/BaseApiController';
|
|
4
|
-
import {
|
|
4
|
+
import { SystemTables} from '../../models/SystemTables';
|
|
5
|
+
import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
|
|
5
6
|
import {KeysOfSimpleSQL} from '../../libs/crud-pro/models/keys';
|
|
6
7
|
import {WorkbenchService} from '../../service/WorkbenchService';
|
|
7
8
|
import {CommonResult} from '../../libs/utils/common-dto';
|
|
@@ -37,6 +38,8 @@ export class DocGatewayController extends BaseApiController {
|
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
const {SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
|
|
42
|
+
|
|
40
43
|
await this.curdMixService.executeCrudByCfg({
|
|
41
44
|
data: {
|
|
42
45
|
pv: pv + 1
|
|
@@ -50,7 +53,7 @@ export class DocGatewayController extends BaseApiController {
|
|
|
50
53
|
sqlTable: SystemTables.sys_doc,
|
|
51
54
|
sqlSimpleName: KeysOfSimpleSQL.SIMPLE_UPDATE,
|
|
52
55
|
sqlDatabase: SystemDbName,
|
|
53
|
-
|
|
56
|
+
sqlDbType: SystemDbType,
|
|
54
57
|
});
|
|
55
58
|
}
|
|
56
59
|
|
|
@@ -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();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { All, Controller, Inject, Param } from '@midwayjs/core';
|
|
2
2
|
import { Context } from '@midwayjs/koa';
|
|
3
3
|
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
+
import * as _ from 'lodash';
|
|
4
5
|
import * as fs from 'fs/promises';
|
|
5
6
|
import * as fs2 from 'fs';
|
|
6
7
|
import * as path from 'path';
|
|
@@ -15,19 +16,18 @@ interface HttpGetRes {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
const localDir = path.join(__dirname, '../../../public/static'); // 本地文件存储目录
|
|
19
|
-
const notFoundListFile = path.join(localDir, '__404__list.json') // 404列表文件
|
|
20
|
-
|
|
21
19
|
|
|
22
20
|
function getPathConfig(ossName: string) {
|
|
23
21
|
const remoteBaseUrlMap = {
|
|
24
22
|
"cdnjsx": 'https://cdnjsx.oss-cn-shanghai.aliyuncs.com',
|
|
25
|
-
"i.alicdn.com":"https://i.alicdn.com",
|
|
26
|
-
"img.alicdn.com":"https://img.alicdn.com",
|
|
23
|
+
"i.alicdn.com": "https://i.alicdn.com",
|
|
24
|
+
"img.alicdn.com": "https://img.alicdn.com",
|
|
25
|
+
"at.alicdn.com": "https://at.alicdn.com",
|
|
27
26
|
};
|
|
28
|
-
|
|
27
|
+
let remoteBaseUrl = remoteBaseUrlMap[ossName];
|
|
29
28
|
if (!remoteBaseUrl) {
|
|
30
|
-
|
|
29
|
+
console.error(`getPathConfig ossName: ${ossName} 未配置`);
|
|
30
|
+
remoteBaseUrl = `https://${ossName}`
|
|
31
31
|
}
|
|
32
32
|
return {
|
|
33
33
|
remoteBaseUrl,
|
|
@@ -35,28 +35,13 @@ function getPathConfig(ossName: string) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
// 404列表缓存
|
|
39
|
-
let notFoundList = new Set();
|
|
40
|
-
|
|
41
38
|
|
|
42
|
-
// 初始化:加载404列表
|
|
43
|
-
async function init() {
|
|
44
|
-
try {
|
|
45
|
-
// 确保本地存储目录存在
|
|
46
|
-
await fs.mkdir(localDir, { recursive: true });
|
|
47
|
-
const data = await fs.readFile(notFoundListFile, 'utf8');
|
|
48
39
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (error.code !== 'ENOENT') {
|
|
53
|
-
console.error('读取404列表失败:', error);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
40
|
+
// 404列表缓存
|
|
41
|
+
let notFoundList = new Set();
|
|
42
|
+
let notFoundListIsInit = false;
|
|
57
43
|
|
|
58
44
|
|
|
59
|
-
init();
|
|
60
45
|
|
|
61
46
|
/**
|
|
62
47
|
* 静态文件代理功能
|
|
@@ -66,6 +51,44 @@ export class StaticController extends BaseApiController {
|
|
|
66
51
|
@Inject()
|
|
67
52
|
protected ctx: Context;
|
|
68
53
|
|
|
54
|
+
constructor() {
|
|
55
|
+
super();
|
|
56
|
+
this.initNotFoundList();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
private getLocalPaths(): any {
|
|
61
|
+
const appDir = this.app.getAppDir();
|
|
62
|
+
const localDir = path.join(appDir, './public/static'); // 本地文件存储目录
|
|
63
|
+
const notFoundListFile = path.join(localDir, '__404__list.json') // 404列表文件
|
|
64
|
+
return {
|
|
65
|
+
localDir,
|
|
66
|
+
notFoundListFile
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
private async initNotFoundList() {
|
|
72
|
+
if (notFoundListIsInit) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
notFoundListIsInit = true;
|
|
76
|
+
|
|
77
|
+
const { localDir, notFoundListFile } = this.getLocalPaths();
|
|
78
|
+
try {
|
|
79
|
+
// 确保本地存储目录存在
|
|
80
|
+
await fs.mkdir(localDir, { recursive: true });
|
|
81
|
+
const data = await fs.readFile(notFoundListFile, 'utf8');
|
|
82
|
+
|
|
83
|
+
notFoundList = new Set(JSON.parse(data));
|
|
84
|
+
console.log(`已加载${notFoundList.size}个404记录`);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
if (error.code !== 'ENOENT') {
|
|
87
|
+
console.error('读取404列表失败:', error);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
69
92
|
private async responseLocalFile(localFilePath: string, localHeaderPath: string, relativePath: string): Promise<boolean> {
|
|
70
93
|
|
|
71
94
|
const headers = {
|
|
@@ -128,6 +151,7 @@ export class StaticController extends BaseApiController {
|
|
|
128
151
|
@All('/:ossName/:relativePath+')
|
|
129
152
|
async proxyStaticFile(@Param('ossName') ossName: string, @Param('relativePath') relativePath: string) {
|
|
130
153
|
|
|
154
|
+
const { localDir } = this.getLocalPaths();
|
|
131
155
|
const PATH_CONFIG = getPathConfig(ossName);
|
|
132
156
|
|
|
133
157
|
|
|
@@ -195,6 +219,7 @@ export class StaticController extends BaseApiController {
|
|
|
195
219
|
|
|
196
220
|
// 保存404列表
|
|
197
221
|
async saveNotFoundList() {
|
|
222
|
+
const { notFoundListFile } = this.getLocalPaths();
|
|
198
223
|
try {
|
|
199
224
|
// 确保存储404列表的目录存在
|
|
200
225
|
const dir = path.dirname(notFoundListFile);
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {Controller, Get, Inject} from '@midwayjs/core';
|
|
2
|
-
import {Context} from '@midwayjs/koa';
|
|
3
|
-
import {BaseApiController} from './base/BaseApiController';
|
|
4
|
-
import {WorkbenchService} from '../service/WorkbenchService';
|
|
5
|
-
import {createRenderUtils} from
|
|
6
|
-
import {privateAES} from
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { Controller, Get, Inject } from '@midwayjs/core';
|
|
2
|
+
import { Context } from '@midwayjs/koa';
|
|
3
|
+
import { BaseApiController } from './base/BaseApiController';
|
|
4
|
+
import { WorkbenchService } from '../service/WorkbenchService';
|
|
5
|
+
import { createRenderUtils } from '../libs/utils/render-utils';
|
|
6
|
+
import { privateAES } from '../libs/utils/crypto-utils';
|
|
9
7
|
|
|
10
8
|
@Controller('/')
|
|
11
9
|
export class HomeController extends BaseApiController {
|
|
@@ -36,14 +34,14 @@ export class HomeController extends BaseApiController {
|
|
|
36
34
|
|
|
37
35
|
const userInfo = this.getUserSessionInfo();
|
|
38
36
|
|
|
39
|
-
const fatcmscsrftoken = await privateAES.time_encrypt_utf8_base64(
|
|
37
|
+
const fatcmscsrftoken = await privateAES.time_encrypt_utf8_base64('' + Date.now());
|
|
40
38
|
|
|
41
39
|
const utils = createRenderUtils({
|
|
42
40
|
ctx: this.ctx,
|
|
43
41
|
userInfo,
|
|
44
42
|
workbenchInfo,
|
|
45
43
|
package_assets: workbenchInfo.package_assets,
|
|
46
|
-
fatcmscsrftoken
|
|
44
|
+
fatcmscsrftoken,
|
|
47
45
|
});
|
|
48
46
|
|
|
49
47
|
return this.ctx.renderString(html_content, { workbenchInfo, userInfo, utils }, { viewEngine: 'ejs' });
|