rez_core 0.0.6 → 1.0.7
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/module/user/dto/update-user.dto.d.ts +5 -0
- package/dist/module/user/dto/update-user.dto.js +9 -0
- package/dist/module/user/dto/update-user.dto.js.map +1 -0
- package/dist/module/user/service/user.service.js +1 -3
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/meta/service/entity-service-impl.service.ts +8 -5
- package/src/module/meta/service/entity.service.ts +2 -1
- package/src/module/user/dto/update-user.dto.ts +4 -0
- package/src/module/user/service/user.service.ts +5 -4
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,8 @@ 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';
|
|
20
|
+
import {UpdateUserDto} from "../dto/update-user.dto";
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
|
|
@@ -43,6 +45,7 @@ export class UserService extends EntityServiceImpl {
|
|
|
43
45
|
async createEntity(
|
|
44
46
|
entityData: BaseEntity,
|
|
45
47
|
loggedInUser: UserData | null,
|
|
48
|
+
manager?: EntityManager,
|
|
46
49
|
): Promise<BaseEntity> {
|
|
47
50
|
let userData = entityData as CreateUserDto;
|
|
48
51
|
let existingUser = await this.userRepository.findByEmailId(
|
|
@@ -118,7 +121,7 @@ export class UserService extends EntityServiceImpl {
|
|
|
118
121
|
entityData: BaseEntity,
|
|
119
122
|
loggedInUserData: UserData,
|
|
120
123
|
): Promise<BaseEntity> {
|
|
121
|
-
let userDto = entityData as
|
|
124
|
+
let userDto = entityData as UpdateUserDto;
|
|
122
125
|
|
|
123
126
|
if (userDto.password) {
|
|
124
127
|
const password = EncryptUtilService.encryptGCM(
|
|
@@ -129,9 +132,7 @@ export class UserService extends EntityServiceImpl {
|
|
|
129
132
|
userDto.password = password;
|
|
130
133
|
}
|
|
131
134
|
|
|
132
|
-
let userData = plainToInstance(UserData, userDto
|
|
133
|
-
excludeExtraneousValues: true,
|
|
134
|
-
});
|
|
135
|
+
let userData = plainToInstance(UserData, userDto);
|
|
135
136
|
let savedData = await super.updateEntity(userData, loggedInUserData);
|
|
136
137
|
if (userDto.roles) {
|
|
137
138
|
let roles = userDto.roles;
|