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.
Files changed (117) hide show
  1. package/dist/config/config.default.js +52 -15
  2. package/dist/controller/base/BaseApiController.js +9 -6
  3. package/dist/controller/gateway/CrudMtdGatewayController.js +4 -1
  4. package/dist/controller/gateway/DocGatewayController.js +13 -8
  5. package/dist/controller/gateway/StaticController.d.ts +3 -0
  6. package/dist/controller/gateway/StaticController.js +41 -21
  7. package/dist/controller/home.controller.js +2 -2
  8. package/dist/controller/manage/CrudStandardDesignApi.js +89 -74
  9. package/dist/controller/manage/DeployManageApi.js +6 -4
  10. package/dist/controller/manage/SuperAdminManageApi.js +12 -8
  11. package/dist/controller/manage/SysConfigMangeApi.js +3 -1
  12. package/dist/controller/manage/UserAccountManageApi.d.ts +1 -1
  13. package/dist/controller/manage/UserAccountManageApi.js +5 -0
  14. package/dist/controller/myinfo/AuthController.d.ts +0 -4
  15. package/dist/controller/myinfo/AuthController.js +0 -53
  16. package/dist/controller/render/AppRenderController.js +4 -2
  17. package/dist/controller/test.controller.js +1 -1
  18. package/dist/index.d.ts +28 -4
  19. package/dist/index.js +28 -4
  20. package/dist/libs/crud-pro/interfaces.d.ts +1 -1
  21. package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +1 -1
  22. package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +1 -1
  23. package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +4 -4
  24. package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +4 -4
  25. package/dist/libs/crud-pro/services/CrudProGenSqlService.js +8 -8
  26. package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +2 -2
  27. package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +2 -2
  28. package/dist/libs/global-config/global-config.d.ts +39 -0
  29. package/dist/libs/global-config/global-config.js +32 -0
  30. package/dist/models/SystemTables.d.ts +0 -3
  31. package/dist/models/SystemTables.js +1 -4
  32. package/dist/service/AuthService.js +8 -5
  33. package/dist/service/EnumInfoService.js +7 -4
  34. package/dist/service/FileCenterService.js +13 -9
  35. package/dist/service/SysConfigService.js +4 -2
  36. package/dist/service/UserAccountService.js +10 -6
  37. package/dist/service/VisitStatService.js +4 -2
  38. package/dist/service/WorkbenchService.js +4 -2
  39. package/dist/service/anyapi/AnyApiService.js +4 -2
  40. package/dist/service/crudstd/CrudStdService.js +7 -3
  41. package/dist/service/curd/CurdMixByAccountService.js +12 -6
  42. package/dist/service/curd/CurdMixByDictService.js +4 -2
  43. package/dist/service/curd/CurdMixByLinkToCustomService.js +1 -1
  44. package/dist/service/curd/CurdMixBySysConfigService.js +4 -2
  45. package/dist/service/curd/CurdMixByWorkbenchService.js +4 -2
  46. package/dist/service/curd/CurdMixService.d.ts +1 -1
  47. package/dist/service/curd/CurdMixService.js +2 -2
  48. package/dist/service/curd/CurdMixUtils.d.ts +7 -0
  49. package/dist/service/curd/CurdMixUtils.js +31 -1
  50. package/dist/service/curd/CurdProService.d.ts +3 -3
  51. package/dist/service/curd/CurdProService.js +9 -9
  52. package/dist/service/proxyapi/ProxyApiLoadService.js +7 -4
  53. package/dist/views/404_app.html +31 -0
  54. package/dist/views/404_workbench.html +34 -0
  55. package/dist/views/static/favicon.ico +0 -0
  56. package/package.json +5 -1
  57. package/src/config/config.default.ts +58 -27
  58. package/src/controller/base/BaseApiController.ts +14 -14
  59. package/src/controller/gateway/CrudMtdGatewayController.ts +6 -2
  60. package/src/controller/gateway/DocGatewayController.ts +13 -5
  61. package/src/controller/gateway/StaticController.ts +50 -25
  62. package/src/controller/home.controller.ts +8 -10
  63. package/src/controller/manage/CrudStandardDesignApi.ts +145 -100
  64. package/src/controller/manage/DeployManageApi.ts +6 -3
  65. package/src/controller/manage/SuperAdminManageApi.ts +15 -6
  66. package/src/controller/manage/SysConfigMangeApi.ts +4 -1
  67. package/src/controller/manage/UserAccountManageApi.ts +6 -0
  68. package/src/controller/myinfo/AuthController.ts +4 -66
  69. package/src/controller/render/AppRenderController.ts +18 -15
  70. package/src/controller/test.controller.ts +1 -1
  71. package/src/index.ts +33 -4
  72. package/src/libs/crud-pro/interfaces.ts +1 -1
  73. package/src/libs/crud-pro/models/RequestCfgModel.ts +1 -1
  74. package/src/libs/crud-pro/models/SqlCfgModel.ts +1 -1
  75. package/src/libs/crud-pro/services/CrudProExecuteSqlService.ts +4 -4
  76. package/src/libs/crud-pro/services/CrudProGenSqlCondition.ts +4 -4
  77. package/src/libs/crud-pro/services/CrudProGenSqlService.ts +8 -8
  78. package/src/libs/crud-pro/services/CrudProOriginToExecuteSql.ts +2 -2
  79. package/src/libs/crud-pro/utils/sqlConvert/convertColumnName.ts +2 -2
  80. package/src/libs/global-config/global-config.ts +72 -0
  81. package/src/models/SystemTables.ts +0 -4
  82. package/src/service/AuthService.ts +13 -8
  83. package/src/service/EnumInfoService.ts +8 -3
  84. package/src/service/FileCenterService.ts +12 -6
  85. package/src/service/SysConfigService.ts +10 -6
  86. package/src/service/UserAccountService.ts +14 -4
  87. package/src/service/VisitStatService.ts +6 -2
  88. package/src/service/WorkbenchService.ts +7 -2
  89. package/src/service/anyapi/AnyApiService.ts +5 -2
  90. package/src/service/crudstd/CrudStdService.ts +13 -3
  91. package/src/service/curd/CurdMixByAccountService.ts +14 -6
  92. package/src/service/curd/CurdMixByDictService.ts +8 -2
  93. package/src/service/curd/CurdMixByLinkToCustomService.ts +1 -1
  94. package/src/service/curd/CurdMixBySysConfigService.ts +7 -2
  95. package/src/service/curd/CurdMixByWorkbenchService.ts +6 -2
  96. package/src/service/curd/CurdMixService.ts +2 -2
  97. package/src/service/curd/CurdMixUtils.ts +42 -12
  98. package/src/service/curd/CurdProService.ts +10 -10
  99. package/src/service/proxyapi/ProxyApiLoadService.ts +11 -3
  100. package/src/views/404_app.html +31 -0
  101. package/src/views/404_workbench.html +34 -0
  102. package/src/views/static/favicon.ico +0 -0
  103. package/dist/controller/medstatistic/MedAdminController.d.ts +0 -35
  104. package/dist/controller/medstatistic/MedAdminController.js +0 -205
  105. package/dist/controller/medstatistic/MedClientController.d.ts +0 -28
  106. package/dist/controller/medstatistic/MedClientController.js +0 -188
  107. package/dist/controller/medstatistic/MedMessageService.d.ts +0 -19
  108. package/dist/controller/medstatistic/MedMessageService.js +0 -95
  109. package/dist/controller/medstatistic/MedScoreService.d.ts +0 -21
  110. package/dist/controller/medstatistic/MedScoreService.js +0 -107
  111. package/dist/controller/medstatistic/constants.d.ts +0 -32
  112. package/dist/controller/medstatistic/constants.js +0 -43
  113. package/src/controller/medstatistic/MedAdminController.ts +0 -221
  114. package/src/controller/medstatistic/MedClientController.ts +0 -188
  115. package/src/controller/medstatistic/MedMessageService.ts +0 -89
  116. package/src/controller/medstatistic/MedScoreService.ts +0 -108
  117. package/src/controller/medstatistic/constants.ts +0 -63
@@ -1,11 +1,12 @@
1
- import {Inject, Controller, Get, Param} from '@midwayjs/core';
2
- import {Context} from '@midwayjs/koa';
3
- import {BaseApiController} from '../base/BaseApiController';
4
- import {KeysOfSimpleSQL} from '../../libs/crud-pro/models/keys';
5
- import {SystemDbName, SystemDbType, SystemTables} from '../../models/SystemTables';
6
- import {WorkbenchService} from '../../service/WorkbenchService';
7
- import {createRenderUtils} from "../../libs/utils/render-utils";
8
- import {privateAES} from "../../libs/utils/crypto-utils";
1
+ import { Inject, Controller, Get, Param } from '@midwayjs/core';
2
+ import { Context } from '@midwayjs/koa';
3
+ import { BaseApiController } from '../base/BaseApiController';
4
+ import { KeysOfSimpleSQL } from '../../libs/crud-pro/models/keys';
5
+ import { SystemTables } from '../../models/SystemTables';
6
+ import { WorkbenchService } from '../../service/WorkbenchService';
7
+ import { createRenderUtils } from "../../libs/utils/render-utils";
8
+ import { privateAES } from "../../libs/utils/crypto-utils";
9
+ import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
9
10
 
10
11
 
11
12
  /**
@@ -21,34 +22,36 @@ export class AppRenderController extends BaseApiController {
21
22
 
22
23
  @Get('/:appPath+')
23
24
  async home(@Param('appPath') appPath: string): Promise<string> {
25
+ const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
26
+
24
27
  const appPathArr = appPath.split('/');
25
28
  const appCode = appPathArr[0];
26
29
 
27
30
  const res = await this.curdMixService.executeCrudByCfg(
28
- {condition: {app_code: appCode}},
31
+ { condition: { app_code: appCode } },
29
32
  {
30
33
  sqlTable: SystemTables.sys_app,
31
34
  sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
32
35
  sqlDatabase: SystemDbName,
33
- sqlDdType: SystemDbType,
36
+ sqlDbType: SystemDbType,
34
37
  }
35
38
  );
36
39
 
37
- const {row: appInfo} = res.getResModel();
40
+ const { row: appInfo } = res.getResModel();
38
41
  if (!appInfo) {
39
42
  this.ctx.status = 404;
40
- return this.ctx.render('404_app', {appCode, errorMsg: ' 应用不存在'});
43
+ return this.ctx.render('404_app', { appCode, errorMsg: ' 应用不存在' });
41
44
  }
42
45
 
43
46
  if (appInfo.status !== 1) {
44
47
  this.ctx.status = 404;
45
- return this.ctx.render('404_app', {appCode, errorMsg: ' 应用已下线'});
48
+ return this.ctx.render('404_app', { appCode, errorMsg: ' 应用已下线' });
46
49
  }
47
50
 
48
51
  const isSupportWorkbench = await this.isSupportCurrentWorkbench(appInfo);
49
52
  if (!isSupportWorkbench) {
50
53
  this.ctx.status = 404;
51
- return this.ctx.render('404_app', {appCode, errorMsg: ' 应用没有绑定此站点'});
54
+ return this.ctx.render('404_app', { appCode, errorMsg: ' 应用没有绑定此站点' });
52
55
  }
53
56
 
54
57
  const workbenchInfo = await this.workbenchService.getCurrentHostWorkbenchInfo();
@@ -61,7 +64,7 @@ export class AppRenderController extends BaseApiController {
61
64
  ctx: this.ctx,
62
65
  appInfo, workbenchInfo, userInfo, package_assets: appInfo.package_assets, fatcmscsrftoken
63
66
  });
64
- return this.ctx.renderString(html_content, {appInfo, workbenchInfo, userInfo, utils}, {viewEngine: 'ejs'});
67
+ return this.ctx.renderString(html_content, { appInfo, workbenchInfo, userInfo, utils }, { viewEngine: 'ejs' });
65
68
  }
66
69
 
67
70
 
@@ -22,7 +22,7 @@ export class TestApiController extends BaseApiController{
22
22
  sqlTable: "test_table1",
23
23
  sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
24
24
  sqlDatabase: "postgres_test1",
25
- sqlDdType: SqlDbType.postgres,
25
+ sqlDbType: SqlDbType.postgres,
26
26
  updateCfg: {},
27
27
  };
28
28
 
package/src/index.ts CHANGED
@@ -30,10 +30,6 @@ export * from './controller/manage/SysConfigMangeApi';
30
30
  export * from './controller/manage/SystemInfoManageApi';
31
31
  export * from './controller/manage/UserAccountManageApi';
32
32
  export * from './controller/manage/WorkbenchMangeApi';
33
- export * from './controller/medstatistic/MedAdminController';
34
- export * from './controller/medstatistic/MedClientController';
35
- export * from './controller/medstatistic/MedMessageService';
36
- export * from './controller/medstatistic/MedScoreService';
37
33
  export * from './controller/myinfo/AuthController';
38
34
  export * from './controller/myinfo/MyInfoController';
39
35
  export * from './controller/render/AppRenderController';
@@ -43,6 +39,7 @@ export * from './filter/notfound.filter';
43
39
  export * from './middleware/forbidden.middleware';
44
40
  export * from './middleware/global.middleware';
45
41
  export * from './middleware/tx.middleware';
42
+ export * from './middleware/permission.middleware';
46
43
  export * from './service/AuthService';
47
44
  export * from './service/EnumInfoService';
48
45
  export * from './service/FileCenterService';
@@ -68,3 +65,35 @@ export * from './service/curd/CurdMixService';
68
65
  export * from './service/curd/CurdProService';
69
66
  export * from './service/proxyapi/ProxyApiLoadService';
70
67
  export * from './service/proxyapi/ProxyApiService';
68
+ export * from './models/userSession';
69
+ export * from './models/bizmodels';
70
+ export * from './models/SystemEntities';
71
+ export * from './models/SystemPerm';
72
+ export * from './models/contextLogger';
73
+ export * from './models/devops';
74
+ export * from './models/SystemTables';
75
+
76
+
77
+ export * from './libs/utils/common-dto';
78
+ export * from './libs/utils/crypto-utils';
79
+ export * from './libs/utils/fatcms-request';
80
+ export * from './libs/utils/functions';
81
+ export * from './libs/utils/ordernum-utils';
82
+ export * from './libs/utils/parseConfig';
83
+
84
+ export * from './libs/crud-pro/CrudPro';
85
+ export * from './libs/crud-pro/defaultConfigs';
86
+ export * from './libs/crud-pro/exceptions';
87
+ export * from './libs/crud-pro/interfaces';
88
+
89
+ export * from './libs/crud-pro/models/ExecuteContext';
90
+ export * from './libs/crud-pro/models/FuncContext';
91
+ export * from './libs/crud-pro/models/RequestModel';
92
+ export * from './libs/crud-pro/models/SqlCfgModel';
93
+ export * from './libs/crud-pro/models/Transaction';
94
+ export * from './libs/crud-pro/models/keys';
95
+ export * from './libs/crud-pro/models/ExecuteContextFunc';
96
+ export * from './libs/crud-pro/models/RequestCfgModel';
97
+ export * from './libs/crud-pro/models/SqlSegArg';
98
+
99
+ export * from './libs/global-config/global-config';
@@ -102,7 +102,7 @@ export interface IBaseCfgModel {
102
102
  sqlTable?: string; // 可以为空. originSql中不包含@@table时可以为空
103
103
  sqlSchema?: string; // 可以为空
104
104
  sqlDatabase?: string; // 可以为空,用此字段进行connection的选择和切换。配合getBizConnectionPool使用
105
- sqlDdType?: SqlDbType; // 数据库类型,mysql(默认) 、postgres
105
+ sqlDbType?: SqlDbType; // 数据库类型,mysql(默认) 、postgres
106
106
  maxLimit?: number; // 最大一次性返回的数量
107
107
  columns?: string | string[]; // "columns": "id,name,age,sex,addr",
108
108
  columnsRelation?: ColumnRelation[];
@@ -38,7 +38,7 @@ class RequestCfgModel {
38
38
  sqlTable: string; // 可以为空. originSql中不包含@@table时可以为空
39
39
  sqlSchema?: string; // 可以为空
40
40
  sqlDatabase?: string; // 可以为空,用此字段进行connection的选择和切换。配合getBizConnectionPool使用
41
- sqlDdType?: SqlDbType; // 数据库类型,mysql(默认) 、postgres
41
+ sqlDbType?: SqlDbType; // 数据库类型,mysql(默认) 、postgres
42
42
  maxLimit = DEFAULT_MAX_LIMIT; // 最大一次性返回的数量
43
43
  method: string; // 不能为空
44
44
  transactionEnable: boolean; // 是否开启事务,默认不开启,每条语句都是autocommit
@@ -11,7 +11,7 @@ class SqlCfgModel {
11
11
  sqlTable: string; // 可以为空. originSql中不包含@@table时可以为空
12
12
  sqlSchema?: string; // 可以为空
13
13
  sqlDatabase?: string; // 可以为空,用此字段进行connection的选择和切换。配合getBizConnectionPool使用
14
- sqlDdType?: SqlDbType; // 数据库类型,mysql(默认) 、postgres
14
+ sqlDbType?: SqlDbType; // 数据库类型,mysql(默认) 、postgres
15
15
  maxLimit: number; // 最大一次性返回的数量
16
16
  resName: string;
17
17
  resPicker: KeysOfSqlResPicker;
@@ -39,7 +39,7 @@ class CrudProExecuteSqlService extends CrudProServiceBase {
39
39
  let sqlRes: any;
40
40
  let queryRes : any;
41
41
 
42
- if (sqlCfgModel.sqlDdType === SqlDbType.postgres) { // import { PoolClient } from 'pg';
42
+ if (sqlCfgModel.sqlDbType === SqlDbType.postgres) { // import { PoolClient } from 'pg';
43
43
 
44
44
  const pgClient: PoolClient = connection as any;
45
45
  const pgSql = replaceQuestionMarks(sqlCfgModel.executeSql);
@@ -55,7 +55,7 @@ class CrudProExecuteSqlService extends CrudProServiceBase {
55
55
 
56
56
  }
57
57
 
58
- else if (sqlCfgModel.sqlDdType === SqlDbType.sqlserver) {
58
+ else if (sqlCfgModel.sqlDbType === SqlDbType.sqlserver) {
59
59
 
60
60
  const mssql = replaceQuestionMarksForMssql(sqlCfgModel.executeSql);
61
61
 
@@ -245,14 +245,14 @@ class CrudProExecuteSqlService extends CrudProServiceBase {
245
245
 
246
246
  // 增删改res的内容是修改结果:包括: insert\delete\update
247
247
  if (KeysOfSqlResPicker.UPDATE_RESULT === resPicker) {
248
- if (sqlCfgModel.sqlDdType === SqlDbType.postgres) {
248
+ if (sqlCfgModel.sqlDbType === SqlDbType.postgres) {
249
249
  return {
250
250
  insertId: _.get(queryRes,'rows[0].id'),
251
251
  affectedRows: _.get(queryRes,'rowCount')
252
252
  }
253
253
  }
254
254
 
255
- if (sqlCfgModel.sqlDdType === SqlDbType.sqlserver) {
255
+ if (sqlCfgModel.sqlDbType === SqlDbType.sqlserver) {
256
256
  return {
257
257
  insertId: _.get(queryRes,'recordset[0].id'),
258
258
  affectedRows: _.get(queryRes,'rowsAffected[0]')
@@ -212,7 +212,7 @@ class CrudProGenSqlCondition {
212
212
  tmpArgList.push(value0);
213
213
  tmpSql = `${toSqlColumnName(key)} COLLATE UTF8MB4_GENERAL_CI like concat(?, '%')`; // like前缀匹配
214
214
 
215
- if (this.sqlCfg.sqlDdType === SqlDbType.postgres) {
215
+ if (this.sqlCfg.sqlDbType === SqlDbType.postgres) {
216
216
  tmpSql = `${toSqlColumnName(key)} like concat(?, '%')`; // like前缀匹配
217
217
  }
218
218
 
@@ -221,7 +221,7 @@ class CrudProGenSqlCondition {
221
221
  tmpSql = `${toSqlColumnName(key)} COLLATE UTF8MB4_GENERAL_CI not like concat(?, '%')`;
222
222
 
223
223
 
224
- if (this.sqlCfg.sqlDdType === SqlDbType.postgres) {
224
+ if (this.sqlCfg.sqlDbType === SqlDbType.postgres) {
225
225
  tmpSql = `${toSqlColumnName(key)} not like concat(?, '%')`;
226
226
  }
227
227
 
@@ -232,7 +232,7 @@ class CrudProGenSqlCondition {
232
232
  tmpArgList.push(value0);
233
233
  tmpSql = `${toSqlColumnName(key)} COLLATE UTF8MB4_GENERAL_CI like concat('%', ?, '%')`; // like包含
234
234
 
235
- if (this.sqlCfg.sqlDdType === SqlDbType.postgres) {
235
+ if (this.sqlCfg.sqlDbType === SqlDbType.postgres) {
236
236
  tmpSql = `${toSqlColumnName(key)} like concat('%', ?, '%')`; // like包含
237
237
  }
238
238
 
@@ -240,7 +240,7 @@ class CrudProGenSqlCondition {
240
240
  tmpArgList.push(value0);
241
241
  tmpSql = `${toSqlColumnName(key)} COLLATE UTF8MB4_GENERAL_CI not like concat('%',?, '%')`; // like不包含
242
242
 
243
- if (this.sqlCfg.sqlDdType === SqlDbType.postgres) {
243
+ if (this.sqlCfg.sqlDbType === SqlDbType.postgres) {
244
244
  tmpSql = `${toSqlColumnName(key)} not like concat('%',?, '%')`; // like不包含
245
245
  }
246
246
 
@@ -97,10 +97,10 @@ class CrudProGenSqlService extends CrudProServiceBase {
97
97
  * @private
98
98
  */
99
99
  private generateOriginSqlForDelete(cfgModel: RequestCfgModel) : string {
100
- if (cfgModel.sqlDdType === SqlDbType.postgres) {
100
+ if (cfgModel.sqlDbType === SqlDbType.postgres) {
101
101
  return 'delete from @@table where @@asWhere:condition ';
102
102
  }
103
- if (cfgModel.sqlDdType === SqlDbType.sqlserver) {
103
+ if (cfgModel.sqlDbType === SqlDbType.sqlserver) {
104
104
  return 'delete from @@table where @@asWhere:condition ';
105
105
  }
106
106
  return 'delete from @@table where @@asWhere:condition limit 100 '; // 删除操作,不能一次性删除太多
@@ -112,7 +112,7 @@ class CrudProGenSqlService extends CrudProServiceBase {
112
112
  * @private
113
113
  */
114
114
  private generateOriginSqlForDuplicateInsert(cfgModel: RequestCfgModel) : string {
115
- if (cfgModel.sqlDdType === SqlDbType.postgres) {
115
+ if (cfgModel.sqlDbType === SqlDbType.postgres) {
116
116
  const uniqueColumn = cfgModel.uniqueColumn ; // id
117
117
  if (!Array.isArray(uniqueColumn) || uniqueColumn.length === 0) {
118
118
  throw new CommonException(Exceptions.CFG_ERROR_POSTGRES_UNIQUE_COLUMNS_NULL)
@@ -124,7 +124,7 @@ class CrudProGenSqlService extends CrudProServiceBase {
124
124
  }
125
125
 
126
126
 
127
- if (cfgModel.sqlDdType === SqlDbType.sqlserver) {
127
+ if (cfgModel.sqlDbType === SqlDbType.sqlserver) {
128
128
  const uniqueColumn = cfgModel.uniqueColumn ; // id
129
129
  if (uniqueColumn.length !== 1) {
130
130
  throw new CommonException(Exceptions.CFG_UNIQUE_COLUMN_COUNT_MUST_ONE);
@@ -160,10 +160,10 @@ class CrudProGenSqlService extends CrudProServiceBase {
160
160
  * @private
161
161
  */
162
162
  private generateOriginSqlForInsert(cfgModel: RequestCfgModel): string {
163
- if (cfgModel.sqlDdType === SqlDbType.postgres) {
163
+ if (cfgModel.sqlDbType === SqlDbType.postgres) {
164
164
  return 'insert into @@table ( @@asInsertKeys:data ) values( @@asInsertValues:data ) RETURNING * ';
165
165
  }
166
- if (cfgModel.sqlDdType === SqlDbType.sqlserver) {
166
+ if (cfgModel.sqlDbType === SqlDbType.sqlserver) {
167
167
  return 'insert into @@table ( @@asInsertKeys:data ) OUTPUT INSERTED.* values( @@asInsertValues:data ) ';
168
168
  }
169
169
  return 'insert into @@table ( @@asInsertKeys:data ) values( @@asInsertValues:data )'; // 关键字的前后,必须有空格
@@ -177,12 +177,12 @@ class CrudProGenSqlService extends CrudProServiceBase {
177
177
 
178
178
  const reqCfgModel = exeCtx.getCfgModel();
179
179
  const sqlCfgList = reqCfgModel.sqlCfgList || [];
180
- const { sqlTable, sqlSchema, sqlDatabase, sqlDdType, maxLimit, columns, columnsRelation } = reqCfgModel;
180
+ const { sqlTable, sqlSchema, sqlDatabase, sqlDbType, maxLimit, columns, columnsRelation } = reqCfgModel;
181
181
 
182
182
  for (let i = 0; i < sqlCfgList.length; i++) {
183
183
  const sqlCfgModel = sqlCfgList[i];
184
184
 
185
- sqlCfgModel.sqlDdType = MixinUtils.selectNotEmpty(sqlCfgModel.sqlDdType, sqlDdType);
185
+ sqlCfgModel.sqlDbType = MixinUtils.selectNotEmpty(sqlCfgModel.sqlDbType, sqlDbType);
186
186
  sqlCfgModel.sqlDatabase = MixinUtils.selectNotEmpty(sqlCfgModel.sqlDatabase, sqlDatabase);
187
187
  sqlCfgModel.sqlSchema = MixinUtils.selectNotEmpty(sqlCfgModel.sqlSchema, sqlSchema);
188
188
  sqlCfgModel.sqlTable = MixinUtils.selectNotEmpty(sqlCfgModel.sqlTable, sqlTable);
@@ -226,11 +226,11 @@ class CrudProOriginToExecuteSql extends CrudProServiceBase {
226
226
  const reqLimit = req.limit;
227
227
  const limit = Math.min(maxLimit, reqLimit);
228
228
 
229
- if (sqlCfg.sqlDdType === SqlDbType.postgres) {
229
+ if (sqlCfg.sqlDbType === SqlDbType.postgres) {
230
230
  return new SqlSegArg(' LIMIT ? OFFSET ? ', [limit, req.offset]);
231
231
  }
232
232
 
233
- if (sqlCfg.sqlDdType === SqlDbType.sqlserver) {
233
+ if (sqlCfg.sqlDbType === SqlDbType.sqlserver) {
234
234
  return new SqlSegArg(' OFFSET ? ROWS FETCH NEXT ? ROWS ONLY ', [ req.offset, limit]);
235
235
  }
236
236
 
@@ -3,10 +3,10 @@ import {SqlDbType} from "../../models/keys";
3
3
 
4
4
 
5
5
  function toSqlColumnName(columnName: string, sqlCfgModel: SqlCfgModel): string {
6
- if (sqlCfgModel.sqlDdType === SqlDbType.postgres) {
6
+ if (sqlCfgModel.sqlDbType === SqlDbType.postgres) {
7
7
  return '"' + columnName + '"';
8
8
  }
9
- if (sqlCfgModel.sqlDdType === SqlDbType.sqlserver) {
9
+ if (sqlCfgModel.sqlDbType === SqlDbType.sqlserver) {
10
10
  return '[' + columnName + ']';
11
11
  }
12
12
  return '`' + columnName + '`';
@@ -0,0 +1,72 @@
1
+ import { SqlDbType } from '../crud-pro/models/keys';
2
+
3
+ interface IGlobalStaticConfig {
4
+ /**
5
+ * CrudStd: 业务系统自定义的修改cfgModel
6
+ * @param reqJson
7
+ * @param cfgModel
8
+ * @param appInfo
9
+ * @param ctx
10
+ */
11
+ bizUpdateCfgModelForCrudStd(reqJson: any, cfgModel: any, appInfo: any, ctx: any): Promise<any>;
12
+
13
+ /**
14
+ * CrudMtd: 业务系统自定义的修改cfgModel
15
+ * @param reqJson
16
+ * @param cfgModel
17
+ * @param methodInfo
18
+ * @param ctx
19
+ */
20
+ bizUpdateCfgModelForCrudMtd(reqJson: any, cfgModel: any, methodInfo: any, ctx: any): Promise<any>;
21
+
22
+
23
+ /**
24
+ * 生成用户的账号ID,业务系统可以生成类似工号的ID
25
+ * @param userSubmitData
26
+ */
27
+ generateUserAccountId(userSubmitData: any): Promise<string>;
28
+
29
+
30
+ /**
31
+ * 将业务系统表中的userId映射为fatcms的UserAccountId
32
+ * @param bizTableUserId 业余系统表中的UserId
33
+ */
34
+ toFatcmsUserAccountId(bizTableUserId: any): string;
35
+
36
+ SystemDbName: string;
37
+ SystemDbType: SqlDbType;
38
+ }
39
+
40
+ const noop = () => {
41
+ return Promise.resolve();
42
+ };
43
+
44
+ class GlobalStaticConfig {
45
+ private configObject: IGlobalStaticConfig;
46
+ constructor() {
47
+ this.configObject = {
48
+ bizUpdateCfgModelForCrudStd: noop,
49
+ bizUpdateCfgModelForCrudMtd: noop,
50
+ generateUserAccountId: null,
51
+ toFatcmsUserAccountId: (bizTableUserId: any) => {
52
+ return bizTableUserId;
53
+ },
54
+ SystemDbName: 'fatcms',
55
+ SystemDbType: SqlDbType.mysql,
56
+ };
57
+ }
58
+ public getConfig(): IGlobalStaticConfig {
59
+ return this.configObject as IGlobalStaticConfig;
60
+ }
61
+
62
+ public setConfig(configObject: any) {
63
+ if (!configObject || typeof configObject !== 'object') {
64
+ throw new Error('参数configObject不能为空');
65
+ }
66
+ Object.assign(this.configObject, configObject);
67
+ }
68
+ }
69
+
70
+ const GLOBAL_STATIC_CONFIG = new GlobalStaticConfig();
71
+
72
+ export { GLOBAL_STATIC_CONFIG };
@@ -1,5 +1,3 @@
1
- import {SqlDbType} from "../libs/crud-pro/models/keys";
2
-
3
1
  export const SystemTables = {
4
2
  sys_workbench: 'sys_workbench',
5
3
  sys_user_account: 'sys_user_account',
@@ -24,7 +22,5 @@ export const SystemTables = {
24
22
  sys_visit_stats: 'sys_visit_stats',
25
23
  };
26
24
 
27
- export const SystemDbName = 'fatcms';
28
- export const SystemDbType = SqlDbType.mysql;
29
25
 
30
26
  export const SystemDevOpsWorkbench = 'devops';
@@ -5,12 +5,13 @@ import { CurdMixService } from './curd/CurdMixService';
5
5
  import * as md5 from 'md5';
6
6
  import { UserAccountService } from './UserAccountService';
7
7
  import { createUniqueId } from '../libs/utils/functions';
8
- import {IConsumerUserInfo, ISessionInfo, SYS_ACCOUNT_TYPE} from '../models/userSession';
9
- import {SystemDbName, SystemDbType, SystemTables} from '../models/SystemTables';
8
+ import { IConsumerUserInfo, ISessionInfo, SYS_ACCOUNT_TYPE } from '../models/userSession';
9
+ import { SystemTables } from '../models/SystemTables';
10
10
  import { UserSessionService } from './UserSessionService';
11
11
  import { CommonResult } from '../libs/utils/common-dto';
12
12
  import { isEnableSuperAdmin } from "../libs/utils/fatcms-request";
13
- import {CommonException} from "../libs/crud-pro/exceptions";
13
+ import { CommonException } from "../libs/crud-pro/exceptions";
14
+ import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
14
15
 
15
16
  @Provide()
16
17
  export class AuthService {
@@ -94,7 +95,7 @@ export class AuthService {
94
95
  nickName: consumerUserInfo.nickName,
95
96
  avatar: consumerUserInfo.avatar,
96
97
  roleCodes: [],
97
- functionCodes:[],
98
+ functionCodes: [],
98
99
  loginName: consumerUserInfo.loginName,
99
100
  sessionId,
100
101
  accountId: consumerUserInfo.accountId,
@@ -141,7 +142,7 @@ export class AuthService {
141
142
  sessionId,
142
143
  accountId,
143
144
  workbenchCode,
144
- accountType: SYS_ACCOUNT_TYPE
145
+ accountType: SYS_ACCOUNT_TYPE,
145
146
  };
146
147
 
147
148
  await this.userSessionService.saveUserSession(sessionInfo);
@@ -203,6 +204,8 @@ export class AuthService {
203
204
  * @private
204
205
  */
205
206
  private async queryUserRoleCodeList(accountId: string): Promise<string[]> {
207
+ const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
208
+
206
209
  const res = await this.curdMixService.executeCrudByCfg(
207
210
  {
208
211
  condition: { account_id: accountId },
@@ -212,7 +215,7 @@ export class AuthService {
212
215
  sqlTable: SystemTables.sys_perm_user_role,
213
216
  sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
214
217
  sqlDatabase: SystemDbName,
215
- sqlDdType: SystemDbType,
218
+ sqlDbType: SystemDbType,
216
219
  }
217
220
  );
218
221
  const rows = res.getResModel().rows || [];
@@ -232,6 +235,8 @@ export class AuthService {
232
235
  return [];
233
236
  }
234
237
 
238
+ const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
239
+
235
240
  const res = await this.curdMixService.executeCrudByCfg(
236
241
  {
237
242
  condition: { role_code: { $in: roleCodeList } },
@@ -241,7 +246,7 @@ export class AuthService {
241
246
  sqlTable: SystemTables.sys_perm_role_func,
242
247
  sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
243
248
  sqlDatabase: SystemDbName,
244
- sqlDdType: SystemDbType,
249
+ sqlDbType: SystemDbType,
245
250
  }
246
251
  );
247
252
  const rows = res.getResModel().rows || [];
@@ -259,7 +264,7 @@ export class AuthService {
259
264
  const oldSessionId = sessionInfo.sessionId;
260
265
 
261
266
  const sessionId = createUniqueId();
262
- const newSessionInfo: ISessionInfo = {...sessionInfo, sessionId};
267
+ const newSessionInfo: ISessionInfo = { ...sessionInfo, sessionId };
263
268
 
264
269
  await this.userSessionService.saveUserSession(newSessionInfo);
265
270
 
@@ -3,10 +3,11 @@ import {Context} from '@midwayjs/koa';
3
3
  import {KeysOfSimpleSQL} from '../libs/crud-pro/models/keys';
4
4
  import {CurdProService} from './curd/CurdProService';
5
5
  import {RelatedType} from './curd/CurdMixUtils';
6
- import {SystemDbName, SystemDbType, SystemTables} from '../models/SystemTables';
6
+ import {SystemTables} from '../models/SystemTables';
7
7
  import {parseConfigContentToEnumInfo, IEnumInfo} from '../libs/utils/parseConfig';
8
8
  import {RedisCacheService} from "./base/RedisCacheService";
9
9
  import {CurdMixByLinkToCustomService} from "./curd/CurdMixByLinkToCustomService";
10
+ import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
10
11
 
11
12
 
12
13
  interface IQueryEnumInfo {
@@ -88,6 +89,8 @@ export class EnumInfoService {
88
89
  }
89
90
 
90
91
  private async queryEnumInfoBySysCfgEnum(code: string): Promise<IEnumInfo[]> {
92
+ const {SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
93
+
91
94
  const res1 = await this.curdProService.executeCrudByCfg(
92
95
  {
93
96
  condition: { config_code: code },
@@ -96,7 +99,7 @@ export class EnumInfoService {
96
99
  sqlTable: SystemTables.sys_configs,
97
100
  sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
98
101
  sqlDatabase: SystemDbName,
99
- sqlDdType: SystemDbType,
102
+ sqlDbType: SystemDbType,
100
103
  }
101
104
  );
102
105
  const obj = res1.getOneObj();
@@ -109,6 +112,8 @@ export class EnumInfoService {
109
112
  }
110
113
 
111
114
  private async queryEnumInfoItemByDict(code: string): Promise<IEnumInfo[]> {
115
+ const {SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
116
+
112
117
  const res1 = await this.curdProService.executeCrudByCfg(
113
118
  {
114
119
  condition: { dict_code: code },
@@ -117,7 +122,7 @@ export class EnumInfoService {
117
122
  sqlTable: SystemTables.sys_data_dict_item,
118
123
  sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY,
119
124
  sqlDatabase: SystemDbName,
120
- sqlDdType: SystemDbType,
125
+ sqlDbType: SystemDbType,
121
126
  }
122
127
  );
123
128
  const obj = res1.getResRows();
@@ -10,7 +10,7 @@ import { KeysOfSimpleSQL, KeysOfValidators } from '../libs/crud-pro/models/keys'
10
10
  import { AccessType, IEntityCommonInfo, UploadCategoryType } from '../models/bizmodels';
11
11
  import { IRequestCfgModel } from '../libs/crud-pro/interfaces';
12
12
  import { BaseService } from './base/BaseService';
13
- import {SystemDbName, SystemDbType} from '../models/SystemTables';
13
+ import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
14
14
 
15
15
  function getSuffix(s: string): string {
16
16
  if (s) {
@@ -107,12 +107,14 @@ class FileDB {
107
107
  }
108
108
 
109
109
  async getFileInfo(fileKey: string): Promise<IFileInfo> {
110
+ const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
111
+
110
112
  const condition: any = { file_key: fileKey };
111
113
  const cfgModel: IRequestCfgModel = {
112
114
  sqlTable: 'sys_file',
113
115
  sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
114
116
  sqlDatabase: SystemDbName,
115
- sqlDdType: SystemDbType,
117
+ sqlDbType: SystemDbType,
116
118
  validateCfg: {
117
119
  'condition.file_key': [KeysOfValidators.REQUIRED, KeysOfValidators.STRING],
118
120
  },
@@ -123,11 +125,13 @@ class FileDB {
123
125
  }
124
126
 
125
127
  async saveFileInfo(fileInfo: IFileInfo) {
128
+ const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
129
+
126
130
  const cfgModel = {
127
131
  sqlTable: 'sys_file',
128
132
  sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
129
133
  sqlDatabase: SystemDbName,
130
- sqlDdType: SystemDbType,
134
+ sqlDbType: SystemDbType,
131
135
  };
132
136
  return await this.curdMixService.executeCrudByCfg(
133
137
  {
@@ -141,21 +145,23 @@ class FileDB {
141
145
  }
142
146
 
143
147
  async saveAssetsLog(fileInfo: IFileInfo) {
148
+ const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
144
149
  const cfgModel = {
145
150
  sqlTable: 'sys_assets_log',
146
151
  sqlSimpleName: KeysOfSimpleSQL.SIMPLE_INSERT,
147
152
  sqlDatabase: SystemDbName,
148
- sqlDdType: SystemDbType,
153
+ sqlDbType: SystemDbType,
149
154
  };
150
155
  return await this.curdMixService.executeCrudByCfg({ data: fileInfo }, cfgModel);
151
156
  }
152
157
 
153
158
  async deleteFileInfo(id: number) {
159
+ const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
154
160
  const cfgModel: IRequestCfgModel = {
155
161
  sqlTable: 'sys_file',
156
162
  sqlSimpleName: KeysOfSimpleSQL.SIMPLE_DELETE,
157
163
  sqlDatabase: SystemDbName,
158
- sqlDdType: SystemDbType,
164
+ sqlDbType: SystemDbType,
159
165
  validateCfg: {
160
166
  'condition.id': [KeysOfValidators.REQUIRED, KeysOfValidators.NUMBER],
161
167
  },
@@ -200,7 +206,7 @@ function toUploadOriginByReferer(referer: string): string {
200
206
  return 'doc-editor';
201
207
  }
202
208
  if (pathname.startsWith('/pages/devops/file-manage')) {
203
- return 'file-manage';
209
+ return 'file-manage';
204
210
  }
205
211
  } catch (error) {
206
212
  console.error('toUploadOriginByReferer', error);
@@ -1,9 +1,10 @@
1
1
  import { Inject, Provide } from '@midwayjs/core';
2
2
  import { Context } from '@midwayjs/koa';
3
- import { KeysOfSimpleSQL} from "../libs/crud-pro/models/keys";
4
- import {SystemDbName, SystemDbType, SystemTables} from "../models/SystemTables";
5
- import {BaseService} from "./base/BaseService";
6
- import {CurdProService} from "./curd/CurdProService";
3
+ import { KeysOfSimpleSQL } from "../libs/crud-pro/models/keys";
4
+ import { SystemTables } from "../models/SystemTables";
5
+ import { BaseService } from "./base/BaseService";
6
+ import { CurdProService } from "./curd/CurdProService";
7
+ import { GLOBAL_STATIC_CONFIG } from '@/libs/global-config/global-config';
7
8
 
8
9
  @Provide()
9
10
  export class SysConfigService extends BaseService {
@@ -14,9 +15,12 @@ export class SysConfigService extends BaseService {
14
15
  private curdProService: CurdProService;
15
16
 
16
17
  async getSysConfigOne(config_code: string): Promise<any> {
17
- if (!config_code){
18
+ if (!config_code) {
18
19
  throw new Error('[getSysConfigOne] config_code required');
19
20
  }
21
+
22
+ const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
23
+
20
24
  const res1 = await this.curdProService.executeCrudByCfg(
21
25
  {
22
26
  condition: { config_code },
@@ -25,7 +29,7 @@ export class SysConfigService extends BaseService {
25
29
  sqlTable: SystemTables.sys_configs,
26
30
  sqlSimpleName: KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
27
31
  sqlDatabase: SystemDbName,
28
- sqlDdType: SystemDbType,
32
+ sqlDbType: SystemDbType,
29
33
  }
30
34
  );
31
35
  return res1.getOneObj();