rez_core 1.0.59 → 1.0.60

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.59",
3
+ "version": "1.0.60",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -1,4 +1,4 @@
1
- import { Body, Controller, HttpCode, HttpStatus, Param, Post } from '@nestjs/common';
1
+ import { Body, Controller, HttpCode, HttpStatus, Param, Post, Query } from '@nestjs/common';
2
2
  import { ListMasterService } from '../service/list-master.service';
3
3
 
4
4
  @Controller('list-master')
@@ -7,7 +7,7 @@ export class ListMasterController {
7
7
 
8
8
  @Post('/getDropdownData/:type')
9
9
  @HttpCode(HttpStatus.OK)
10
- async getDropdownData(@Param('type') type: string, @Body() params) {
11
- return await this.service.getDropdownOptions(type, params);
10
+ async getDropdownData(@Param('type') type: string, @Body() params,@Query() query: Record<string, string>,) {
11
+ return await this.service.getDropdownOptions(type, params,query);
12
12
  }
13
13
  }
@@ -21,14 +21,14 @@ export class ListMasterService extends EntityServiceImpl {
21
21
  super();
22
22
  }
23
23
 
24
- async getDropdownOptions(type: string, params: Record<string, string>) {
24
+ async getDropdownOptions(type: string, params: Record<string, string>,option) {
25
25
  const config = await this.listMasterRepo.findByType(type);
26
26
 
27
27
  if (!config) throw new NotFoundException(`Type ${type} not found`);
28
28
 
29
29
  switch (config.source) {
30
30
  case 'entity':
31
- return this.fetchFromEntity(type);
31
+ return this.fetchFromEntity(type,option);
32
32
 
33
33
  case 'master':
34
34
  return this.listItemsRepo.findItemsByType(type);
@@ -41,15 +41,18 @@ export class ListMasterService extends EntityServiceImpl {
41
41
  }
42
42
  }
43
43
 
44
- private async fetchFromEntity(sourceList: string) {
44
+ private async fetchFromEntity(sourceList: string,option) {
45
45
  let result: { label: string; value: number }[] = [];
46
46
  if (sourceList) {
47
47
  const entityMaster =
48
48
  await this.entityMasterService.getEntityData(sourceList);
49
49
 
50
- let baseEntities = await super.getEntityList(
51
- entityMaster.mapped_entity_type,
52
- );
50
+ const filters: any = {};
51
+ if (option?.onlyActive === 'true') {
52
+ filters.status = 'ACTIVE';
53
+ }
54
+
55
+ const baseEntities = await super.getEntityList(entityMaster.mapped_entity_type,filters);
53
56
  baseEntities.forEach((entity) => {
54
57
  result.push({
55
58
  label: entity.name,
@@ -62,10 +62,13 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
62
62
  entityData.created_date = new Date();
63
63
  if (loggedInUser) {
64
64
  entityData.created_by = loggedInUser.id;
65
+ if (!entityData.organization_id)
66
+ entityData.organization_id = loggedInUser.organization_id;
67
+ if (!entityData.enterprise_id)
68
+ entityData.enterprise_id = loggedInUser.enterprise_id;
65
69
  }
66
70
 
67
- const savedEntity = repo.save(entityData);
68
- return savedEntity;
71
+ return repo.save(entityData);
69
72
  }
70
73
 
71
74
  deleteEntity(
@@ -110,24 +113,24 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
110
113
  return await repoService.findOne({ where: { id: id } });
111
114
  }
112
115
 
113
- async getEntityList(entityType: string): Promise<BaseEntity[]> {
116
+ async getEntityList(entityType: string, filters: Record<string, any> = {}): Promise<BaseEntity[]> {
114
117
  const entityData = await this.entityMasterService.getEntityData(entityType);
115
- const repoService = this.reflectionHelper.getRepoService(
116
- entityData.entity_data_class,
117
- );
118
+ const repoService = this.reflectionHelper.getRepoService(entityData.entity_data_class);
119
+
118
120
  if (!repoService) {
119
- throw new Error(
120
- `Repository service not found for entityType: ${entityType}`,
121
- );
121
+ throw new Error(`Repository service not found for entityType: ${entityType}`);
122
122
  }
123
-
124
- const result = await repoService.find();
123
+
124
+ const result = await repoService.find({
125
+ where: filters,
126
+ });
127
+
125
128
  return result;
126
129
  }
127
130
 
128
131
  async updateEntity(
129
132
  entityData: BaseEntity,
130
- loggedInUserData: UserData | null,
133
+ loggedInUser: UserData | null,
131
134
  ): Promise<BaseEntity> {
132
135
  const entityMaster = await this.entityMasterService.getEntityData(
133
136
  entityData.entity_type,
@@ -143,8 +146,12 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
143
146
  }
144
147
 
145
148
  entityData.modified_date = new Date();
146
- if (loggedInUserData) {
147
- entityData.modified_by = loggedInUserData.id;
149
+ if (loggedInUser) {
150
+ entityData.modified_by = loggedInUser.id;
151
+ if (!entityData.organization_id)
152
+ entityData.organization_id = loggedInUser.organization_id;
153
+ if (!entityData.enterprise_id)
154
+ entityData.enterprise_id = loggedInUser.enterprise_id;
148
155
  }
149
156
  await repoService.update(entityData.id, entityData);
150
157
  return await repoService.findOne({ where: { id: entityData.id } });
@@ -1,21 +0,0 @@
1
- DB_HOST: "13.234.25.234"
2
- DB_PORT: "3306"
3
- DB_USER: "root"
4
- DB_PASS: "Rezolut@123"
5
- DB_NAME: "core"
6
- MASTER_KEY: "0QZ2eRJv5oVILYnyBlC+FbSGVQiWKReh"
7
- MASTER_IV: "heuUQf5uPVtkotrFAOKUVw=="
8
- SECRET_KEY: "1hard_to_guess_secret7890a"
9
- CLIENT_ID: "324529881356-596sc8ksrb9lg01i7sktofqqqf0fv2ug.apps.googleusercontent.com"
10
- CLIENT_SECRET: "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"
11
- CALLBACK_URL: "http://localhost:3000/auth/google/callback"
12
- OTP_EXPIRY: "10"
13
- OTP_LENGTH: "6"
14
- VERIFY_OTP: "false"
15
- DEFAULT_OTP: "123456"
16
- AWS:
17
- S3:
18
- AWS_ACCESS_KEY_ID: "AKIAYYKIBDDSQF3KILGE"
19
- AWS_SECRET_KEY: "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"
20
- AWS_REGION: "ap-south-1"
21
- BUCKET_NAME: "testether"
@@ -1,15 +0,0 @@
1
- DB_HOST: "13.234.25.234"
2
- DB_PORT: "3306"
3
- DB_USER: "root"
4
- DB_PASS: "Rezolut@123"
5
- DB_NAME: "ether_core"
6
- MASTER_KEY: "0QZ2eRJv5oVILYnyBlC+FbSGVQiWKReh"
7
- MASTER_IV: "heuUQf5uPVtkotrFAOKUVw=="
8
- SECRET_KEY: "1hard_to_guess_secret7890a"
9
- CLIENT_ID: "324529881356-596sc8ksrb9lg01i7sktofqqqf0fv2ug.apps.googleusercontent.com"
10
- CLIENT_SECRET: "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"
11
- CALLBACK_URL: "http://localhost:3000/auth/google/callback"
12
- OTP_EXPIRY: "10"
13
- OTP_LENGTH: "6"
14
- VERIFY_OTP: "false"
15
- DEFAULT_OTP: "123456"