rez_core 1.0.10 → 1.0.12
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/.env +3 -1
- package/data/master.xlsx +0 -0
- package/dist/config/config.module.js +1 -1
- package/dist/config/config.module.js.map +1 -1
- package/dist/decorators/roles.decorator.js.map +1 -1
- package/dist/module/enterprise/enterprise.module.js +1 -1
- package/dist/module/enterprise/enterprise.module.js.map +1 -1
- package/dist/module/enterprise/service/organization.service.js.map +1 -1
- package/dist/module/master/controller/master.controller.js +1 -1
- package/dist/module/master/controller/master.controller.js.map +1 -1
- package/dist/module/meta/controller/entity.controller.d.ts +1 -0
- package/dist/module/meta/controller/entity.controller.js +38 -2
- package/dist/module/meta/controller/entity.controller.js.map +1 -1
- package/dist/module/meta/entity/base-entity.entity.js.map +1 -1
- package/dist/module/meta/entity/entity-table-column.entity.js.map +1 -1
- package/dist/module/meta/entity/entity-table.entity.d.ts +1 -0
- package/dist/module/meta/entity/entity-table.entity.js +4 -0
- package/dist/module/meta/entity/entity-table.entity.js.map +1 -1
- package/dist/module/meta/entity.module.js +8 -1
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/repository/entity-table-column.repository.js +2 -2
- package/dist/module/meta/repository/entity-table.repository.d.ts +1 -0
- package/dist/module/meta/repository/entity-table.repository.js +9 -0
- package/dist/module/meta/repository/entity-table.repository.js.map +1 -1
- package/dist/module/meta/service/entity-list.service.d.ts +2 -1
- package/dist/module/meta/service/entity-list.service.js +12 -1
- package/dist/module/meta/service/entity-list.service.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.d.ts +11 -4
- package/dist/module/meta/service/entity-service-impl.service.js +67 -9
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/meta/service/entity-table-column.service.d.ts +1 -0
- package/dist/module/meta/service/entity-table-column.service.js +4 -0
- package/dist/module/meta/service/entity-table-column.service.js.map +1 -1
- package/dist/module/meta/service/entity-table.service.d.ts +1 -0
- package/dist/module/meta/service/entity-table.service.js +3 -0
- package/dist/module/meta/service/entity-table.service.js.map +1 -1
- package/dist/module/meta/service/entity.service.d.ts +1 -0
- package/dist/module/meta/service/preference.service.d.ts +1 -5
- package/dist/module/meta/service/preference.service.js +3 -11
- package/dist/module/meta/service/preference.service.js.map +1 -1
- package/dist/module/module/controller/menu.controller.js +1 -1
- package/dist/module/module/controller/menu.controller.js.map +1 -1
- package/dist/module/module/controller/module-access.controller.js +1 -1
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/entity/menu.entity.js.map +1 -1
- package/dist/module/module/entity/module.entity.js.map +1 -1
- package/dist/module/module/module.module.js +2 -2
- package/dist/module/module/module.module.js.map +1 -1
- package/dist/module/module/repository/menu.repository.js +3 -3
- package/dist/module/module/repository/menu.repository.js.map +1 -1
- package/dist/module/module/repository/module-access.repository.js +31 -20
- package/dist/module/module/repository/module-access.repository.js.map +1 -1
- package/dist/module/module/service/menu.service.js +2 -2
- package/dist/module/module/service/menu.service.js.map +1 -1
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/notification/controller/otp.controller.d.ts +15 -0
- package/dist/module/notification/controller/otp.controller.js +59 -0
- package/dist/module/notification/controller/otp.controller.js.map +1 -0
- package/dist/module/notification/entity/otp.entity.d.ts +10 -0
- package/dist/module/notification/entity/otp.entity.js +52 -0
- package/dist/module/notification/entity/otp.entity.js.map +1 -0
- package/dist/module/notification/notification.module.d.ts +2 -0
- package/dist/module/notification/notification.module.js +27 -0
- package/dist/module/notification/notification.module.js.map +1 -0
- package/dist/module/notification/repository/otp.repository.d.ts +9 -0
- package/dist/module/notification/repository/otp.repository.js +44 -0
- package/dist/module/notification/repository/otp.repository.js.map +1 -0
- package/dist/module/notification/service/otp.service.d.ts +12 -0
- package/dist/module/notification/service/otp.service.js +61 -0
- package/dist/module/notification/service/otp.service.js.map +1 -0
- package/dist/module/user/controller/login.controller.js +1 -1
- package/dist/module/user/controller/login.controller.js.map +1 -1
- package/dist/module/user/controller/user.controller.js +1 -1
- package/dist/module/user/controller/user.controller.js.map +1 -1
- package/dist/module/user/dto/create-user.dto.js.map +1 -1
- package/dist/module/user/entity/role.entity.js.map +1 -1
- package/dist/module/user/repository/user-role-mapping.repository.js +4 -1
- package/dist/module/user/repository/user-role-mapping.repository.js.map +1 -1
- package/dist/module/user/repository/user.repository.js.map +1 -1
- package/dist/module/user/service/role.service.d.ts +1 -5
- package/dist/module/user/service/role.service.js +3 -10
- package/dist/module/user/service/role.service.js.map +1 -1
- package/dist/module/user/service/user.service.d.ts +1 -5
- package/dist/module/user/service/user.service.js +3 -11
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/module/user/user.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/dto/excel-data.dto.d.ts +7 -0
- package/dist/utils/dto/excel-data.dto.js +16 -0
- package/dist/utils/dto/excel-data.dto.js.map +1 -0
- package/dist/utils/dto/excelsheet-data.dto.d.ts +5 -0
- package/dist/utils/dto/excelsheet-data.dto.js +3 -0
- package/dist/utils/dto/excelsheet-data.dto.js.map +1 -0
- package/dist/utils/service/excel-helper.service.d.ts +3 -1
- package/dist/utils/service/excel-helper.service.js +12 -3
- package/dist/utils/service/excel-helper.service.js.map +1 -1
- package/dist/utils/service/loggingUtil.service.js +6 -6
- package/dist/utils/service/loggingUtil.service.js.map +1 -1
- package/dist/utils/utils.module.js.map +1 -1
- package/package.json +1 -1
- package/src/app.controller.ts +12 -12
- package/src/app.service.ts +8 -8
- package/src/config/config.module.ts +1 -1
- package/src/decorators/roles.decorator.ts +5 -2
- package/src/module/auth/guards/google-auth.guard.ts +1 -1
- package/src/module/enterprise/enterprise.module.ts +2 -3
- package/src/module/enterprise/service/organization.service.ts +8 -5
- package/src/module/master/controller/master.controller.ts +1 -1
- package/src/module/meta/controller/entity.controller.ts +57 -4
- package/src/module/meta/entity/base-entity.entity.ts +1 -1
- package/src/module/meta/entity/entity-table-column.entity.ts +1 -1
- package/src/module/meta/entity/entity-table.entity.ts +4 -2
- package/src/module/meta/entity.module.ts +8 -1
- package/src/module/meta/repository/entity-table-column.repository.ts +3 -3
- package/src/module/meta/repository/entity-table.repository.ts +14 -0
- package/src/module/meta/service/entity-list.service.ts +15 -5
- package/src/module/meta/service/entity-service-impl.service.ts +98 -8
- package/src/module/meta/service/entity-table-column.service.ts +14 -1
- package/src/module/meta/service/entity-table.service.ts +8 -1
- package/src/module/meta/service/entity.service.ts +12 -1
- package/src/module/meta/service/preference.service.ts +2 -17
- package/src/module/module/controller/menu.controller.ts +1 -1
- package/src/module/module/controller/module-access.controller.ts +2 -2
- package/src/module/module/entity/menu.entity.ts +9 -9
- package/src/module/module/entity/module.entity.ts +8 -8
- package/src/module/module/module.module.ts +2 -4
- package/src/module/module/repository/menu.repository.ts +7 -10
- package/src/module/module/repository/module-access.repository.ts +57 -42
- package/src/module/module/service/menu.service.ts +9 -10
- package/src/module/module/service/module-access.service.ts +8 -3
- package/src/module/notification/controller/otp.controller.ts +27 -0
- package/src/module/notification/entity/otp.entity.ts +28 -0
- package/src/module/notification/notification.module.ts +14 -0
- package/src/module/notification/repository/otp.repository.ts +27 -0
- package/src/module/notification/service/otp.service.ts +50 -0
- package/src/module/user/controller/login.controller.ts +1 -1
- package/src/module/user/controller/user.controller.ts +1 -1
- package/src/module/user/dto/create-user.dto.ts +43 -43
- package/src/module/user/entity/role.entity.ts +1 -1
- package/src/module/user/repository/user-role-mapping.repository.ts +9 -3
- package/src/module/user/repository/user.repository.ts +2 -2
- package/src/module/user/service/role.service.ts +2 -13
- package/src/module/user/service/user-role-mapping.service.ts +1 -1
- package/src/module/user/service/user-session.service.ts +1 -1
- package/src/module/user/service/user.service.ts +4 -17
- package/src/module/user/user.module.ts +0 -1
- package/src/utils/dto/excel-data.dto.ts +14 -0
- package/src/utils/dto/excelsheet-data.dto.ts +5 -0
- package/src/utils/service/clockIDGenUtil.service.ts +1 -1
- package/src/utils/service/dateUtil.service.ts +1 -1
- package/src/utils/service/excel-helper.service.ts +14 -1
- package/src/utils/service/loggingUtil.service.ts +48 -48
- package/src/utils/utils.module.ts +7 -7
|
@@ -8,11 +8,24 @@ export class EntityTableColumnService {
|
|
|
8
8
|
) {}
|
|
9
9
|
|
|
10
10
|
async getAttributeJson(parentId: number, parentType: string) {
|
|
11
|
-
let entityTableColumns =
|
|
11
|
+
let entityTableColumns =
|
|
12
|
+
await this.entityTableColumnRepository.findByParentIdAndParentType(
|
|
13
|
+
parentId,
|
|
14
|
+
parentType,
|
|
15
|
+
);
|
|
12
16
|
let attributeJson = {};
|
|
13
17
|
entityTableColumns.forEach((value) => {
|
|
14
18
|
attributeJson[value.attribute_key] = value.data_type;
|
|
15
19
|
});
|
|
16
20
|
return attributeJson;
|
|
17
21
|
}
|
|
22
|
+
|
|
23
|
+
async findByParentIdAndParentType(parentId: number, parentType: string) {
|
|
24
|
+
let entityTableColumns =
|
|
25
|
+
await this.entityTableColumnRepository.findByParentIdAndParentType(
|
|
26
|
+
parentId,
|
|
27
|
+
parentType,
|
|
28
|
+
);
|
|
29
|
+
return entityTableColumns;
|
|
30
|
+
}
|
|
18
31
|
}
|
|
@@ -6,6 +6,13 @@ export class EntityTableService {
|
|
|
6
6
|
constructor(private entityTableRepository: EntityTableRepository) {}
|
|
7
7
|
|
|
8
8
|
async findByEntityTypeAndListType(entityType: string, listType: string) {
|
|
9
|
-
return await this.entityTableRepository.findByEntityTypeAndListType(
|
|
9
|
+
return await this.entityTableRepository.findByEntityTypeAndListType(
|
|
10
|
+
entityType,
|
|
11
|
+
listType,
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async findByEntityTypeAndListTypeAndDisplayType(entityType: string, listType: string, displayType: string) {
|
|
16
|
+
return await this.entityTableRepository.findByEntityTypeAndListTypeAndDisplayType(entityType, listType, displayType);
|
|
10
17
|
}
|
|
11
18
|
}
|
|
@@ -4,7 +4,11 @@ import { EntityListData } from '../dto/entity-list-data.dto';
|
|
|
4
4
|
import { EntityManager } from 'typeorm';
|
|
5
5
|
|
|
6
6
|
export interface EntityService<T extends BaseEntity> {
|
|
7
|
-
createEntity(
|
|
7
|
+
createEntity(
|
|
8
|
+
entityData: T,
|
|
9
|
+
loggedInUser: UserData,
|
|
10
|
+
manager?: EntityManager,
|
|
11
|
+
): Promise<BaseEntity>;
|
|
8
12
|
|
|
9
13
|
getEntityData(
|
|
10
14
|
entityType: string,
|
|
@@ -32,4 +36,11 @@ export interface EntityService<T extends BaseEntity> {
|
|
|
32
36
|
pageNumber: number,
|
|
33
37
|
pageSize: number,
|
|
34
38
|
): Promise<EntityListData>;
|
|
39
|
+
|
|
40
|
+
generateExcelReport(
|
|
41
|
+
entityType: string,
|
|
42
|
+
filterCriteria: Record<string, any>,
|
|
43
|
+
listEntityType: string,
|
|
44
|
+
displayType: string,
|
|
45
|
+
): Promise<string | null>;
|
|
35
46
|
}
|
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
import { EntityServiceImpl } from './entity-service-impl.service';
|
|
2
2
|
import { Injectable } from '@nestjs/common';
|
|
3
3
|
import { PreferenceRepository } from '../repository/preference.repository';
|
|
4
|
-
import { EntityMasterService } from './entity-master.service';
|
|
5
|
-
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
6
|
-
import { LoggingService } from '../../../utils/service/loggingUtil.service';
|
|
7
|
-
import { EntityListService } from './entity-list.service';
|
|
8
4
|
|
|
9
5
|
@Injectable()
|
|
10
6
|
export class PreferenceService extends EntityServiceImpl {
|
|
11
|
-
constructor(
|
|
12
|
-
|
|
13
|
-
reflectionHelper: ReflectionHelper,
|
|
14
|
-
loggingService: LoggingService,
|
|
15
|
-
entityListService: EntityListService,
|
|
16
|
-
private readonly preferenceRepository: PreferenceRepository,
|
|
17
|
-
) {
|
|
18
|
-
super(
|
|
19
|
-
entityMasterService,
|
|
20
|
-
reflectionHelper,
|
|
21
|
-
entityListService,
|
|
22
|
-
loggingService,
|
|
23
|
-
);
|
|
7
|
+
constructor(private readonly preferenceRepository: PreferenceRepository) {
|
|
8
|
+
super();
|
|
24
9
|
}
|
|
25
10
|
|
|
26
11
|
async getPreferenceValue(preferenceKey: string): Promise<string | undefined> {
|
|
@@ -2,7 +2,7 @@ import { Controller, Get, Request, UseGuards } from '@nestjs/common';
|
|
|
2
2
|
import { MenuService } from '../service/menu.service';
|
|
3
3
|
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
4
4
|
|
|
5
|
-
@Controller('menu')
|
|
5
|
+
@Controller('api/menu')
|
|
6
6
|
export class MenuController {
|
|
7
7
|
constructor(private readonly menuService: MenuService) {}
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Controller, Get, Post,
|
|
1
|
+
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
|
2
2
|
import { ModuleAccessService } from '../service/module-access.service';
|
|
3
3
|
|
|
4
|
-
@Controller('module-access')
|
|
4
|
+
@Controller('api/module-access')
|
|
5
5
|
export class ModuleAccessController {
|
|
6
6
|
constructor(private readonly moduleAccessService: ModuleAccessService) {}
|
|
7
7
|
|
|
@@ -9,30 +9,30 @@ export class MenuData {
|
|
|
9
9
|
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
10
10
|
name: string;
|
|
11
11
|
|
|
12
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
12
|
+
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
13
13
|
module_code: string;
|
|
14
14
|
|
|
15
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
15
|
+
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
16
16
|
status: StatusType;
|
|
17
17
|
|
|
18
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
18
|
+
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
19
19
|
wbs_code: string;
|
|
20
20
|
|
|
21
|
-
@Column({type: 'varchar', nullable: true })
|
|
21
|
+
@Column({ type: 'varchar', nullable: true })
|
|
22
22
|
path: string;
|
|
23
23
|
|
|
24
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
24
|
+
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
25
25
|
icon: string;
|
|
26
26
|
|
|
27
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
27
|
+
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
28
28
|
module_level: string;
|
|
29
29
|
|
|
30
|
-
@Column({type: 'int', nullable: true})
|
|
30
|
+
@Column({ type: 'int', nullable: true })
|
|
31
31
|
parent_id: number;
|
|
32
32
|
|
|
33
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
33
|
+
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
34
34
|
parent_code: string;
|
|
35
35
|
|
|
36
|
-
@Column({type: 'int', nullable: true})
|
|
36
|
+
@Column({ type: 'int', nullable: true })
|
|
37
37
|
ui_visible: number;
|
|
38
38
|
}
|
|
@@ -6,27 +6,27 @@ export class ModuleData {
|
|
|
6
6
|
@PrimaryGeneratedColumn({ type: 'int' })
|
|
7
7
|
id: number;
|
|
8
8
|
|
|
9
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
9
|
+
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
10
10
|
name: string;
|
|
11
11
|
|
|
12
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
12
|
+
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
13
13
|
module_code: string;
|
|
14
14
|
|
|
15
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
15
|
+
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
16
16
|
wbs_code: string;
|
|
17
17
|
|
|
18
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
18
|
+
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
19
19
|
status: StatusType;
|
|
20
20
|
|
|
21
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
21
|
+
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
22
22
|
module_level: string;
|
|
23
23
|
|
|
24
|
-
@Column({type: 'int', nullable: true })
|
|
24
|
+
@Column({ type: 'int', nullable: true })
|
|
25
25
|
parent_id: number;
|
|
26
26
|
|
|
27
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
27
|
+
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
28
28
|
parent_code: string;
|
|
29
29
|
|
|
30
|
-
@Column({type: 'int', nullable: true})
|
|
30
|
+
@Column({ type: 'int', nullable: true })
|
|
31
31
|
ui_visible: number;
|
|
32
32
|
}
|
|
@@ -13,7 +13,6 @@ import { ModuleAccessRepository } from './repository/module-access.repository';
|
|
|
13
13
|
import { ModuleAccessController } from './controller/module-access.controller';
|
|
14
14
|
import { UserRoleMapping } from '../user/entity/user-role-mapping.entity';
|
|
15
15
|
import { UserModule } from '../user/user.module';
|
|
16
|
-
import { RoleRepository } from '../user/repository/role.repository';
|
|
17
16
|
import { Role } from '../user/entity/role.entity';
|
|
18
17
|
|
|
19
18
|
@Module({
|
|
@@ -24,10 +23,10 @@ import { Role } from '../user/entity/role.entity';
|
|
|
24
23
|
ModuleAction,
|
|
25
24
|
MenuData,
|
|
26
25
|
UserRoleMapping,
|
|
27
|
-
Role
|
|
26
|
+
Role,
|
|
28
27
|
]),
|
|
29
28
|
UtilsModule,
|
|
30
|
-
UserModule
|
|
29
|
+
UserModule,
|
|
31
30
|
],
|
|
32
31
|
controllers: [MenuController, ModuleAccessController],
|
|
33
32
|
providers: [
|
|
@@ -35,7 +34,6 @@ import { Role } from '../user/entity/role.entity';
|
|
|
35
34
|
MenuService,
|
|
36
35
|
MenuRepository,
|
|
37
36
|
ModuleAccessRepository,
|
|
38
|
-
|
|
39
37
|
],
|
|
40
38
|
exports: [ModuleAccessService],
|
|
41
39
|
})
|
|
@@ -22,7 +22,7 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
22
22
|
.where('userRoleMapping.user_id = :userId', { userId })
|
|
23
23
|
.getMany();
|
|
24
24
|
|
|
25
|
-
return roles.map(role => role.role_id);
|
|
25
|
+
return roles.map((role) => role.role_id);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -36,13 +36,13 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
36
36
|
.select('role.code')
|
|
37
37
|
.where('role.id IN (:...roleIds)', { roleIds })
|
|
38
38
|
.getMany();
|
|
39
|
-
|
|
40
|
-
const codes = roleCodes.map(role => role.code);
|
|
41
|
-
|
|
39
|
+
|
|
40
|
+
const codes = roleCodes.map((role) => role.code);
|
|
41
|
+
|
|
42
42
|
if (codes.length === 0) {
|
|
43
43
|
return [];
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
// Get accessible modules using role codes
|
|
47
47
|
const modules = await this.dataSource
|
|
48
48
|
.getRepository(ModuleAccess)
|
|
@@ -51,11 +51,9 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
51
51
|
.where('moduleAccess.role_code IN (:...codes)', { codes })
|
|
52
52
|
.andWhere('moduleAccess.access_flag > 0')
|
|
53
53
|
.getMany();
|
|
54
|
-
|
|
55
|
-
return modules.map(module => module.module_code);
|
|
54
|
+
|
|
55
|
+
return modules.map((module) => module.module_code);
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
57
|
|
|
60
58
|
/**
|
|
61
59
|
* Get menu items based on accessible modules.
|
|
@@ -65,5 +63,4 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
65
63
|
.where('menu.module_code IN (:...moduleCodes)', { moduleCodes })
|
|
66
64
|
.getMany();
|
|
67
65
|
}
|
|
68
|
-
|
|
69
66
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
-
import {
|
|
3
|
+
import { In, Repository } from 'typeorm';
|
|
4
4
|
import { Role } from 'src/module/user/entity/role.entity';
|
|
5
5
|
import { ModuleAccess } from '../entity/module-access.entity';
|
|
6
6
|
import { ModuleAction } from '../entity/module-action.entity';
|
|
@@ -16,7 +16,7 @@ export class ModuleAccessRepository {
|
|
|
16
16
|
@InjectRepository(ModuleAccess)
|
|
17
17
|
private readonly moduleAccessRepo: Repository<ModuleAccess>,
|
|
18
18
|
@InjectRepository(ModuleAction)
|
|
19
|
-
private readonly moduleActionRepo: Repository<ModuleAction
|
|
19
|
+
private readonly moduleActionRepo: Repository<ModuleAction>,
|
|
20
20
|
) {}
|
|
21
21
|
|
|
22
22
|
async getRoles() {
|
|
@@ -24,83 +24,98 @@ export class ModuleAccessRepository {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async getModules() {
|
|
27
|
-
return this.moduleRepo.find({ where: { module_level: 'MAINMOD' }});
|
|
27
|
+
return this.moduleRepo.find({ where: { module_level: 'MAINMOD' } });
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
async getAccessListing(roleIds: number[]) {
|
|
31
31
|
// Fetch roles using role IDs
|
|
32
32
|
const roles = await this.roleRepo.find({ where: { id: In(roleIds) } });
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
// Extract role codes from roles
|
|
35
|
-
const roleCodes = roles.map(role => role.code);
|
|
36
|
-
|
|
35
|
+
const roleCodes = roles.map((role) => role.code);
|
|
36
|
+
|
|
37
37
|
// Fetch module access using role codes
|
|
38
|
-
const moduleAccesses = await this.moduleAccessRepo.find({
|
|
39
|
-
|
|
38
|
+
const moduleAccesses = await this.moduleAccessRepo.find({
|
|
39
|
+
where: { role_code: In(roleCodes) },
|
|
40
|
+
});
|
|
41
|
+
|
|
40
42
|
// Map role data to include access permissions
|
|
41
|
-
return roles.map(role => ({
|
|
43
|
+
return roles.map((role) => ({
|
|
42
44
|
role_code: role.code,
|
|
43
45
|
name: role.name,
|
|
44
46
|
permission: moduleAccesses
|
|
45
|
-
.filter(access => access.role_code === role.code)
|
|
46
|
-
.map(access => ({
|
|
47
|
+
.filter((access) => access.role_code === role.code)
|
|
48
|
+
.map((access) => ({
|
|
47
49
|
action: access.action_type,
|
|
48
50
|
access: access.access_flag,
|
|
49
|
-
code: access.module_code
|
|
50
|
-
}))
|
|
51
|
+
code: access.module_code,
|
|
52
|
+
})),
|
|
51
53
|
}));
|
|
52
54
|
}
|
|
53
|
-
|
|
55
|
+
|
|
54
56
|
async getMenuListing(mainModIds: string[]) {
|
|
55
57
|
// Get MAINMOD modules using their IDs
|
|
56
|
-
const mainModules = await this.moduleRepo.find({
|
|
57
|
-
|
|
58
|
+
const mainModules = await this.moduleRepo.find({
|
|
59
|
+
where: { id: In(mainModIds), module_level: 'MAINMOD' },
|
|
58
60
|
});
|
|
59
61
|
|
|
60
62
|
if (!mainModules.length) return [];
|
|
61
63
|
|
|
62
64
|
// Extract WBS codes of the MAINMOD modules
|
|
63
|
-
const wbsCodes = mainModules.map(mod => mod.wbs_code);
|
|
65
|
+
const wbsCodes = mainModules.map((mod) => mod.wbs_code);
|
|
64
66
|
|
|
65
67
|
// Fetch all related modules using `LIKE` for WBS structure
|
|
66
|
-
const modules = await this.moduleRepo
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
const modules = await this.moduleRepo
|
|
69
|
+
.createQueryBuilder('module')
|
|
70
|
+
.where(
|
|
71
|
+
wbsCodes
|
|
72
|
+
.map((code) => `module.wbs_code LIKE :code${code}`)
|
|
73
|
+
.join(' OR '),
|
|
74
|
+
Object.fromEntries(wbsCodes.map((code) => [`code${code}`, `${code}%`])),
|
|
75
|
+
)
|
|
76
|
+
.getMany();
|
|
72
77
|
|
|
73
78
|
// Fetch module actions
|
|
74
79
|
const moduleActions = await this.moduleActionRepo.find();
|
|
75
80
|
|
|
76
81
|
// Function to recursively build module hierarchy
|
|
77
82
|
const buildHierarchy = (parentWbs: string) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
return modules
|
|
84
|
+
.filter(
|
|
85
|
+
(mod) =>
|
|
86
|
+
mod.wbs_code.startsWith(parentWbs) && mod.wbs_code !== parentWbs,
|
|
87
|
+
)
|
|
88
|
+
.map((mod) => ({
|
|
89
|
+
name: mod.name,
|
|
90
|
+
code: mod.module_code,
|
|
91
|
+
permission: moduleActions
|
|
92
|
+
.filter((action) => action.module_code === mod.module_code)
|
|
93
|
+
.map((action) => ({
|
|
94
|
+
action: action.action_type,
|
|
95
|
+
name: action.action_type,
|
|
96
|
+
})),
|
|
97
|
+
submod: buildHierarchy(mod.wbs_code),
|
|
98
|
+
}));
|
|
88
99
|
};
|
|
89
100
|
|
|
90
101
|
// Construct the final hierarchical response
|
|
91
|
-
return mainModules.map(mod => ({
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
102
|
+
return mainModules.map((mod) => ({
|
|
103
|
+
name: mod.name,
|
|
104
|
+
code: mod.module_code,
|
|
105
|
+
permission: moduleActions
|
|
106
|
+
.filter((action) => action.module_code === mod.module_code)
|
|
107
|
+
.map((action) => ({
|
|
108
|
+
action: action.action_type,
|
|
109
|
+
name: action.action_type,
|
|
110
|
+
})),
|
|
111
|
+
submod: buildHierarchy(mod.wbs_code),
|
|
98
112
|
}));
|
|
99
|
-
}
|
|
113
|
+
}
|
|
100
114
|
async updateModuleAccess(moduleAccessData: any[]): Promise<boolean> {
|
|
101
115
|
try {
|
|
102
116
|
for (const access of moduleAccessData) {
|
|
103
|
-
const { role_code, module_code, action_type, access_flag, app_code } =
|
|
117
|
+
const { role_code, module_code, action_type, access_flag, app_code } =
|
|
118
|
+
access;
|
|
104
119
|
|
|
105
120
|
const existingEntry = await this.moduleAccessRepo.findOne({
|
|
106
121
|
where: { role_code, module_code, action_type, app_code },
|
|
@@ -17,14 +17,15 @@ export class MenuService {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// Step 2: Get the modules the user has access to
|
|
20
|
-
const moduleCodes =
|
|
20
|
+
const moduleCodes =
|
|
21
|
+
await this.menuRepository.getAccessibleModules(roleCodes);
|
|
21
22
|
if (!moduleCodes.length) {
|
|
22
23
|
return { menu: [] }; // Return empty menu if no accessible modules
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
// Step 3: Get the menu items based on accessible modules
|
|
26
27
|
const menuItems = await this.menuRepository.getMenuItems(moduleCodes);
|
|
27
|
-
|
|
28
|
+
|
|
28
29
|
// Step 4: Build hierarchical menu structure
|
|
29
30
|
const menuTree = this.buildMenuHierarchy(menuItems);
|
|
30
31
|
|
|
@@ -37,25 +38,23 @@ export class MenuService {
|
|
|
37
38
|
private buildMenuHierarchy(menuItems: MenuData[]): any[] {
|
|
38
39
|
const menuMap = new Map<string, any>(); // Use module_code as the key
|
|
39
40
|
const rootMenu: any[] = [];
|
|
40
|
-
|
|
41
|
+
|
|
41
42
|
// Initialize menu items in the map
|
|
42
|
-
menuItems.forEach(menu => {
|
|
43
|
+
menuItems.forEach((menu) => {
|
|
43
44
|
menuMap.set(menu.wbs_code, { ...menu, submenu: [] });
|
|
44
45
|
});
|
|
45
|
-
|
|
46
|
+
|
|
46
47
|
// Build the hierarchy based on WBS code
|
|
47
|
-
menuItems.forEach(menu => {
|
|
48
|
+
menuItems.forEach((menu) => {
|
|
48
49
|
const parentWbs = menu.wbs_code.split('.').slice(0, -1).join('.'); // Get parent WBS code
|
|
49
|
-
|
|
50
|
+
|
|
50
51
|
if (parentWbs && menuMap.has(parentWbs)) {
|
|
51
52
|
menuMap.get(parentWbs).submenu.push(menuMap.get(menu.wbs_code));
|
|
52
53
|
} else {
|
|
53
54
|
rootMenu.push(menuMap.get(menu.wbs_code));
|
|
54
55
|
}
|
|
55
56
|
});
|
|
56
|
-
|
|
57
|
+
|
|
57
58
|
return rootMenu;
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
60
|
}
|
|
@@ -3,7 +3,9 @@ import { ModuleAccessRepository } from '../repository/module-access.repository';
|
|
|
3
3
|
|
|
4
4
|
@Injectable()
|
|
5
5
|
export class ModuleAccessService {
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(
|
|
7
|
+
private readonly moduleAccessRepository: ModuleAccessRepository,
|
|
8
|
+
) {}
|
|
7
9
|
|
|
8
10
|
async getRoles() {
|
|
9
11
|
return this.moduleAccessRepository.getRoles();
|
|
@@ -21,12 +23,15 @@ export class ModuleAccessService {
|
|
|
21
23
|
return this.moduleAccessRepository.getMenuListing(mainModIds);
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
async updateModuleAccess(
|
|
26
|
+
async updateModuleAccess(
|
|
27
|
+
moduleAccessData: any[],
|
|
28
|
+
): Promise<{ success: boolean; msg: string }> {
|
|
25
29
|
if (!moduleAccessData || moduleAccessData.length === 0) {
|
|
26
30
|
return { success: false, msg: 'No data provided' };
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
const result =
|
|
33
|
+
const result =
|
|
34
|
+
await this.moduleAccessRepository.updateModuleAccess(moduleAccessData);
|
|
30
35
|
|
|
31
36
|
if (result) {
|
|
32
37
|
return { success: true, msg: 'Module access updated successfully' };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BadRequestException, Controller, HttpCode, HttpStatus, Post, Query } from '@nestjs/common';
|
|
2
|
+
import { OtpService } from '../service/otp.service';
|
|
3
|
+
|
|
4
|
+
@Controller('api/otp')
|
|
5
|
+
export class OtpController{
|
|
6
|
+
otpExpiry = process.env.otp_expiry || '2';
|
|
7
|
+
otpLength = process.env.otp_length || '6';
|
|
8
|
+
constructor(private readonly otpService: OtpService) {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@Post('generate')
|
|
12
|
+
@HttpCode(HttpStatus.OK)
|
|
13
|
+
async generateOtp(@Query('identifier') identifier: string, @Query('service') service: string) {
|
|
14
|
+
let otp = await this.otpService.generate(identifier, service, parseInt(this.otpExpiry), parseInt(this.otpLength));
|
|
15
|
+
return {'otp_id':otp.otp_id, 'success': true};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Post('verify')
|
|
19
|
+
@HttpCode(HttpStatus.OK)
|
|
20
|
+
async verifyOtp(@Query('otp') otp: string, @Query('otp_id') otpId: string) {
|
|
21
|
+
let verify = await this.otpService.verifyOtp(otp, otpId);
|
|
22
|
+
if (!verify) {
|
|
23
|
+
throw new BadRequestException('Invalid OTP!');
|
|
24
|
+
}
|
|
25
|
+
return {'message': 'OTP verified successfully!', 'success': true};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
@Entity({ name: 'cr_otp' })
|
|
4
|
+
export class Otp {
|
|
5
|
+
@PrimaryGeneratedColumn()
|
|
6
|
+
id: number;
|
|
7
|
+
|
|
8
|
+
@Column({ name: 'otp_id', type: 'varchar', length: 50, nullable: true })
|
|
9
|
+
otp_id: string;
|
|
10
|
+
|
|
11
|
+
@Column({ name: 'service', type: 'varchar', length: 50, nullable: true })
|
|
12
|
+
service: string;
|
|
13
|
+
|
|
14
|
+
@Column({ name: 'otp', type: 'varchar', length: 50, nullable: true })
|
|
15
|
+
otp: string;
|
|
16
|
+
|
|
17
|
+
@Column({ name: 'identifier', type: 'varchar', nullable: true })
|
|
18
|
+
identifier: string;
|
|
19
|
+
|
|
20
|
+
@Column({ name: 'created_date', type: 'datetime', nullable: true })
|
|
21
|
+
created_date: Date;
|
|
22
|
+
|
|
23
|
+
@Column({name: 'expiration_date', type: 'datetime'})
|
|
24
|
+
expiration_date: Date;
|
|
25
|
+
|
|
26
|
+
@Column({name: 'verified', type: 'int', nullable: true})
|
|
27
|
+
verified: number;
|
|
28
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { OtpService } from './service/otp.service';
|
|
3
|
+
import { OtpRepository } from './repository/otp.repository';
|
|
4
|
+
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
5
|
+
import { Otp } from './entity/otp.entity';
|
|
6
|
+
import { OtpController } from './controller/otp.controller';
|
|
7
|
+
|
|
8
|
+
@Module({
|
|
9
|
+
imports: [TypeOrmModule.forFeature([Otp])],
|
|
10
|
+
providers: [OtpService, OtpRepository],
|
|
11
|
+
exports: [OtpService],
|
|
12
|
+
controllers: [OtpController]
|
|
13
|
+
})
|
|
14
|
+
export class NotificationModule {}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
+
import { Otp } from '../entity/otp.entity';
|
|
4
|
+
import { Repository } from 'typeorm';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class OtpRepository {
|
|
8
|
+
constructor(
|
|
9
|
+
@InjectRepository(Otp) private readonly otpRepository: Repository<Otp>,
|
|
10
|
+
) {}
|
|
11
|
+
|
|
12
|
+
async save(otp: Otp) {
|
|
13
|
+
return await this.otpRepository.save(otp);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async findByOtpId(otpId: string) {
|
|
17
|
+
return await this.otpRepository.findOne({
|
|
18
|
+
where: {
|
|
19
|
+
otp_id: otpId,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async update(id: number, otp: Otp){
|
|
25
|
+
return await this.otpRepository.update(id, otp);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { OtpRepository } from '../repository/otp.repository';
|
|
3
|
+
import { Otp } from '../entity/otp.entity';
|
|
4
|
+
import { ClockIDGenService } from '../../../utils/service/clockIDGenUtil.service';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class OtpService {
|
|
8
|
+
constructor(
|
|
9
|
+
private readonly otpRepository: OtpRepository,
|
|
10
|
+
private readonly idGen: ClockIDGenService,
|
|
11
|
+
) {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async generate(identifier: string, service: string, expiresIn: number = 5, otpLength: number = 6) {
|
|
15
|
+
let otp = new Otp();
|
|
16
|
+
otp.created_date = new Date();
|
|
17
|
+
otp.otp_id = this.idGen.idGenerator();
|
|
18
|
+
otp.identifier = identifier;
|
|
19
|
+
otp.otp = this.generateOtp(otpLength);
|
|
20
|
+
otp.service = service;
|
|
21
|
+
otp.verified = 0;
|
|
22
|
+
otp.expiration_date = new Date(Date.now() + expiresIn * 60 * 1000);
|
|
23
|
+
|
|
24
|
+
return await this.otpRepository.save(otp);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async verifyOtp(otp: string, otpId: string) {
|
|
28
|
+
let otpEntity = await this.findByOtpId(otpId);
|
|
29
|
+
if (otpEntity) {
|
|
30
|
+
if (otpEntity.otp === otp && new Date(Date.now()) <= otpEntity.expiration_date && 0 === otpEntity.verified) {
|
|
31
|
+
otpEntity.verified = 1;
|
|
32
|
+
const updatedOtp = await this.otpRepository.update(otpEntity.id, otpEntity);
|
|
33
|
+
if (updatedOtp) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async findByOtpId(otpId: string) {
|
|
42
|
+
return await this.otpRepository.findByOtpId(otpId);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private generateOtp(length: number): string {
|
|
46
|
+
const min = 10 ** (length - 1);
|
|
47
|
+
const max = 10 ** length - 1;
|
|
48
|
+
return Math.floor(min + Math.random() * (max - min + 1)).toString();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -13,7 +13,7 @@ import { GoogleAuthGuard } from '../../../module/auth/guards/google-auth.guard';
|
|
|
13
13
|
import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
|
|
14
14
|
import { Request, Response } from 'express';
|
|
15
15
|
|
|
16
|
-
@Controller('auth')
|
|
16
|
+
@Controller('api/auth')
|
|
17
17
|
export class LoginController {
|
|
18
18
|
constructor(private loginService: LoginService) {}
|
|
19
19
|
|