rez_core 5.0.14 → 5.0.16

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": "5.0.14",
3
+ "version": "5.0.16",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -1,10 +1,12 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import { EntityServiceImpl } from './entity-service-impl.service';
3
3
  import { DataSource } from 'typeorm';
4
+ import { EntityMasterRepository } from '../repository/entity-master.repository';
4
5
 
5
6
  @Injectable()
6
7
  export class EntityRelationService extends EntityServiceImpl {
7
- constructor(private readonly dataSource: DataSource) {
8
+ constructor(private readonly dataSource: DataSource,
9
+ private entityMasterRepo: EntityMasterRepository) {
8
10
  super();
9
11
  }
10
12
 
@@ -21,16 +23,11 @@ export class EntityRelationService extends EntityServiceImpl {
21
23
  );
22
24
 
23
25
  if (includeSelf) {
24
- const [entity] = await this.dataSource.query(
25
- `SELECT name as label
26
- FROM frm_entity_master
27
- WHERE mapped_entity_type = $1 AND organization_id = $2`,
28
- [entityType, loggedInUser.organization_id],
29
- );
26
+ const entity = await this.entityMasterRepo.getEntityByMappedEntityType(entityType, loggedInUser.organization_id);
30
27
 
31
28
  if (entity) {
32
29
  relations.unshift({
33
- label: entity.label,
30
+ label: entity.name,
34
31
  value: entityType,
35
32
  id: null, // or some special marker
36
33
  });
@@ -4,6 +4,7 @@ import { UserData } from '../../user/entity/user.entity';
4
4
  import * as moment from 'moment';
5
5
  import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
6
6
  import { ModuleRef } from '@nestjs/core';
7
+ import { AttributeMasterRepository } from '../repository/attribute-master.repository';
7
8
 
8
9
  @Injectable()
9
10
  export class ResolverService {
@@ -14,6 +15,7 @@ export class ResolverService {
14
15
  @Inject('ListMasterService')
15
16
  private readonly listMasterService: ListMasterService,
16
17
  private readonly moduleRef: ModuleRef,
18
+ private readonly attributeMasterRepo: AttributeMasterRepository
17
19
  ) {}
18
20
 
19
21
  private async getMediaDataService() {
@@ -31,10 +33,7 @@ export class ResolverService {
31
33
  entityData: any,
32
34
  entityType: string,
33
35
  ): Promise<any> {
34
- const attributeItems = await this.dataSource.query(
35
- `SELECT * FROM frm_entity_attribute WHERE mapped_entity_type = $1 AND organization_id = $2`,
36
- [entityType, loggedInUser.organization_id],
37
- );
36
+ const attributeItems = await this.attributeMasterRepo.findAttributesByMappedEntityType(entityType, loggedInUser.organization_id);
38
37
 
39
38
  const resolvedEntityData = { ...entityData };
40
39
 
@@ -44,16 +44,25 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
44
44
 
45
45
  const commTemplates = await this.dataSource.query(
46
46
  `
47
- SELECT code as value, name as label , id
48
- FROM frm_wf_comm_template
49
- WHERE mode = $1 AND organization_id = $2 AND level_type = $3 AND level_id = $4 AND status IN (SELECT id FROM frm_list_master_items WHERE code = 'STATUS_ACTIVE' AND organization_id = $5)
50
- `,
47
+ SELECT code as value, name as label , id
48
+ FROM frm_wf_comm_template
49
+ WHERE mode = $1
50
+ AND organization_id = $2
51
+ AND level_type = $3
52
+ AND level_id::int = $4
53
+ AND status::int IN (
54
+ SELECT id
55
+ FROM frm_list_master_items
56
+ WHERE code = 'STATUS_ACTIVE'
57
+ AND organization_id = $5
58
+ )
59
+ `,
51
60
  [
52
- modeId,
53
- loggedInUser.organization_id,
54
- loggedInUser.level_type,
55
- loggedInUser.level_id,
56
- loggedInUser.organization_id,
61
+ String(modeId),
62
+ String(loggedInUser.organization_id),
63
+ String(loggedInUser.level_type),
64
+ Number(loggedInUser.level_id), // keep number
65
+ String(loggedInUser.organization_id),
57
66
  ],
58
67
  );
59
68