rez_core 4.0.21 → 4.0.23

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": "4.0.21",
3
+ "version": "4.0.23",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -1,15 +1,20 @@
1
- import { Controller, Get, Inject, Query } from '@nestjs/common';
1
+ import { Controller, Get, Inject, Query, Req, Res, UseGuards } from '@nestjs/common';
2
2
  import { MapperService } from '../service/mapper.service';
3
+ import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
4
+ import { Response } from 'express';
3
5
 
4
6
  @Controller('mapper')
7
+ @UseGuards(JwtAuthGuard)
5
8
  export class MapperController {
6
9
  constructor(@Inject('MapperService') private readonly mapperService: MapperService) {}
7
10
 
8
11
  @Get('all')
9
12
  async getByMappedEntityType(@Query('mapped_entity_type') mappedEntityType: string,
13
+ @Req() req: Request & { user: any },
10
14
  @Query('filter') filter?: string,
11
- @Query('status') status?: string
15
+ @Query('status') status?: string,
12
16
  ) {
13
- return this.mapperService.getByMappedEntityType(mappedEntityType, filter, status);
17
+ const loggedInUser = req.user.userData;
18
+ return this.mapperService.getByMappedEntityType(mappedEntityType,loggedInUser, filter, status);
14
19
  }
15
20
  }
@@ -16,14 +16,14 @@ export class MapperService extends EntityServiceImpl {
16
16
  super();
17
17
  }
18
18
 
19
- async getByMappedEntityType(mappedEntityType: string, filter?: string, status?: string) {
19
+ async getByMappedEntityType(mappedEntityType: string,loggedInUser, filter?: string, status?: string) {
20
20
  if (!mappedEntityType) return [];
21
21
 
22
22
  const mappers = await this.dataSource.query(
23
23
  `SELECT id, name, code, status
24
24
  FROM frm_mapper_master
25
- WHERE mapped_entity_type = ? AND (-1 = ? OR name LIKE ? OR code LIKE ?)`,
26
- [mappedEntityType, filter || -1, `%${filter}%`, `%${filter}%`],
25
+ WHERE mapped_entity_type = ? AND organization_id = ? AND (-1 = ? OR name LIKE ? OR code LIKE ?)`,
26
+ [mappedEntityType,loggedInUser.organization_id, filter || -1, `%${filter}%`, `%${filter}%`],
27
27
  );
28
28
 
29
29
  const distinctStatuses = [
@@ -65,19 +65,21 @@ export class EntityValidationService {
65
65
  .where(`${db_table_name}.${attr.attribute_key} = :value`, { value });
66
66
 
67
67
  // Add AND condition for organization_id/level_type/level_id if present
68
- const orgId = loggedInUser.organization_id;
69
- const level_type = loggedInUser.level_type;
70
- const level_id = loggedInUser.level_id;
71
-
72
- if (orgId !== undefined && orgId !== null) {
73
- qb = qb.andWhere(
74
- `${db_table_name}.organization_id = :organization_id AND ${db_table_name}.level_type = :level_type AND ${db_table_name}.level_id = :level_id`,
75
- {
76
- organization_id: orgId,
77
- level_type,
78
- level_id,
79
- },
80
- );
68
+ if (entityType !== 'ORG' && entityType !== 'ORGP') {
69
+ const orgId = loggedInUser.organization_id;
70
+ const level_type = loggedInUser.level_type;
71
+ const level_id = loggedInUser.level_id;
72
+
73
+ if (orgId !== undefined && orgId !== null) {
74
+ qb = qb.andWhere(
75
+ `${db_table_name}.organization_id = :organization_id AND ${db_table_name}.level_type = :level_type AND ${db_table_name}.level_id = :level_id`,
76
+ {
77
+ organization_id: orgId,
78
+ level_type,
79
+ level_id,
80
+ },
81
+ );
82
+ }
81
83
  }
82
84
 
83
85
  // Skip the current record when checking for uniqueness during update
@@ -400,7 +400,9 @@ export class MediaDataService extends EntityServiceImpl {
400
400
  }).toString();
401
401
 
402
402
  organizationData = await axios
403
- .get(`${baseUrl}/organization/public/?${queryParams}`)
403
+ .get(
404
+ `${baseUrl}/organization/public/${loggedInUser.organization_id}?${queryParams}`,
405
+ )
404
406
  .then((res) => res.data)
405
407
  .catch((err) => {
406
408
  console.error('Error fetching organization data:', err.message);
@@ -68,8 +68,15 @@ export class ActionDataRepository extends EntityServiceImpl {
68
68
  loggedInUser,
69
69
  );
70
70
 
71
+ const viewMaster = await super.getEntityData(
72
+ 'VMS',
73
+ Number(act.form_id),
74
+ loggedInUser,
75
+ );
76
+
71
77
  const data = {
72
78
  entity_type: 'LFRM',
79
+ name: viewMaster?.name,
73
80
  stage_id: act.stage_id,
74
81
  mapped_entity_type,
75
82
  mapped_entity_id,