rez_core 2.2.41 → 2.2.43

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": "2.2.41",
3
+ "version": "2.2.43",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -4,11 +4,15 @@ import {
4
4
  Body,
5
5
  Param,
6
6
  Req,
7
+ UseGuards,
8
+ Get,
7
9
  } from '@nestjs/common';
8
10
  import { Request } from 'express';
9
11
  import { AttributeMasterService } from '../service/attribute-master.service';
12
+ import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
10
13
 
11
- @Controller('attribute-master')
14
+ @Controller('attribute-master')
15
+ @UseGuards(JwtAuthGuard)
12
16
  export class AttributeMasterController {
13
17
  constructor(
14
18
  private readonly attributeMasterService: AttributeMasterService,
@@ -40,12 +44,25 @@ import {
40
44
  );
41
45
  }
42
46
 
43
- @Post('getById/:id')
47
+ @Get('getById/:id')
44
48
  async getAttributeById(
45
49
  @Param('id') id: number,
46
50
  @Req() req: Request & { user: any },
47
51
  ) {
48
-
52
+ return await this.attributeMasterService.getAttributeById(id);
53
+ }
54
+
55
+
56
+ @Get('getDropdownList/:entityType')
57
+ async getAttributesDropdownList(
58
+ @Param('entityType') entityType: string,
59
+ @Req() req: Request & { user: any },
60
+ ) {
61
+ let loggedInUser = req.user.userData;
62
+ return await this.attributeMasterService.getAttributesDropdownList(
63
+ entityType,
64
+ loggedInUser,
65
+ );
49
66
  }
50
67
  }
51
68
 
@@ -46,6 +46,7 @@ import { AppMasterService } from './service/app-master.service';
46
46
  import { AppMasterRespository } from './repository/app-master.repository';
47
47
  import { AppMaster } from './entity/app-master.entity';
48
48
  import { PopulateMetaService } from './service/populate-meta.service';
49
+ import { AttributeMasterController } from './controller/attribute-master.controller';
49
50
 
50
51
  @Module({
51
52
  imports: [
@@ -117,6 +118,7 @@ import { PopulateMetaService } from './service/populate-meta.service';
117
118
  ViewMasterController,
118
119
  MetaController,
119
120
  AppMasterController,
121
+ AttributeMasterController,
120
122
  ],
121
123
  })
122
124
  export class EntityModule {}
@@ -61,4 +61,22 @@ export class AttributeMasterRepository {
61
61
  return await this.attributeMasterRepository.findOne({ where: { id } });
62
62
  }
63
63
 
64
+ async getAttributesDropdownList(
65
+ entityType: string,
66
+ loggedInUser: UserData,
67
+ ): Promise<{ label: string; value: number }[]> {
68
+ const data = await this.attributeMasterRepository.find({
69
+ where: {
70
+ mapped_entity_type: entityType,
71
+ organization_id: loggedInUser.organization_id,
72
+ },
73
+ });
74
+
75
+ return data.map((item) => ({
76
+ label: item.name,
77
+ value: item.id,
78
+ }));
79
+ }
80
+
81
+
64
82
  }
@@ -56,4 +56,15 @@ export class AttributeMasterService {
56
56
  loggedInUser,
57
57
  );
58
58
  }
59
+
60
+ async getAttributesDropdownList(
61
+ entityType: string,
62
+ loggedInUser: UserData,
63
+ ): Promise<{ label: string; value: number }[]> {
64
+ return await this.attributeMasterRepository.getAttributesDropdownList(
65
+ entityType,
66
+ loggedInUser,
67
+ );
68
+ }
69
+
59
70
  }
@@ -1,4 +1,4 @@
1
- import { Inject, Injectable } from '@nestjs/common';
1
+ import { BadGatewayException, Inject, Injectable } from '@nestjs/common';
2
2
  import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
3
3
  import { StageGroupRepository } from '../repository/stage-group.repository';
4
4
  import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
@@ -76,6 +76,13 @@ export class StageGroupService extends EntityServiceImpl {
76
76
  },
77
77
  });
78
78
 
79
+ if (stageMovementData.length === 0) {
80
+ throw new BadGatewayException(
81
+ `No lead found with id ${lead_id} or no stage movements recorded for this lead
82
+ `,
83
+ );
84
+ }
85
+
79
86
  // 5. Map: stage_id => movement data
80
87
  const stageMovementMap = new Map<number, any>();
81
88
  for (const movement of stageMovementData) {