rez_core 0.0.7 → 1.0.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.
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import { BaseEntity } from '../entity/base-entity.entity';
|
|
|
7
7
|
import { LoggingService } from '../../../utils/service/loggingUtil.service';
|
|
8
8
|
import { EntityListData } from '../dto/entity-list-data.dto';
|
|
9
9
|
import { EntityListService } from './entity-list.service';
|
|
10
|
+
import { EntityManager } from 'typeorm';
|
|
10
11
|
|
|
11
12
|
@Injectable()
|
|
12
13
|
export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
@@ -20,15 +21,17 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
20
21
|
async createEntity(
|
|
21
22
|
entityData: BaseEntity,
|
|
22
23
|
loggedInUser: UserData | null,
|
|
24
|
+
manager?: EntityManager
|
|
23
25
|
): Promise<BaseEntity> {
|
|
24
26
|
const entityMaster = await this.entityMasterService.getEntityData(
|
|
25
27
|
entityData.entity_type,
|
|
26
28
|
);
|
|
27
29
|
|
|
28
|
-
const
|
|
29
|
-
entityMaster.entityDataClass
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const repo = manager
|
|
31
|
+
? manager.getRepository(entityMaster.entityDataClass) // <-- Use transaction-safe repo
|
|
32
|
+
: this.reflectionHelper.getRepoService(entityMaster.entityDataClass);
|
|
33
|
+
|
|
34
|
+
if (!repo) {
|
|
32
35
|
throw new Error(
|
|
33
36
|
`Repository service not found for entityType: ${entityData.entity_type}`,
|
|
34
37
|
);
|
|
@@ -39,7 +42,7 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
39
42
|
entityData.created_by = loggedInUser.id;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
const savedEntity =
|
|
45
|
+
const savedEntity = repo.save(entityData);
|
|
43
46
|
return savedEntity;
|
|
44
47
|
}
|
|
45
48
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { UserData } from '../../user/entity/user.entity';
|
|
2
2
|
import { BaseEntity } from '../entity/base-entity.entity';
|
|
3
3
|
import { EntityListData } from '../dto/entity-list-data.dto';
|
|
4
|
+
import { EntityManager } from 'typeorm';
|
|
4
5
|
|
|
5
6
|
export interface EntityService<T extends BaseEntity> {
|
|
6
|
-
createEntity(entityData: T, loggedInUser: UserData): Promise<BaseEntity>;
|
|
7
|
+
createEntity(entityData: T, loggedInUser: UserData, manager?: EntityManager): Promise<BaseEntity>;
|
|
7
8
|
|
|
8
9
|
getEntityData(
|
|
9
10
|
entityType: string,
|
|
@@ -16,6 +16,7 @@ import { UserRoleMappingService } from './user-role-mapping.service';
|
|
|
16
16
|
import { UserRoleMapping } from '../entity/user-role-mapping.entity';
|
|
17
17
|
import { plainToInstance } from 'class-transformer';
|
|
18
18
|
import { EntityListService } from '../../meta/service/entity-list.service';
|
|
19
|
+
import { EntityManager } from 'typeorm';
|
|
19
20
|
import {UpdateUserDto} from "../dto/update-user.dto";
|
|
20
21
|
|
|
21
22
|
|
|
@@ -44,6 +45,7 @@ export class UserService extends EntityServiceImpl {
|
|
|
44
45
|
async createEntity(
|
|
45
46
|
entityData: BaseEntity,
|
|
46
47
|
loggedInUser: UserData | null,
|
|
48
|
+
manager?: EntityManager,
|
|
47
49
|
): Promise<BaseEntity> {
|
|
48
50
|
let userData = entityData as CreateUserDto;
|
|
49
51
|
let existingUser = await this.userRepository.findByEmailId(
|