rez_core 1.0.63 → 1.0.64

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.63",
3
+ "version": "1.0.64",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -28,3 +28,8 @@ export const STATUS_PENDING = 'PENDING';
28
28
  // Entity Status
29
29
  export const ENTITYSTATUS_TO_BE_PUBLISHED = 'to_be_published';
30
30
  export const ENTITYSTATUS_PUBLISHED = 'published';
31
+
32
+ // Display Type
33
+ export const DISPLAY_LIST = 'LIST';
34
+ export const DISPLAY_EXPORT = 'EXPORT';
35
+ export const DISPLAY_REPORT = 'REPORT';
@@ -0,0 +1,22 @@
1
+ import { Controller, HttpStatus, Post, Query, Res, UseGuards } from '@nestjs/common';
2
+ import { EntityTableService } from '../service/entity-table.service';
3
+ import { Response } from 'express';
4
+ import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
5
+
6
+ @Controller('meta')
7
+ @UseGuards(JwtAuthGuard)
8
+ export class MetaController {
9
+ constructor(private readonly entityTableService: EntityTableService) {}
10
+
11
+ @Post('get-table-data')
12
+ async getTableMetaData(@Query('entity_type') entityType: string,
13
+ @Query('list_type') listType: string,
14
+ @Res() response: Response) {
15
+ let entityTableDto = await this.entityTableService.getTableMetaDataForListing(entityType, listType);
16
+ return response.status(HttpStatus.OK).json({
17
+ success: true,
18
+ data: entityTableDto,
19
+ message: 'Data fetch successfully!'
20
+ })
21
+ }
22
+ }
@@ -0,0 +1,6 @@
1
+ import { EntityTable } from '../entity/entity-table.entity';
2
+ import { EntityTableColumn } from '../entity/entity-table-column.entity';
3
+
4
+ export class EntityTableDto extends EntityTable{
5
+ column_list: EntityTableColumn[];
6
+ }
@@ -34,6 +34,7 @@ import { FieldGroupService } from './service/field-group.service';
34
34
  import { ViewMasterService } from './service/view-master.service';
35
35
  import { ViewMasterController } from './controller/view-master.controller';
36
36
  import { ViewMaterRespository } from './repository/view-master.repository';
37
+ import { MetaController } from './controller/meta.controller';
37
38
 
38
39
  @Module({
39
40
  imports: [
@@ -84,6 +85,6 @@ import { ViewMaterRespository } from './repository/view-master.repository';
84
85
  FieldGroupService,
85
86
  'ViewMasterService',
86
87
  ],
87
- controllers: [EntityController, MasterController, MediaController, ViewMasterController],
88
+ controllers: [EntityController, MasterController, MediaController, ViewMasterController, MetaController],
88
89
  })
89
90
  export class EntityModule {}
@@ -16,6 +16,7 @@ export class EntityTableColumnRepository {
16
16
  parent_id: parentId,
17
17
  parent_type: parentType,
18
18
  },
19
+ order: { col_position: 'ASC' }
19
20
  });
20
21
  }
21
22
  }
@@ -1,9 +1,15 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import { EntityTableRepository } from '../repository/entity-table.repository';
3
+ import { EntityTableColumnRepository } from '../repository/entity-table-column.repository';
4
+ import { EntityTableDto } from '../dto/entity-table.dto';
5
+ import { DISPLAY_LIST } from '../../../constant/global.constant';
3
6
 
4
7
  @Injectable()
5
8
  export class EntityTableService {
6
- constructor(private entityTableRepository: EntityTableRepository) {}
9
+ constructor(
10
+ private entityTableRepository: EntityTableRepository,
11
+ private readonly entityTableColumnRepository: EntityTableColumnRepository,
12
+ ) {}
7
13
 
8
14
  async findByEntityTypeAndListType(entityType: string, listType: string) {
9
15
  return await this.entityTableRepository.findByEntityTypeAndListType(
@@ -12,7 +18,41 @@ export class EntityTableService {
12
18
  );
13
19
  }
14
20
 
15
- async findByEntityTypeAndListTypeAndDisplayType(entityType: string, listType: string, displayType: string) {
16
- return await this.entityTableRepository.findByEntityTypeAndListTypeAndDisplayType(entityType, listType, displayType);
21
+ async findByEntityTypeAndListTypeAndDisplayType(
22
+ entityType: string,
23
+ listType: string,
24
+ displayType: string,
25
+ ) {
26
+ return await this.entityTableRepository.findByEntityTypeAndListTypeAndDisplayType(
27
+ entityType,
28
+ listType,
29
+ displayType,
30
+ );
31
+ }
32
+
33
+ async getTableMetaDataForListing(entityType: string, listType: string) {
34
+ return await this.getTableMetaData(entityType, listType, DISPLAY_LIST);
35
+ }
36
+
37
+ async getTableMetaData(
38
+ entityType: string,
39
+ listType: string,
40
+ displayType: string,
41
+ ) {
42
+ let entityTable = await this.findByEntityTypeAndListTypeAndDisplayType(
43
+ entityType,
44
+ listType,
45
+ displayType,
46
+ );
47
+
48
+ let entityTableDto = entityTable as EntityTableDto;
49
+ if (entityTable) {
50
+ entityTableDto.column_list =
51
+ await this.entityTableColumnRepository.findByParentIdAndParentType(
52
+ entityTable.id,
53
+ entityTable.entity_type,
54
+ );
55
+ }
56
+ return entityTableDto;
17
57
  }
18
58
  }