midway-fatcms 0.0.1-beta.6 → 0.0.1-beta.8

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 (54) hide show
  1. package/dist/controller/base/BaseApiController.js +9 -6
  2. package/dist/controller/gateway/CrudMtdGatewayController.js +3 -0
  3. package/dist/controller/gateway/DocGatewayController.js +13 -8
  4. package/dist/controller/home.controller.js +2 -2
  5. package/dist/controller/manage/DeployManageApi.js +6 -4
  6. package/dist/controller/manage/SuperAdminManageApi.js +12 -8
  7. package/dist/controller/manage/SysConfigMangeApi.js +3 -1
  8. package/dist/controller/render/AppRenderController.js +4 -2
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +1 -0
  11. package/dist/libs/global-config/global-config.d.ts +27 -0
  12. package/dist/libs/global-config/global-config.js +28 -0
  13. package/dist/models/SystemTables.d.ts +0 -3
  14. package/dist/models/SystemTables.js +1 -4
  15. package/dist/service/AuthService.js +7 -4
  16. package/dist/service/EnumInfoService.js +7 -4
  17. package/dist/service/FileCenterService.js +13 -9
  18. package/dist/service/SysConfigService.js +4 -2
  19. package/dist/service/UserAccountService.js +10 -6
  20. package/dist/service/VisitStatService.js +4 -2
  21. package/dist/service/WorkbenchService.js +4 -2
  22. package/dist/service/anyapi/AnyApiService.js +4 -2
  23. package/dist/service/crudstd/CrudStdService.js +6 -2
  24. package/dist/service/curd/CurdMixByAccountService.js +4 -2
  25. package/dist/service/curd/CurdMixByDictService.js +4 -2
  26. package/dist/service/curd/CurdMixBySysConfigService.js +4 -2
  27. package/dist/service/curd/CurdMixByWorkbenchService.js +4 -2
  28. package/dist/service/proxyapi/ProxyApiLoadService.js +7 -4
  29. package/package.json +1 -1
  30. package/src/controller/base/BaseApiController.ts +13 -13
  31. package/src/controller/gateway/CrudMtdGatewayController.ts +5 -1
  32. package/src/controller/gateway/DocGatewayController.ts +9 -1
  33. package/src/controller/home.controller.ts +4 -6
  34. package/src/controller/manage/DeployManageApi.ts +4 -1
  35. package/src/controller/manage/SuperAdminManageApi.ts +11 -2
  36. package/src/controller/manage/SysConfigMangeApi.ts +4 -1
  37. package/src/controller/render/AppRenderController.ts +17 -14
  38. package/src/index.ts +1 -1
  39. package/src/libs/global-config/global-config.ts +52 -0
  40. package/src/models/SystemTables.ts +0 -4
  41. package/src/service/AuthService.ts +10 -5
  42. package/src/service/EnumInfoService.ts +6 -1
  43. package/src/service/FileCenterService.ts +8 -2
  44. package/src/service/SysConfigService.ts +9 -5
  45. package/src/service/UserAccountService.ts +11 -1
  46. package/src/service/VisitStatService.ts +5 -1
  47. package/src/service/WorkbenchService.ts +6 -1
  48. package/src/service/anyapi/AnyApiService.ts +4 -1
  49. package/src/service/crudstd/CrudStdService.ts +11 -1
  50. package/src/service/curd/CurdMixByAccountService.ts +6 -1
  51. package/src/service/curd/CurdMixByDictService.ts +7 -1
  52. package/src/service/curd/CurdMixBySysConfigService.ts +6 -1
  53. package/src/service/curd/CurdMixByWorkbenchService.ts +5 -1
  54. package/src/service/proxyapi/ProxyApiLoadService.ts +9 -1
@@ -13,7 +13,7 @@ exports.BaseApiController = void 0;
13
13
  const core_1 = require("@midwayjs/core");
14
14
  const CurdMixService_1 = require("../../service/curd/CurdMixService");
15
15
  const keys_1 = require("../../libs/crud-pro/models/keys");
16
- const SystemTables_1 = require("../../models/SystemTables");
16
+ const global_config_1 = require("../../libs/global-config/global-config");
17
17
  const UserAccountService_1 = require("../../service/UserAccountService");
18
18
  const CurdMixUtils_1 = require("../../service/curd/CurdMixUtils");
19
19
  const BaseService_1 = require("../../service/base/BaseService");
@@ -25,11 +25,12 @@ let BaseApiController = class BaseApiController extends BaseService_1.BaseServic
25
25
  return this.ctx.userSession.getSessionInfo();
26
26
  }
27
27
  async executeSysSQL(executeSql, executeSqlArgs) {
28
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
28
29
  return await this.curdMixService.executeSQL({
29
30
  executeSql: executeSql,
30
31
  executeSqlArgs: executeSqlArgs,
31
- sqlDatabase: SystemTables_1.SystemDbName,
32
- sqlDdType: SystemTables_1.SystemDbType,
32
+ sqlDatabase: SystemDbName,
33
+ sqlDdType: SystemDbType,
33
34
  crudType: keys_1.KeyOfCrudTypes.SYS_QUERY,
34
35
  });
35
36
  }
@@ -41,14 +42,15 @@ let BaseApiController = class BaseApiController extends BaseService_1.BaseServic
41
42
  * @protected
42
43
  */
43
44
  async executeSysSimpleSQL(sqlTable, sqlSimpleName, params) {
45
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
44
46
  const body = this.ctx.request.body;
45
47
  const req = this.ctx.req;
46
48
  const cfgModel = {
47
49
  method: `${req.method}:${req.url}`,
48
50
  sqlTable,
49
51
  sqlSimpleName,
50
- sqlDatabase: SystemTables_1.SystemDbName,
51
- sqlDdType: SystemTables_1.SystemDbType,
52
+ sqlDatabase: SystemDbName,
53
+ sqlDdType: SystemDbType,
52
54
  updateCfg: {},
53
55
  };
54
56
  if (params && typeof params === 'object') {
@@ -61,7 +63,8 @@ let BaseApiController = class BaseApiController extends BaseService_1.BaseServic
61
63
  return await this.curdMixService.executeCrudByCfg(body, cfgModel);
62
64
  }
63
65
  get sysDBUtil() {
64
- return this.curdMixService.getBbUtil(SystemTables_1.SystemDbName, SystemTables_1.SystemDbType);
66
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
67
+ return this.curdMixService.getBbUtil(SystemDbName, SystemDbType);
65
68
  }
66
69
  addAccountBasicInfoCfgModel(cfgModel) {
67
70
  let columnsRelation = cfgModel.columnsRelation;
@@ -22,6 +22,7 @@ const ApiBaseService_1 = require("../../service/base/ApiBaseService");
22
22
  const CurdProService_1 = require("../../service/curd/CurdProService");
23
23
  const CurdMixService_1 = require("../../service/curd/CurdMixService");
24
24
  const DatabaseName_1 = require("../../libs/crud-pro/utils/DatabaseName");
25
+ const global_config_1 = require("../../libs/global-config/global-config");
25
26
  const QUERY_AS_LIST = ['condition', 'data'];
26
27
  function pickAsQuery(query_as_pick, query) {
27
28
  if (query_as_pick && typeof query_as_pick === 'string') {
@@ -84,6 +85,8 @@ let CrudMtdGatewayController = class CrudMtdGatewayController extends ApiBaseSer
84
85
  const { dbType, dbName } = (0, DatabaseName_1.parseDatabaseName)(cfgModel.sqlDatabase);
85
86
  cfgModel.sqlDatabase = dbName;
86
87
  cfgModel.sqlDdType = dbType;
88
+ // 业务系统自定义的修改cfgModel
89
+ await global_config_1.GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudMtd(cfgModel, methodInfo, this.ctx);
87
90
  return this.curdMixService.executeCrudByCfg(reqJson, cfgModel);
88
91
  }
89
92
  };
@@ -16,6 +16,7 @@ exports.DocGatewayController = void 0;
16
16
  const core_1 = require("@midwayjs/core");
17
17
  const BaseApiController_1 = require("../base/BaseApiController");
18
18
  const SystemTables_1 = require("../../models/SystemTables");
19
+ const global_config_1 = require("../../libs/global-config/global-config");
19
20
  const keys_1 = require("../../libs/crud-pro/models/keys");
20
21
  const WorkbenchService_1 = require("../../service/WorkbenchService");
21
22
  const common_dto_1 = require("../../libs/utils/common-dto");
@@ -40,6 +41,7 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
40
41
  if (nxRes !== 'OK') {
41
42
  return;
42
43
  }
44
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
43
45
  await this.curdMixService.executeCrudByCfg({
44
46
  data: {
45
47
  pv: pv + 1
@@ -51,8 +53,8 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
51
53
  }, {
52
54
  sqlTable: SystemTables_1.SystemTables.sys_doc,
53
55
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE,
54
- sqlDatabase: SystemTables_1.SystemDbName,
55
- sqlDdType: SystemTables_1.SystemDbType,
56
+ sqlDatabase: SystemDbName,
57
+ sqlDdType: SystemDbType,
56
58
  });
57
59
  }
58
60
  /**
@@ -66,6 +68,7 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
66
68
  if (!docLibInfoRes.success) {
67
69
  return docLibInfoRes;
68
70
  }
71
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
69
72
  const res = await this.curdMixService.executeCrudByCfg({
70
73
  condition: {
71
74
  id: parseInt(docId),
@@ -74,8 +77,8 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
74
77
  }, {
75
78
  sqlTable: SystemTables_1.SystemTables.sys_doc,
76
79
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
77
- sqlDatabase: SystemTables_1.SystemDbName,
78
- sqlDdType: SystemTables_1.SystemDbType,
80
+ sqlDatabase: SystemDbName,
81
+ sqlDdType: SystemDbType,
79
82
  });
80
83
  // 更新PV数据
81
84
  const docObj = res.getOneObj();
@@ -94,6 +97,7 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
94
97
  if (!docLibInfoRes.success) {
95
98
  return docLibInfoRes;
96
99
  }
100
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
97
101
  return this.curdMixService.executeCrudByCfg({
98
102
  columns: 'id,title,doc_category_code,sort_index',
99
103
  orderBy: 'sort_index+,id-',
@@ -106,8 +110,8 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
106
110
  }, {
107
111
  sqlTable: SystemTables_1.SystemTables.sys_doc,
108
112
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
109
- sqlDatabase: SystemTables_1.SystemDbName,
110
- sqlDdType: SystemTables_1.SystemDbType,
113
+ sqlDatabase: SystemDbName,
114
+ sqlDdType: SystemDbType,
111
115
  });
112
116
  }
113
117
  /**
@@ -116,6 +120,7 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
116
120
  */
117
121
  async getDocLibInfo(docLibId) {
118
122
  checkIsNumber(docLibId, 'docLibId');
123
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
119
124
  const s = await this.curdMixService.executeCrudByCfg({
120
125
  condition: {
121
126
  id: parseInt(docLibId),
@@ -123,8 +128,8 @@ let DocGatewayController = class DocGatewayController extends BaseApiController_
123
128
  }, {
124
129
  sqlTable: SystemTables_1.SystemTables.sys_doc_lib,
125
130
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
126
- sqlDatabase: SystemTables_1.SystemDbName,
127
- sqlDdType: SystemTables_1.SystemDbType,
131
+ sqlDatabase: SystemDbName,
132
+ sqlDdType: SystemDbType,
128
133
  });
129
134
  const docLibInfo = s.getOneObj();
130
135
  if (!docLibInfo) {
@@ -31,13 +31,13 @@ let HomeController = class HomeController extends BaseApiController_1.BaseApiCon
31
31
  }
32
32
  const html_content = workbenchInfo.html_content || '未配置HTML模版';
33
33
  const userInfo = this.getUserSessionInfo();
34
- const fatcmscsrftoken = await crypto_utils_1.privateAES.time_encrypt_utf8_base64("" + Date.now());
34
+ const fatcmscsrftoken = await crypto_utils_1.privateAES.time_encrypt_utf8_base64('' + Date.now());
35
35
  const utils = (0, render_utils_1.createRenderUtils)({
36
36
  ctx: this.ctx,
37
37
  userInfo,
38
38
  workbenchInfo,
39
39
  package_assets: workbenchInfo.package_assets,
40
- fatcmscsrftoken
40
+ fatcmscsrftoken,
41
41
  });
42
42
  return this.ctx.renderString(html_content, { workbenchInfo, userInfo, utils }, { viewEngine: 'ejs' });
43
43
  }
@@ -24,6 +24,7 @@ const FileCenterService_1 = require("../../service/FileCenterService");
24
24
  const SystemTables_1 = require("../../models/SystemTables");
25
25
  const keys_1 = require("../../libs/crud-pro/models/keys");
26
26
  const WorkbenchService_1 = require("../../service/WorkbenchService");
27
+ const global_config_1 = require("../../libs/global-config/global-config");
27
28
  function toAssetsSchema(fileList) {
28
29
  for (let i = 0; i < fileList.length; i++) {
29
30
  const fileListElement = fileList[i];
@@ -109,6 +110,7 @@ let DeployManageApi = class DeployManageApi extends BaseApiController_1.BaseApiC
109
110
  if (!Array.isArray(cdnResources) || cdnResources.length === 0) {
110
111
  throw new devops_1.BizException('cdnResources参数不存在');
111
112
  }
113
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
112
114
  const workbench = await this.curdMixService.executeCrudByCfg({
113
115
  data: {
114
116
  package_assets: JSON.stringify(toAssetsSchema(cdnResources)),
@@ -118,8 +120,8 @@ let DeployManageApi = class DeployManageApi extends BaseApiController_1.BaseApiC
118
120
  }
119
121
  }, {
120
122
  sqlTable: SystemTables_1.SystemTables.sys_workbench,
121
- sqlDatabase: SystemTables_1.SystemDbName,
122
- sqlDdType: SystemTables_1.SystemDbType,
123
+ sqlDatabase: SystemDbName,
124
+ sqlDdType: SystemDbType,
123
125
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE
124
126
  });
125
127
  const app = await this.curdMixService.executeCrudByCfg({
@@ -131,8 +133,8 @@ let DeployManageApi = class DeployManageApi extends BaseApiController_1.BaseApiC
131
133
  }
132
134
  }, {
133
135
  sqlTable: SystemTables_1.SystemTables.sys_app,
134
- sqlDatabase: SystemTables_1.SystemDbName,
135
- sqlDdType: SystemTables_1.SystemDbType,
136
+ sqlDatabase: SystemDbName,
137
+ sqlDdType: SystemDbType,
136
138
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_UPDATE
137
139
  });
138
140
  this.workbenchService.clearCache();
@@ -18,11 +18,13 @@ const permission_middleware_1 = require("../../middleware/permission.middleware"
18
18
  const SystemPerm_1 = require("../../models/SystemPerm");
19
19
  const SystemTables_1 = require("../../models/SystemTables");
20
20
  const common_dto_1 = require("../../libs/utils/common-dto");
21
+ const global_config_1 = require("../../libs/global-config/global-config");
21
22
  let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.BaseApiController {
22
23
  /**
23
24
  * 预设系统内置功能点数据
24
25
  */
25
26
  async presetsFuncCode() {
27
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
26
28
  const funcCodeList = Object.keys(SystemPerm_1.SystemFuncCodeNameMap);
27
29
  for (let i = 0; i < funcCodeList.length; i++) {
28
30
  const funcCode = funcCodeList[i];
@@ -36,8 +38,8 @@ let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.
36
38
  }, {
37
39
  sqlTable: SystemTables_1.SystemTables.sys_perm_func,
38
40
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
39
- sqlDatabase: SystemTables_1.SystemDbName,
40
- sqlDdType: SystemTables_1.SystemDbType,
41
+ sqlDatabase: SystemDbName,
42
+ sqlDdType: SystemDbType,
41
43
  });
42
44
  }
43
45
  return common_dto_1.CommonResult.successRes();
@@ -46,6 +48,7 @@ let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.
46
48
  * 预设系统内置角色数据
47
49
  */
48
50
  async presetsRoleCode() {
51
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
49
52
  const roleCodeList = [SystemPerm_1.SystemRoleCode.DevOpsViewer, SystemPerm_1.SystemRoleCode.DevOpsWriter];
50
53
  for (let i = 0; i < roleCodeList.length; i++) {
51
54
  const roleCode = roleCodeList[i];
@@ -59,8 +62,8 @@ let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.
59
62
  }, {
60
63
  sqlTable: SystemTables_1.SystemTables.sys_perm_role,
61
64
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
62
- sqlDatabase: SystemTables_1.SystemDbName,
63
- sqlDdType: SystemTables_1.SystemDbType,
65
+ sqlDatabase: SystemDbName,
66
+ sqlDdType: SystemDbType,
64
67
  });
65
68
  }
66
69
  return common_dto_1.CommonResult.successRes();
@@ -69,6 +72,7 @@ let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.
69
72
  * 预设系统内置:角色和功能点的关系
70
73
  */
71
74
  async presetsRoleFuncList() {
75
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
72
76
  const funcCodeList = Object.keys(SystemPerm_1.SystemFuncCodeNameMap);
73
77
  for (let i = 0; i < funcCodeList.length; i++) {
74
78
  const funcCode = funcCodeList[i];
@@ -81,8 +85,8 @@ let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.
81
85
  }, {
82
86
  sqlTable: SystemTables_1.SystemTables.sys_perm_role_func,
83
87
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
84
- sqlDatabase: SystemTables_1.SystemDbName,
85
- sqlDdType: SystemTables_1.SystemDbType,
88
+ sqlDatabase: SystemDbName,
89
+ sqlDdType: SystemDbType,
86
90
  });
87
91
  }
88
92
  for (let i = 0; i < funcCodeList.length; i++) {
@@ -97,8 +101,8 @@ let SuperAdminManageApi = class SuperAdminManageApi extends BaseApiController_1.
97
101
  }, {
98
102
  sqlTable: SystemTables_1.SystemTables.sys_perm_role_func,
99
103
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
100
- sqlDatabase: SystemTables_1.SystemDbName,
101
- sqlDdType: SystemTables_1.SystemDbType,
104
+ sqlDatabase: SystemDbName,
105
+ sqlDdType: SystemDbType,
102
106
  });
103
107
  }
104
108
  }
@@ -18,6 +18,7 @@ const SystemPerm_1 = require("../../models/SystemPerm");
18
18
  const bizmodels_1 = require("../../models/bizmodels");
19
19
  const SystemTables_1 = require("../../models/SystemTables");
20
20
  const common_dto_1 = require("../../libs/utils/common-dto");
21
+ const global_config_1 = require("../../libs/global-config/global-config");
21
22
  let SysConfigMangeApi = class SysConfigMangeApi extends BaseApiController_1.BaseApiController {
22
23
  async getSysConfigList() {
23
24
  return this.executeSysSimpleSQL('sys_configs', keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_PAGE, {
@@ -47,12 +48,13 @@ let SysConfigMangeApi = class SysConfigMangeApi extends BaseApiController_1.Base
47
48
  });
48
49
  }
49
50
  async updateSysConfig() {
51
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
50
52
  const body = this.ctx.request.body;
51
53
  const id = body.condition.id;
52
54
  if (!id) {
53
55
  return common_dto_1.CommonResult.errorRes("id不能为空");
54
56
  }
55
- const sysConfig = await this.curdMixService.getBbUtil(SystemTables_1.SystemDbName, SystemTables_1.SystemDbType).getOne({ condition: body.condition }, SystemTables_1.SystemTables.sys_configs);
57
+ const sysConfig = await this.curdMixService.getBbUtil(SystemDbName, SystemDbType).getOne({ condition: body.condition }, SystemTables_1.SystemTables.sys_configs);
56
58
  if (!sysConfig) {
57
59
  return common_dto_1.CommonResult.errorRes("配置项不存在");
58
60
  }
@@ -20,18 +20,20 @@ const SystemTables_1 = require("../../models/SystemTables");
20
20
  const WorkbenchService_1 = require("../../service/WorkbenchService");
21
21
  const render_utils_1 = require("../../libs/utils/render-utils");
22
22
  const crypto_utils_1 = require("../../libs/utils/crypto-utils");
23
+ const global_config_1 = require("../../libs/global-config/global-config");
23
24
  /**
24
25
  * 渲染独立外部应用
25
26
  */
26
27
  let AppRenderController = class AppRenderController extends BaseApiController_1.BaseApiController {
27
28
  async home(appPath) {
29
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
28
30
  const appPathArr = appPath.split('/');
29
31
  const appCode = appPathArr[0];
30
32
  const res = await this.curdMixService.executeCrudByCfg({ condition: { app_code: appCode } }, {
31
33
  sqlTable: SystemTables_1.SystemTables.sys_app,
32
34
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
33
- sqlDatabase: SystemTables_1.SystemDbName,
34
- sqlDdType: SystemTables_1.SystemDbType,
35
+ sqlDatabase: SystemDbName,
36
+ sqlDdType: SystemDbType,
35
37
  });
36
38
  const { row: appInfo } = res.getResModel();
37
39
  if (!appInfo) {
package/dist/index.d.ts CHANGED
@@ -91,3 +91,4 @@ export * from './libs/crud-pro/models/keys';
91
91
  export * from './libs/crud-pro/models/ExecuteContextFunc';
92
92
  export * from './libs/crud-pro/models/RequestCfgModel';
93
93
  export * from './libs/crud-pro/models/SqlSegArg';
94
+ export * from './libs/global-config/global-config';
package/dist/index.js CHANGED
@@ -109,3 +109,4 @@ __exportStar(require("./libs/crud-pro/models/keys"), exports);
109
109
  __exportStar(require("./libs/crud-pro/models/ExecuteContextFunc"), exports);
110
110
  __exportStar(require("./libs/crud-pro/models/RequestCfgModel"), exports);
111
111
  __exportStar(require("./libs/crud-pro/models/SqlSegArg"), exports);
112
+ __exportStar(require("./libs/global-config/global-config"), exports);
@@ -0,0 +1,27 @@
1
+ import { SqlDbType } from '../crud-pro/models/keys';
2
+ interface IGlobalStaticConfig {
3
+ /**
4
+ * CrudStd: 业务系统自定义的修改cfgModel
5
+ * @param cfgModel
6
+ * @param appInfo
7
+ * @param ctx
8
+ */
9
+ bizUpdateCfgModelForCrudStd(cfgModel: any, appInfo: any, ctx: any): Promise<any>;
10
+ /**
11
+ * CrudMtd: 业务系统自定义的修改cfgModel
12
+ * @param cfgModel
13
+ * @param methodInfo
14
+ * @param ctx
15
+ */
16
+ bizUpdateCfgModelForCrudMtd(cfgModel: any, methodInfo: any, ctx: any): Promise<any>;
17
+ SystemDbName: string;
18
+ SystemDbType: SqlDbType;
19
+ }
20
+ declare class GlobalStaticConfig {
21
+ private configObject;
22
+ constructor();
23
+ getConfig(): IGlobalStaticConfig;
24
+ setConfig(configObject: any): void;
25
+ }
26
+ declare const GLOBAL_STATIC_CONFIG: GlobalStaticConfig;
27
+ export { GLOBAL_STATIC_CONFIG };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GLOBAL_STATIC_CONFIG = void 0;
4
+ const keys_1 = require("../crud-pro/models/keys");
5
+ const noop = () => {
6
+ return Promise.resolve();
7
+ };
8
+ class GlobalStaticConfig {
9
+ constructor() {
10
+ this.configObject = {
11
+ bizUpdateCfgModelForCrudStd: noop,
12
+ bizUpdateCfgModelForCrudMtd: noop,
13
+ SystemDbName: 'fatcms',
14
+ SystemDbType: keys_1.SqlDbType.mysql,
15
+ };
16
+ }
17
+ getConfig() {
18
+ return this.configObject;
19
+ }
20
+ setConfig(configObject) {
21
+ if (!configObject || typeof configObject !== 'object') {
22
+ throw new Error('参数configObject不能为空');
23
+ }
24
+ Object.assign(this.configObject, configObject);
25
+ }
26
+ }
27
+ const GLOBAL_STATIC_CONFIG = new GlobalStaticConfig();
28
+ exports.GLOBAL_STATIC_CONFIG = GLOBAL_STATIC_CONFIG;
@@ -1,4 +1,3 @@
1
- import { SqlDbType } from "../libs/crud-pro/models/keys";
2
1
  export declare const SystemTables: {
3
2
  sys_workbench: string;
4
3
  sys_user_account: string;
@@ -22,6 +21,4 @@ export declare const SystemTables: {
22
21
  sys_proxyapi: string;
23
22
  sys_visit_stats: string;
24
23
  };
25
- export declare const SystemDbName = "fatcms";
26
- export declare const SystemDbType = SqlDbType.mysql;
27
24
  export declare const SystemDevOpsWorkbench = "devops";
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SystemDevOpsWorkbench = exports.SystemDbType = exports.SystemDbName = exports.SystemTables = void 0;
4
- const keys_1 = require("../libs/crud-pro/models/keys");
3
+ exports.SystemDevOpsWorkbench = exports.SystemTables = void 0;
5
4
  exports.SystemTables = {
6
5
  sys_workbench: 'sys_workbench',
7
6
  sys_user_account: 'sys_user_account',
@@ -25,6 +24,4 @@ exports.SystemTables = {
25
24
  sys_proxyapi: 'sys_proxyapi',
26
25
  sys_visit_stats: 'sys_visit_stats',
27
26
  };
28
- exports.SystemDbName = 'fatcms';
29
- exports.SystemDbType = keys_1.SqlDbType.mysql;
30
27
  exports.SystemDevOpsWorkbench = 'devops';
@@ -22,6 +22,7 @@ const UserSessionService_1 = require("./UserSessionService");
22
22
  const common_dto_1 = require("../libs/utils/common-dto");
23
23
  const fatcms_request_1 = require("../libs/utils/fatcms-request");
24
24
  const exceptions_1 = require("../libs/crud-pro/exceptions");
25
+ const global_config_1 = require("../libs/global-config/global-config");
25
26
  let AuthService = class AuthService {
26
27
  /**
27
28
  * 明文密码转unsaltedPwd密码
@@ -171,14 +172,15 @@ let AuthService = class AuthService {
171
172
  * @private
172
173
  */
173
174
  async queryUserRoleCodeList(accountId) {
175
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
174
176
  const res = await this.curdMixService.executeCrudByCfg({
175
177
  condition: { account_id: accountId },
176
178
  limit: 10000,
177
179
  }, {
178
180
  sqlTable: SystemTables_1.SystemTables.sys_perm_user_role,
179
181
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
180
- sqlDatabase: SystemTables_1.SystemDbName,
181
- sqlDdType: SystemTables_1.SystemDbType,
182
+ sqlDatabase: SystemDbName,
183
+ sqlDdType: SystemDbType,
182
184
  });
183
185
  const rows = res.getResModel().rows || [];
184
186
  const roleCodes = rows.map(({ role_code }) => {
@@ -195,14 +197,15 @@ let AuthService = class AuthService {
195
197
  if (!roleCodeList || roleCodeList.length === 0) {
196
198
  return [];
197
199
  }
200
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
198
201
  const res = await this.curdMixService.executeCrudByCfg({
199
202
  condition: { role_code: { $in: roleCodeList } },
200
203
  limit: 10000,
201
204
  }, {
202
205
  sqlTable: SystemTables_1.SystemTables.sys_perm_role_func,
203
206
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
204
- sqlDatabase: SystemTables_1.SystemDbName,
205
- sqlDdType: SystemTables_1.SystemDbType,
207
+ sqlDatabase: SystemDbName,
208
+ sqlDdType: SystemDbType,
206
209
  });
207
210
  const rows = res.getResModel().rows || [];
208
211
  const funcCodes = rows.map(({ func_code }) => {
@@ -18,6 +18,7 @@ const SystemTables_1 = require("../models/SystemTables");
18
18
  const parseConfig_1 = require("../libs/utils/parseConfig");
19
19
  const RedisCacheService_1 = require("./base/RedisCacheService");
20
20
  const CurdMixByLinkToCustomService_1 = require("./curd/CurdMixByLinkToCustomService");
21
+ const global_config_1 = require("../libs/global-config/global-config");
21
22
  function filterEmpty(e) {
22
23
  return e.label && typeof e.value !== 'undefined';
23
24
  }
@@ -70,13 +71,14 @@ let EnumInfoService = class EnumInfoService {
70
71
  });
71
72
  }
72
73
  async queryEnumInfoBySysCfgEnum(code) {
74
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
73
75
  const res1 = await this.curdProService.executeCrudByCfg({
74
76
  condition: { config_code: code },
75
77
  }, {
76
78
  sqlTable: SystemTables_1.SystemTables.sys_configs,
77
79
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
78
- sqlDatabase: SystemTables_1.SystemDbName,
79
- sqlDdType: SystemTables_1.SystemDbType,
80
+ sqlDatabase: SystemDbName,
81
+ sqlDdType: SystemDbType,
80
82
  });
81
83
  const obj = res1.getOneObj();
82
84
  if (!obj) {
@@ -86,13 +88,14 @@ let EnumInfoService = class EnumInfoService {
86
88
  return rows.map(e => ({ label: e.label, value: e.value, children: e.children })).filter(filterEmpty);
87
89
  }
88
90
  async queryEnumInfoItemByDict(code) {
91
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
89
92
  const res1 = await this.curdProService.executeCrudByCfg({
90
93
  condition: { dict_code: code },
91
94
  }, {
92
95
  sqlTable: SystemTables_1.SystemTables.sys_data_dict_item,
93
96
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY,
94
- sqlDatabase: SystemTables_1.SystemDbName,
95
- sqlDdType: SystemTables_1.SystemDbType,
97
+ sqlDatabase: SystemDbName,
98
+ sqlDdType: SystemDbType,
96
99
  });
97
100
  const obj = res1.getResRows();
98
101
  if (!obj) {
@@ -20,7 +20,7 @@ const CurdMixService_1 = require("./curd/CurdMixService");
20
20
  const keys_1 = require("../libs/crud-pro/models/keys");
21
21
  const bizmodels_1 = require("../models/bizmodels");
22
22
  const BaseService_1 = require("./base/BaseService");
23
- const SystemTables_1 = require("../models/SystemTables");
23
+ const global_config_1 = require("../libs/global-config/global-config");
24
24
  function getSuffix(s) {
25
25
  if (s) {
26
26
  const indexOf = s.lastIndexOf('.');
@@ -93,12 +93,13 @@ class FileDB {
93
93
  this.curdMixService = curdMixService;
94
94
  }
95
95
  async getFileInfo(fileKey) {
96
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
96
97
  const condition = { file_key: fileKey };
97
98
  const cfgModel = {
98
99
  sqlTable: 'sys_file',
99
100
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
100
- sqlDatabase: SystemTables_1.SystemDbName,
101
- sqlDdType: SystemTables_1.SystemDbType,
101
+ sqlDatabase: SystemDbName,
102
+ sqlDdType: SystemDbType,
102
103
  validateCfg: {
103
104
  'condition.file_key': [keys_1.KeysOfValidators.REQUIRED, keys_1.KeysOfValidators.STRING],
104
105
  },
@@ -107,11 +108,12 @@ class FileDB {
107
108
  return res.getOneObj();
108
109
  }
109
110
  async saveFileInfo(fileInfo) {
111
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
110
112
  const cfgModel = {
111
113
  sqlTable: 'sys_file',
112
114
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
113
- sqlDatabase: SystemTables_1.SystemDbName,
114
- sqlDdType: SystemTables_1.SystemDbType,
115
+ sqlDatabase: SystemDbName,
116
+ sqlDdType: SystemDbType,
115
117
  };
116
118
  return await this.curdMixService.executeCrudByCfg({
117
119
  data: fileInfo,
@@ -121,20 +123,22 @@ class FileDB {
121
123
  }, cfgModel);
122
124
  }
123
125
  async saveAssetsLog(fileInfo) {
126
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
124
127
  const cfgModel = {
125
128
  sqlTable: 'sys_assets_log',
126
129
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_INSERT,
127
- sqlDatabase: SystemTables_1.SystemDbName,
128
- sqlDdType: SystemTables_1.SystemDbType,
130
+ sqlDatabase: SystemDbName,
131
+ sqlDdType: SystemDbType,
129
132
  };
130
133
  return await this.curdMixService.executeCrudByCfg({ data: fileInfo }, cfgModel);
131
134
  }
132
135
  async deleteFileInfo(id) {
136
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
133
137
  const cfgModel = {
134
138
  sqlTable: 'sys_file',
135
139
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_DELETE,
136
- sqlDatabase: SystemTables_1.SystemDbName,
137
- sqlDdType: SystemTables_1.SystemDbType,
140
+ sqlDatabase: SystemDbName,
141
+ sqlDdType: SystemDbType,
138
142
  validateCfg: {
139
143
  'condition.id': [keys_1.KeysOfValidators.REQUIRED, keys_1.KeysOfValidators.NUMBER],
140
144
  },
@@ -15,18 +15,20 @@ const keys_1 = require("../libs/crud-pro/models/keys");
15
15
  const SystemTables_1 = require("../models/SystemTables");
16
16
  const BaseService_1 = require("./base/BaseService");
17
17
  const CurdProService_1 = require("./curd/CurdProService");
18
+ const global_config_1 = require("../libs/global-config/global-config");
18
19
  let SysConfigService = class SysConfigService extends BaseService_1.BaseService {
19
20
  async getSysConfigOne(config_code) {
20
21
  if (!config_code) {
21
22
  throw new Error('[getSysConfigOne] config_code required');
22
23
  }
24
+ const { SystemDbName, SystemDbType } = global_config_1.GLOBAL_STATIC_CONFIG.getConfig();
23
25
  const res1 = await this.curdProService.executeCrudByCfg({
24
26
  condition: { config_code },
25
27
  }, {
26
28
  sqlTable: SystemTables_1.SystemTables.sys_configs,
27
29
  sqlSimpleName: keys_1.KeysOfSimpleSQL.SIMPLE_QUERY_ONE,
28
- sqlDatabase: SystemTables_1.SystemDbName,
29
- sqlDdType: SystemTables_1.SystemDbType,
30
+ sqlDatabase: SystemDbName,
31
+ sqlDdType: SystemDbType,
30
32
  });
31
33
  return res1.getOneObj();
32
34
  }