rez_core 5.0.238 → 5.0.240
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/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/service/reflection-helper.service.d.ts +4 -1
- package/dist/utils/service/reflection-helper.service.js +7 -3
- package/dist/utils/service/reflection-helper.service.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/service/reflection-helper.service.ts +5 -1
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { ModuleRef } from '@nestjs/core';
|
|
2
2
|
import { DataSource, Repository } from 'typeorm';
|
|
3
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
4
|
export declare class ReflectionHelper {
|
|
4
5
|
private moduleRef;
|
|
5
6
|
private dataSource;
|
|
6
|
-
|
|
7
|
+
private readonly configService;
|
|
8
|
+
schema: string;
|
|
9
|
+
constructor(moduleRef: ModuleRef, dataSource: DataSource, configService: ConfigService);
|
|
7
10
|
getRepoService(entityName: string): Repository<any>;
|
|
8
11
|
getBean<T>(beanName: string): Promise<T | null>;
|
|
9
12
|
getEntityData(id: number, tableName: string): Promise<any>;
|
|
@@ -14,10 +14,13 @@ const common_1 = require("@nestjs/common");
|
|
|
14
14
|
const core_1 = require("@nestjs/core");
|
|
15
15
|
const typeorm_1 = require("typeorm");
|
|
16
16
|
const typeorm_2 = require("@nestjs/typeorm");
|
|
17
|
+
const config_1 = require("@nestjs/config");
|
|
17
18
|
let ReflectionHelper = class ReflectionHelper {
|
|
18
|
-
constructor(moduleRef, dataSource) {
|
|
19
|
+
constructor(moduleRef, dataSource, configService) {
|
|
19
20
|
this.moduleRef = moduleRef;
|
|
20
21
|
this.dataSource = dataSource;
|
|
22
|
+
this.configService = configService;
|
|
23
|
+
this.schema = this.configService.get('DB_SCHEMA') || 'default';
|
|
21
24
|
}
|
|
22
25
|
getRepoService(entityName) {
|
|
23
26
|
const entityMetadata = this.dataSource.entityMetadatas.find((meta) => meta.name === entityName ||
|
|
@@ -52,7 +55,7 @@ let ReflectionHelper = class ReflectionHelper {
|
|
|
52
55
|
}
|
|
53
56
|
async getEntityData(id, tableName) {
|
|
54
57
|
const entityList = await this.dataSource.query(`SELECT *
|
|
55
|
-
FROM ${tableName}
|
|
58
|
+
FROM ${this.schema}.${tableName}
|
|
56
59
|
WHERE id = $1`, [id]);
|
|
57
60
|
return entityList.length > 0 ? entityList[0] : null;
|
|
58
61
|
}
|
|
@@ -61,6 +64,7 @@ exports.ReflectionHelper = ReflectionHelper;
|
|
|
61
64
|
exports.ReflectionHelper = ReflectionHelper = __decorate([
|
|
62
65
|
(0, common_1.Injectable)(),
|
|
63
66
|
__metadata("design:paramtypes", [core_1.ModuleRef,
|
|
64
|
-
typeorm_1.DataSource
|
|
67
|
+
typeorm_1.DataSource,
|
|
68
|
+
config_1.ConfigService])
|
|
65
69
|
], ReflectionHelper);
|
|
66
70
|
//# sourceMappingURL=reflection-helper.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflection-helper.service.js","sourceRoot":"","sources":["../../../src/utils/service/reflection-helper.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiE;AACjE,uCAAyC;AACzC,qCAAiD;AACjD,6CAAqD;
|
|
1
|
+
{"version":3,"file":"reflection-helper.service.js","sourceRoot":"","sources":["../../../src/utils/service/reflection-helper.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiE;AACjE,uCAAyC;AACzC,qCAAiD;AACjD,6CAAqD;AACrD,2CAA+C;AAGxC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAE3B,YACU,SAAoB,EACpB,UAAsB,EACb,aAA4B;QAFrC,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,CAAY;QACb,kBAAa,GAAb,aAAa,CAAe;QAE7C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,SAAS,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9D,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAU,EAAE,SAAiB;QAC/C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;2DACQ,IAAI,CAAC,MAAM,IAAI,SAAS;kEACjB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAEtE,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,CAAC;CACF,CAAA;AA1DY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAIU,gBAAS;QACR,oBAAU;QACE,sBAAa;GALpC,gBAAgB,CA0D5B"}
|
package/package.json
CHANGED
|
@@ -2,13 +2,17 @@ import { BadRequestException, Injectable } from '@nestjs/common';
|
|
|
2
2
|
import { ModuleRef } from '@nestjs/core';
|
|
3
3
|
import { DataSource, Repository } from 'typeorm';
|
|
4
4
|
import { getRepositoryToken } from '@nestjs/typeorm';
|
|
5
|
+
import { ConfigService } from '@nestjs/config';
|
|
5
6
|
|
|
6
7
|
@Injectable()
|
|
7
8
|
export class ReflectionHelper {
|
|
9
|
+
schema: string;
|
|
8
10
|
constructor(
|
|
9
11
|
private moduleRef: ModuleRef,
|
|
10
12
|
private dataSource: DataSource,
|
|
13
|
+
private readonly configService: ConfigService
|
|
11
14
|
) {
|
|
15
|
+
this.schema = this.configService.get('DB_SCHEMA') || 'default';
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
getRepoService(entityName: string): Repository<any> {
|
|
@@ -54,7 +58,7 @@ export class ReflectionHelper {
|
|
|
54
58
|
|
|
55
59
|
async getEntityData(id: number, tableName: string) {
|
|
56
60
|
const entityList = await this.dataSource.query(`SELECT *
|
|
57
|
-
FROM ${tableName}
|
|
61
|
+
FROM ${this.schema}.${tableName}
|
|
58
62
|
WHERE id = $1`, [id]);
|
|
59
63
|
|
|
60
64
|
return entityList.length > 0 ? entityList[0] : null;
|