rez_core 1.0.27 → 1.0.28
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/dist/core.module.js +5 -2
- package/dist/core.module.js.map +1 -1
- package/dist/module/layout/controller/layout.controller.d.ts +11 -0
- package/dist/module/layout/controller/layout.controller.js +61 -0
- package/dist/module/layout/controller/layout.controller.js.map +1 -0
- package/dist/module/layout/dto/header.dto.d.ts +0 -0
- package/dist/module/layout/dto/header.dto.js +1 -0
- package/dist/module/layout/dto/header.dto.js.map +1 -0
- package/dist/module/layout/entity/header-items.entity.d.ts +10 -0
- package/dist/module/layout/entity/header-items.entity.js +52 -0
- package/dist/module/layout/entity/header-items.entity.js.map +1 -0
- package/dist/module/layout/entity/header-section.entity.d.ts +7 -0
- package/dist/module/layout/entity/header-section.entity.js +40 -0
- package/dist/module/layout/entity/header-section.entity.js.map +1 -0
- package/dist/module/layout/layout.module.d.ts +2 -0
- package/dist/module/layout/layout.module.js +30 -0
- package/dist/module/layout/layout.module.js.map +1 -0
- package/dist/module/layout/repository/header-items.repository.d.ts +7 -0
- package/dist/module/layout/repository/header-items.repository.js +36 -0
- package/dist/module/layout/repository/header-items.repository.js.map +1 -0
- package/dist/module/layout/repository/header-section.repository.d.ts +7 -0
- package/dist/module/layout/repository/header-section.repository.js +36 -0
- package/dist/module/layout/repository/header-section.repository.js.map +1 -0
- package/dist/module/layout/service/header-section.service.d.ts +8 -0
- package/dist/module/layout/service/header-section.service.js +37 -0
- package/dist/module/layout/service/header-section.service.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core.module.ts +5 -2
- package/src/module/layout/controller/layout.controller.ts +32 -0
- package/src/module/layout/dto/header.dto.ts +0 -0
- package/src/module/layout/entity/header-items.entity.ts +28 -0
- package/src/module/layout/entity/header-section.entity.ts +19 -0
- package/src/module/layout/layout.module.ts +17 -0
- package/src/module/layout/repository/header-items.repository.ts +18 -0
- package/src/module/layout/repository/header-section.repository.ts +18 -0
- package/src/module/layout/service/header-section.service.ts +26 -0
package/package.json
CHANGED
package/src/core.module.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { UserModule } from './module/user/user.module';
|
|
|
6
6
|
import { EntityModule } from './module/meta/entity.module';
|
|
7
7
|
import { ModuleModule } from './module/module/module.module';
|
|
8
8
|
import { NotificationModule } from './module/notification/notification.module';
|
|
9
|
+
import { LayoutModule } from './module/layout/layout.module';
|
|
9
10
|
|
|
10
11
|
@Global()
|
|
11
12
|
@Module({})
|
|
@@ -25,7 +26,8 @@ export class CoreModule {
|
|
|
25
26
|
UtilsModule,
|
|
26
27
|
UserModule,
|
|
27
28
|
ModuleModule,
|
|
28
|
-
NotificationModule
|
|
29
|
+
NotificationModule,
|
|
30
|
+
LayoutModule,
|
|
29
31
|
],
|
|
30
32
|
exports: [
|
|
31
33
|
ConfigModule,
|
|
@@ -35,7 +37,8 @@ export class CoreModule {
|
|
|
35
37
|
UtilsModule,
|
|
36
38
|
UserModule,
|
|
37
39
|
ModuleModule,
|
|
38
|
-
NotificationModule
|
|
40
|
+
NotificationModule,
|
|
41
|
+
LayoutModule,
|
|
39
42
|
],
|
|
40
43
|
};
|
|
41
44
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Controller, Get, HttpStatus, Inject, Req, Res, UseGuards } from '@nestjs/common';
|
|
2
|
+
import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
|
|
3
|
+
import { HeaderSectionService } from '../service/header-section.service';
|
|
4
|
+
import { Request, Response } from 'express';
|
|
5
|
+
import { UserService } from '../../user/service/user.service';
|
|
6
|
+
import { ENTITYTYPE_USER } from '../../../constant/global.constant';
|
|
7
|
+
|
|
8
|
+
@Controller('layout')
|
|
9
|
+
@UseGuards(JwtAuthGuard)
|
|
10
|
+
export class LayoutController {
|
|
11
|
+
constructor(private readonly headerSectionService: HeaderSectionService,
|
|
12
|
+
@Inject('UserService') private readonly userService: UserService) {}
|
|
13
|
+
|
|
14
|
+
@Get('header')
|
|
15
|
+
async getHeader(@Req() req: Request & { user: any }, @Res() res: Response) {
|
|
16
|
+
const userId = req.user.userId;
|
|
17
|
+
const userData = await this.userService.getEntityData(ENTITYTYPE_USER, userId);
|
|
18
|
+
if (userData) {
|
|
19
|
+
let response = await this.headerSectionService.findByOrganizationId(userData.organization_id);
|
|
20
|
+
return res.json({
|
|
21
|
+
success: true,
|
|
22
|
+
data: response,
|
|
23
|
+
message: 'Header fetched successfully'
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
return res.status(HttpStatus.BAD_REQUEST).json({
|
|
27
|
+
success: false,
|
|
28
|
+
message: 'User data not found'
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
@Entity({ name: 'cr_header_items' })
|
|
4
|
+
export class HeaderItems {
|
|
5
|
+
@PrimaryGeneratedColumn()
|
|
6
|
+
id: number;
|
|
7
|
+
|
|
8
|
+
@Column({ nullable: true })
|
|
9
|
+
section_id: number;
|
|
10
|
+
|
|
11
|
+
@Column({length: 50, nullable: true, type: 'varchar'})
|
|
12
|
+
key: string;
|
|
13
|
+
|
|
14
|
+
@Column({length: 50, nullable: true, type: 'varchar'})
|
|
15
|
+
type: string;
|
|
16
|
+
|
|
17
|
+
@Column({length: 50, nullable: true, type: 'varchar'})
|
|
18
|
+
icon: string;
|
|
19
|
+
|
|
20
|
+
@Column({length: 50, nullable: true, type: 'varchar'})
|
|
21
|
+
border: string;
|
|
22
|
+
|
|
23
|
+
@Column({length: 50, nullable: true, type: 'varchar'})
|
|
24
|
+
avatar: string;
|
|
25
|
+
|
|
26
|
+
@Column({length: 500, nullable: true, type: 'varchar'})
|
|
27
|
+
options: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
@Entity({ name: 'cr_header_sections' })
|
|
4
|
+
export class HeaderSection {
|
|
5
|
+
@PrimaryGeneratedColumn()
|
|
6
|
+
id: number;
|
|
7
|
+
|
|
8
|
+
@Column({ name: 'enterprise_id', type: 'int', nullable: true })
|
|
9
|
+
enterprise_id: number;
|
|
10
|
+
|
|
11
|
+
@Column({ nullable: true, type: 'int' })
|
|
12
|
+
organization_id: number;
|
|
13
|
+
|
|
14
|
+
@Column({ length: 50, type: 'varchar', nullable: true })
|
|
15
|
+
section_name: string;
|
|
16
|
+
|
|
17
|
+
@Column({ length: 50, type: 'varchar', nullable: true })
|
|
18
|
+
position: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
3
|
+
import { HeaderSection } from './entity/header-section.entity';
|
|
4
|
+
import { HeaderItems } from './entity/header-items.entity';
|
|
5
|
+
import { HeaderItemsRepository } from './repository/header-items.repository';
|
|
6
|
+
import { HeaderSectionRepository } from './repository/header-section.repository';
|
|
7
|
+
import { LayoutController } from './controller/layout.controller';
|
|
8
|
+
import { UserModule } from '../user/user.module';
|
|
9
|
+
import { HeaderSectionService } from './service/header-section.service';
|
|
10
|
+
|
|
11
|
+
@Module({
|
|
12
|
+
imports: [TypeOrmModule.forFeature([HeaderSection, HeaderItems]), UserModule],
|
|
13
|
+
controllers: [LayoutController],
|
|
14
|
+
providers: [HeaderItemsRepository, HeaderSectionRepository, HeaderSectionService],
|
|
15
|
+
exports: [],
|
|
16
|
+
})
|
|
17
|
+
export class LayoutModule {}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
+
import { HeaderItems } from '../entity/header-items.entity';
|
|
4
|
+
import { Repository } from 'typeorm';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class HeaderItemsRepository {
|
|
8
|
+
constructor(
|
|
9
|
+
@InjectRepository(HeaderItems)
|
|
10
|
+
private readonly headerItemsRepository: Repository<HeaderItems>,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
async findBySectionId(sectionId: number) {
|
|
14
|
+
return await this.headerItemsRepository.find({
|
|
15
|
+
where: { section_id: sectionId },
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
+
import { Repository } from 'typeorm';
|
|
4
|
+
import { HeaderSection } from '../entity/header-section.entity';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class HeaderSectionRepository {
|
|
8
|
+
constructor(
|
|
9
|
+
@InjectRepository(HeaderSection)
|
|
10
|
+
private readonly headerSectionRepository: Repository<HeaderSection>,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
async findByOrganizationId(organizationId: number) {
|
|
14
|
+
return await this.headerSectionRepository.find({
|
|
15
|
+
where: { organization_id: organizationId },
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { HeaderSectionRepository } from '../repository/header-section.repository';
|
|
3
|
+
import { HeaderItemsRepository } from '../repository/header-items.repository';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class HeaderSectionService {
|
|
7
|
+
constructor(
|
|
8
|
+
private readonly headerSectionRepository: HeaderSectionRepository,
|
|
9
|
+
private readonly headerItemsRepository: HeaderItemsRepository,
|
|
10
|
+
) {}
|
|
11
|
+
|
|
12
|
+
async findByOrganizationId(organizationId: number) {
|
|
13
|
+
let headerSections =
|
|
14
|
+
await this.headerSectionRepository.findByOrganizationId(organizationId);
|
|
15
|
+
let response = {};
|
|
16
|
+
|
|
17
|
+
await Promise.all(
|
|
18
|
+
headerSections.map(async (headerSection) => {
|
|
19
|
+
response[headerSection.section_name] =
|
|
20
|
+
await this.headerItemsRepository.findBySectionId(headerSection.id);
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return response;
|
|
25
|
+
}
|
|
26
|
+
}
|