midway-fatcms 0.0.1-beta.7 → 0.0.1-beta.9

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.
@@ -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(reqJson, cfgModel, methodInfo, this.ctx);
87
90
  return this.curdMixService.executeCrudByCfg(reqJson, cfgModel);
88
91
  }
89
92
  };
@@ -1,11 +1,21 @@
1
- import { SqlDbType } from "../crud-pro/models/keys";
1
+ import { SqlDbType } from '../crud-pro/models/keys';
2
2
  interface IGlobalStaticConfig {
3
3
  /**
4
4
  * CrudStd: 业务系统自定义的修改cfgModel
5
+ * @param reqJson
5
6
  * @param cfgModel
6
7
  * @param appInfo
8
+ * @param ctx
7
9
  */
8
- addCfgModelForCrudStdService(cfgModel: any, appInfo: any): Promise<any>;
10
+ bizUpdateCfgModelForCrudStd(reqJson: any, cfgModel: any, appInfo: any, ctx: any): Promise<any>;
11
+ /**
12
+ * CrudMtd: 业务系统自定义的修改cfgModel
13
+ * @param reqJson
14
+ * @param cfgModel
15
+ * @param methodInfo
16
+ * @param ctx
17
+ */
18
+ bizUpdateCfgModelForCrudMtd(reqJson: any, cfgModel: any, methodInfo: any, ctx: any): Promise<any>;
9
19
  SystemDbName: string;
10
20
  SystemDbType: SqlDbType;
11
21
  }
@@ -2,13 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GLOBAL_STATIC_CONFIG = void 0;
4
4
  const keys_1 = require("../crud-pro/models/keys");
5
- function noop() { }
5
+ const noop = () => {
6
+ return Promise.resolve();
7
+ };
6
8
  class GlobalStaticConfig {
7
9
  constructor() {
8
10
  this.configObject = {
9
- addCfgModelForCrudStdService: noop,
11
+ bizUpdateCfgModelForCrudStd: noop,
12
+ bizUpdateCfgModelForCrudMtd: noop,
10
13
  SystemDbName: 'fatcms',
11
- SystemDbType: keys_1.SqlDbType.mysql
14
+ SystemDbType: keys_1.SqlDbType.mysql,
12
15
  };
13
16
  }
14
17
  getConfig() {
@@ -16,7 +19,7 @@ class GlobalStaticConfig {
16
19
  }
17
20
  setConfig(configObject) {
18
21
  if (!configObject || typeof configObject !== 'object') {
19
- throw new Error("参数configObject不能为空");
22
+ throw new Error('参数configObject不能为空');
20
23
  }
21
24
  Object.assign(this.configObject, configObject);
22
25
  }
@@ -55,7 +55,7 @@ let CrudStdService = class CrudStdService extends ApiBaseService_1.ApiBaseServic
55
55
  // 根据用户配置,设置关联查询的数据信息。
56
56
  await this.crudStdRelationService.addCfgModelColumnsRelation(cfgModel, appInfo);
57
57
  // 业务系统自定义的修改cfgModel
58
- await global_config_1.GLOBAL_STATIC_CONFIG.getConfig().addCfgModelForCrudStdService(cfgModel, appInfo);
58
+ await global_config_1.GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudStd(params, cfgModel, appInfo, this.ctx);
59
59
  return await this.curdMixService.executeCrudByCfg(params, cfgModel);
60
60
  }
61
61
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midway-fatcms",
3
- "version": "0.0.1-beta.7",
3
+ "version": "0.0.1-beta.9",
4
4
  "description": "This is a midway component sample",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -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
 
@@ -102,6 +103,9 @@ export class CrudMtdGatewayController extends ApiBaseService {
102
103
  cfgModel.sqlDatabase = dbName;
103
104
  cfgModel.sqlDdType = dbType;
104
105
 
106
+ // 业务系统自定义的修改cfgModel
107
+ await GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudMtd(reqJson, cfgModel, methodInfo, this.ctx);
108
+
105
109
  return this.curdMixService.executeCrudByCfg(reqJson, cfgModel);
106
110
  }
107
111
  }
@@ -1,47 +1,54 @@
1
- import { SqlDbType } from "../crud-pro/models/keys";
1
+ import { SqlDbType } from '../crud-pro/models/keys';
2
2
 
3
3
  interface IGlobalStaticConfig {
4
- /**
5
- * CrudStd: 业务系统自定义的修改cfgModel
6
- * @param cfgModel
7
- * @param appInfo
8
- */
9
- addCfgModelForCrudStdService(cfgModel: any, appInfo: any): Promise<any>;
10
-
11
- SystemDbName: string,
12
- SystemDbType: SqlDbType;
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
+ SystemDbName: string;
23
+ SystemDbType: SqlDbType;
13
24
  }
14
25
 
15
-
16
- function noop() { }
17
-
26
+ const noop = () => {
27
+ return Promise.resolve();
28
+ };
18
29
 
19
30
  class GlobalStaticConfig {
20
- private configObject: any;
21
- constructor() {
22
- this.configObject = {
23
- addCfgModelForCrudStdService: noop,
24
- SystemDbName: 'fatcms',
25
- SystemDbType: SqlDbType.mysql
26
- };
27
- }
28
- public getConfig(): IGlobalStaticConfig {
29
- return this.configObject as IGlobalStaticConfig;
30
- }
31
-
32
- public setConfig(configObject: any) {
33
- if (!configObject || typeof configObject !== 'object') {
34
- throw new Error("参数configObject不能为空")
35
- }
36
- Object.assign(this.configObject, configObject)
31
+ private configObject: IGlobalStaticConfig;
32
+ constructor() {
33
+ this.configObject = {
34
+ bizUpdateCfgModelForCrudStd: noop,
35
+ bizUpdateCfgModelForCrudMtd: noop,
36
+ SystemDbName: 'fatcms',
37
+ SystemDbType: SqlDbType.mysql,
38
+ };
39
+ }
40
+ public getConfig(): IGlobalStaticConfig {
41
+ return this.configObject as IGlobalStaticConfig;
42
+ }
43
+
44
+ public setConfig(configObject: any) {
45
+ if (!configObject || typeof configObject !== 'object') {
46
+ throw new Error('参数configObject不能为空');
37
47
  }
48
+ Object.assign(this.configObject, configObject);
49
+ }
38
50
  }
39
51
 
40
-
41
52
  const GLOBAL_STATIC_CONFIG = new GlobalStaticConfig();
42
53
 
43
-
44
-
45
- export {
46
- GLOBAL_STATIC_CONFIG
47
- }
54
+ export { GLOBAL_STATIC_CONFIG };
@@ -81,10 +81,8 @@ export class AnyApiService extends ApiBaseService {
81
81
  }
82
82
 
83
83
  private async _getAnyApiMethod(methodCode: string): Promise<ISysAnyApiEntity> {
84
-
85
84
  const { SystemDbName, SystemDbType } = GLOBAL_STATIC_CONFIG.getConfig();
86
85
 
87
-
88
86
  const res = await this.curdMixService.executeCrudByCfg(
89
87
  { condition: { method: methodCode } },
90
88
  {
@@ -70,7 +70,7 @@ export class CrudStdService extends ApiBaseService {
70
70
  await this.crudStdRelationService.addCfgModelColumnsRelation(cfgModel, appInfo);
71
71
 
72
72
  // 业务系统自定义的修改cfgModel
73
- await GLOBAL_STATIC_CONFIG.getConfig().addCfgModelForCrudStdService(cfgModel, appInfo);
73
+ await GLOBAL_STATIC_CONFIG.getConfig().bizUpdateCfgModelForCrudStd(params, cfgModel, appInfo, this.ctx);
74
74
 
75
75
  return await this.curdMixService.executeCrudByCfg(params, cfgModel);
76
76
  }