rez_core 1.0.9 → 1.0.10

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -1,12 +1,12 @@
1
- import { Controller, Get } from '@nestjs/common';
2
- import { AppService } from './app.service';
3
-
4
- @Controller()
5
- export class AppController {
6
- constructor(private readonly appService: AppService) {}
7
-
8
- @Get()
9
- getHello(): string {
10
- return this.appService.getHello();
11
- }
12
- }
1
+ import { Controller, Get } from '@nestjs/common';
2
+ import { AppService } from './app.service';
3
+
4
+ @Controller()
5
+ export class AppController {
6
+ constructor(private readonly appService: AppService) {}
7
+
8
+ @Get()
9
+ getHello(): string {
10
+ return this.appService.getHello();
11
+ }
12
+ }
@@ -1,8 +1,8 @@
1
- import { Injectable } from '@nestjs/common';
2
-
3
- @Injectable()
4
- export class AppService {
5
- getHello(): string {
6
- return 'Hello World!';
7
- }
8
- }
1
+ import { Injectable } from '@nestjs/common';
2
+
3
+ @Injectable()
4
+ export class AppService {
5
+ getHello(): string {
6
+ return 'Hello World!';
7
+ }
8
+ }
@@ -1,34 +1,66 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import { InjectRepository } from '@nestjs/typeorm';
3
- import { Repository } from 'typeorm';
3
+ import { EntityManager, Repository } from 'typeorm';
4
4
  import { OrganizationData } from '../entity/organization.entity';
5
+ import { ClockIDGenService } from 'src/utils/service/clockIDGenUtil.service';
5
6
 
6
7
  @Injectable()
7
8
  export class OrganizationService {
8
9
  constructor(
9
10
  @InjectRepository(OrganizationData)
10
11
  private readonly organizationRepository: Repository<OrganizationData>,
11
- ) {}
12
+ private readonly idGen: ClockIDGenService
13
+ ) { }
12
14
 
13
- async create(organizationDto: Partial<OrganizationData>): Promise<OrganizationData> {
14
- const organization = this.organizationRepository.create(organizationDto);
15
- return await this.organizationRepository.save(organization);
15
+ async create(
16
+ organizationDto: Partial<OrganizationData>,
17
+ manager?: EntityManager,
18
+ ): Promise<OrganizationData> {
19
+ const repo = manager
20
+ ? manager.getRepository(OrganizationData)
21
+ : this.organizationRepository;
22
+
23
+ organizationDto.code = this.idGen.idGenerator('ORG');
24
+ organizationDto.status = 'ACTIVE'
25
+ organizationDto.created_date = new Date();
26
+ const organization = repo.create(organizationDto);
27
+ return await repo.save(organization);
16
28
  }
17
29
 
18
- async findAll(): Promise<OrganizationData[]> {
19
- return await this.organizationRepository.find();
30
+ async findAll(manager?: EntityManager): Promise<OrganizationData[]> {
31
+ const repo = manager
32
+ ? manager.getRepository(OrganizationData)
33
+ : this.organizationRepository;
34
+
35
+ return await repo.find();
20
36
  }
21
37
 
22
- async findOne(id: number): Promise<OrganizationData | null> {
23
- return await this.organizationRepository.findOne({ where: { id } });
38
+ async findOne(id: number, manager?: EntityManager): Promise<OrganizationData | null> {
39
+ const repo = manager
40
+ ? manager.getRepository(OrganizationData)
41
+ : this.organizationRepository;
42
+
43
+ return await repo.findOne({ where: { id } });
24
44
  }
25
45
 
26
- async update(id: number, organizationDto: Partial<OrganizationData>): Promise<OrganizationData | null> {
27
- await this.organizationRepository.update(id, organizationDto);
28
- return this.findOne(id);
46
+ async update(
47
+ id: number,
48
+ organizationDto: Partial<OrganizationData>,
49
+ manager?: EntityManager,
50
+ ): Promise<OrganizationData | null> {
51
+ const repo = manager
52
+ ? manager.getRepository(OrganizationData)
53
+ : this.organizationRepository;
54
+
55
+ await repo.update(id, organizationDto);
56
+ return await repo.findOne({ where: { id } });
29
57
  }
30
58
 
31
- async remove(id: number): Promise<void> {
32
- await this.organizationRepository.delete(id);
59
+ async remove(id: number, manager?: EntityManager): Promise<void> {
60
+ const repo = manager
61
+ ? manager.getRepository(OrganizationData)
62
+ : this.organizationRepository;
63
+
64
+ await repo.delete(id);
33
65
  }
34
66
  }
@@ -17,7 +17,7 @@ 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
19
  import { EntityManager } from 'typeorm';
20
- import {UpdateUserDto} from "../dto/update-user.dto";
20
+ import { UpdateUserDto } from "../dto/update-user.dto";
21
21
 
22
22
 
23
23
 
@@ -151,7 +151,7 @@ export class UserService extends EntityServiceImpl {
151
151
  return await this.userRepository.findByEmailId(email_id);
152
152
  }
153
153
 
154
- async findByMobile(mobile: string){
154
+ async findByMobile(mobile: string) {
155
155
  return await this.userRepository.findByMobile(mobile);
156
156
  }
157
157
  }