rez_core 1.0.39 → 1.0.41
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/constant/global.constant.d.ts +2 -0
- package/dist/constant/global.constant.js +3 -1
- package/dist/constant/global.constant.js.map +1 -1
- package/dist/module/auth/guards/role.guard.js +3 -3
- package/dist/module/listmaster/controller/list-master.controller.d.ts +14 -0
- package/dist/module/listmaster/controller/list-master.controller.js +38 -0
- package/dist/module/listmaster/controller/list-master.controller.js.map +1 -0
- package/dist/module/listmaster/entity/list-master-items.entity.d.ts +11 -0
- package/dist/module/listmaster/entity/list-master-items.entity.js +55 -0
- package/dist/module/listmaster/entity/list-master-items.entity.js.map +1 -0
- package/dist/module/listmaster/entity/list-master.entity.d.ts +12 -0
- package/dist/module/listmaster/entity/list-master.entity.js +59 -0
- package/dist/module/listmaster/entity/list-master.entity.js.map +1 -0
- package/dist/module/listmaster/listmaster.module.d.ts +2 -0
- package/dist/module/listmaster/listmaster.module.js +27 -0
- package/dist/module/listmaster/listmaster.module.js.map +1 -0
- package/dist/module/listmaster/repository/list-master-items.repository.d.ts +10 -0
- package/dist/module/listmaster/repository/list-master-items.repository.js +38 -0
- package/dist/module/listmaster/repository/list-master-items.repository.js.map +1 -0
- package/dist/module/listmaster/repository/list-master.repository.d.ts +7 -0
- package/dist/module/listmaster/repository/list-master.repository.js +34 -0
- package/dist/module/listmaster/repository/list-master.repository.js.map +1 -0
- package/dist/module/listmaster/service/list-master.service.d.ts +18 -0
- package/dist/module/listmaster/service/list-master.service.js +51 -0
- package/dist/module/listmaster/service/list-master.service.js.map +1 -0
- package/dist/module/master/controller/master.controller.d.ts +3 -1
- package/dist/module/master/controller/master.controller.js.map +1 -1
- package/dist/module/master/service/master.service.d.ts +16 -4
- package/dist/module/master/service/master.service.js +103 -7
- package/dist/module/master/service/master.service.js.map +1 -1
- package/dist/module/meta/entity/entity-master.entity.d.ts +1 -1
- package/dist/module/meta/entity/entity-master.entity.js +1 -1
- package/dist/module/meta/entity/entity-master.entity.js.map +1 -1
- package/dist/module/meta/repository/entity-table.repository.js +3 -1
- package/dist/module/meta/repository/entity-table.repository.js.map +1 -1
- package/dist/module/meta/service/entity-master.service.d.ts +3 -0
- package/dist/module/meta/service/entity-master.service.js +11 -0
- package/dist/module/meta/service/entity-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.js +1 -1
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/module/controller/module-access.controller.d.ts +22 -2
- package/dist/module/module/controller/module-access.controller.js +12 -0
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/repository/module-access.repository.d.ts +25 -3
- package/dist/module/module/repository/module-access.repository.js +57 -5
- package/dist/module/module/repository/module-access.repository.js.map +1 -1
- package/dist/module/module/service/module-access.service.d.ts +22 -2
- package/dist/module/module/service/module-access.service.js +3 -0
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/service/file-util.service.d.ts +3 -0
- package/dist/utils/service/file-util.service.js +15 -0
- package/dist/utils/service/file-util.service.js.map +1 -0
- package/package.json +4 -2
- package/src/constant/global.constant.ts +2 -0
- package/src/module/auth/guards/jwt.guard.ts +22 -22
- package/src/module/auth/guards/role.guard.ts +68 -68
- package/src/module/auth/services/auth.service.ts +29 -29
- package/src/module/auth/services/jwt.service.ts +11 -11
- package/src/module/auth/strategies/local.strategy.ts +13 -13
- package/src/module/dev/dev.module.ts +12 -12
- package/src/module/dev/service/dev.service.ts +7 -7
- package/src/module/enterprise/entity/enterprise.entity.ts +37 -37
- package/src/module/enterprise/entity/organization.entity.ts +80 -80
- package/src/module/listmaster/controller/list-master.controller.ts +14 -0
- package/src/module/listmaster/entity/list-master-items.entity.ts +33 -0
- package/src/module/listmaster/entity/list-master.entity.ts +35 -0
- package/src/module/listmaster/listmaster.module.ts +14 -0
- package/src/module/listmaster/repository/list-master-items.repository.ts +21 -0
- package/src/module/listmaster/repository/list-master.repository.ts +15 -0
- package/src/module/listmaster/service/list-master.service.ts +44 -0
- package/src/module/master/controller/master.controller.ts +26 -22
- package/src/module/master/service/master.service.ts +133 -9
- package/src/module/meta/dto/entity-list-data.dto.ts +6 -6
- package/src/module/meta/entity/attribute-master.entity.ts +67 -67
- package/src/module/meta/entity/entity-master.entity.ts +1 -1
- package/src/module/meta/entity/preference.entity.ts +65 -65
- package/src/module/meta/repository/attribute-master.repository.ts +28 -28
- package/src/module/meta/repository/entity-table.repository.ts +3 -1
- package/src/module/meta/repository/preference.repository.ts +20 -20
- package/src/module/meta/service/entity-master.service.ts +14 -0
- package/src/module/meta/service/entity-service-impl.service.ts +1 -1
- package/src/module/module/controller/menu.controller.ts +15 -15
- package/src/module/module/controller/module-access.controller.ts +16 -1
- package/src/module/module/entity/module-access.entity.ts +22 -22
- package/src/module/module/entity/module-action.entity.ts +19 -19
- package/src/module/module/repository/module-access.repository.ts +74 -6
- package/src/module/module/service/module-access.service.ts +10 -0
- package/src/module/user/controller/user.controller.ts +28 -28
- package/src/module/user/dto/update-user.dto.ts +4 -4
- package/src/module/user/entity/user-role-mapping.entity.ts +21 -21
- package/src/module/user/entity/user-session.entity.ts +61 -61
- package/src/module/user/entity/user.entity.ts +35 -35
- package/src/module/user/repository/role.repository.ts +16 -16
- package/src/module/user/repository/userSession.repository.ts +33 -33
- package/src/utils/service/encryptUtil.service.ts +97 -97
- package/src/utils/service/excelUtil.service.ts +15 -15
- package/src/utils/service/file-util.service.ts +11 -0
- package/src/utils/service/reflection-helper.service.ts +53 -53
- package/.idea/250218_nodejs_core.iml +0 -12
- package/.idea/codeStyles/Project.xml +0 -59
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/dataSources.xml +0 -12
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -6
- package/.idea/vcs.xml +0 -6
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
-
import { AttributeMaster } from '../entity/attribute-master.entity';
|
|
4
|
-
import { Repository } from 'typeorm';
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class AttributeMasterRepository {
|
|
8
|
-
constructor(
|
|
9
|
-
@InjectRepository(AttributeMaster)
|
|
10
|
-
private readonly attributeMasterRepository: Repository<AttributeMaster>,
|
|
11
|
-
) {}
|
|
12
|
-
|
|
13
|
-
async findByMappedEntityIdAndMappedEntityTypeAndAttributeKeyAndOrganizationId(
|
|
14
|
-
mappedEntityId: number,
|
|
15
|
-
mappedEntityType: string,
|
|
16
|
-
attributeKey: string,
|
|
17
|
-
organizationId: number,
|
|
18
|
-
): Promise<AttributeMaster | null> {
|
|
19
|
-
return await this.attributeMasterRepository.findOne({
|
|
20
|
-
where: {
|
|
21
|
-
mapped_entity_id: mappedEntityId,
|
|
22
|
-
mapped_entity_type: mappedEntityType,
|
|
23
|
-
attribute_key: attributeKey,
|
|
24
|
-
organization_id: organizationId,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
+
import { AttributeMaster } from '../entity/attribute-master.entity';
|
|
4
|
+
import { Repository } from 'typeorm';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class AttributeMasterRepository {
|
|
8
|
+
constructor(
|
|
9
|
+
@InjectRepository(AttributeMaster)
|
|
10
|
+
private readonly attributeMasterRepository: Repository<AttributeMaster>,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
async findByMappedEntityIdAndMappedEntityTypeAndAttributeKeyAndOrganizationId(
|
|
14
|
+
mappedEntityId: number,
|
|
15
|
+
mappedEntityType: string,
|
|
16
|
+
attributeKey: string,
|
|
17
|
+
organizationId: number,
|
|
18
|
+
): Promise<AttributeMaster | null> {
|
|
19
|
+
return await this.attributeMasterRepository.findOne({
|
|
20
|
+
where: {
|
|
21
|
+
mapped_entity_id: mappedEntityId,
|
|
22
|
+
mapped_entity_type: mappedEntityType,
|
|
23
|
+
attribute_key: attributeKey,
|
|
24
|
+
organization_id: organizationId,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -11,9 +11,11 @@ export class EntityTableRepository {
|
|
|
11
11
|
) {}
|
|
12
12
|
|
|
13
13
|
async findByEntityTypeAndListType(entityType: string, listType: string) {
|
|
14
|
-
|
|
14
|
+
const temp = await this.entityTableRepository.findOne({
|
|
15
15
|
where: { mapped_entity_type: entityType, list_type: listType },
|
|
16
16
|
});
|
|
17
|
+
console.log(temp)
|
|
18
|
+
return temp;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
async findByEntityTypeAndListTypeAndDisplayType(
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
-
import { PreferenceMaster } from '../entity/preference.entity';
|
|
4
|
-
import { Repository } from 'typeorm';
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class PreferenceRepository {
|
|
8
|
-
constructor(
|
|
9
|
-
@InjectRepository(PreferenceMaster)
|
|
10
|
-
private readonly preferenceRepository: Repository<PreferenceMaster>,
|
|
11
|
-
) {}
|
|
12
|
-
|
|
13
|
-
async findByPreferenceKey(
|
|
14
|
-
preferenceKey: string,
|
|
15
|
-
): Promise<PreferenceMaster | null> {
|
|
16
|
-
return await this.preferenceRepository.findOne({
|
|
17
|
-
where: { preference_key: preferenceKey },
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
+
import { PreferenceMaster } from '../entity/preference.entity';
|
|
4
|
+
import { Repository } from 'typeorm';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class PreferenceRepository {
|
|
8
|
+
constructor(
|
|
9
|
+
@InjectRepository(PreferenceMaster)
|
|
10
|
+
private readonly preferenceRepository: Repository<PreferenceMaster>,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
async findByPreferenceKey(
|
|
14
|
+
preferenceKey: string,
|
|
15
|
+
): Promise<PreferenceMaster | null> {
|
|
16
|
+
return await this.preferenceRepository.findOne({
|
|
17
|
+
where: { preference_key: preferenceKey },
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -23,4 +23,18 @@ export class EntityMasterService {
|
|
|
23
23
|
|
|
24
24
|
return entityMaster;
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
async save(entityMaster: EntityMaster) {
|
|
28
|
+
return await this.entityMasterRepository.save(entityMaster);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async update(id: number, entityMaster: EntityMaster) {
|
|
32
|
+
return await this.entityMasterRepository.update(id, entityMaster);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async findByMappedEntityType(mappedEntityType: string) {
|
|
36
|
+
return await this.entityMasterRepository.findOne({
|
|
37
|
+
where: { mapped_entity_type: mappedEntityType },
|
|
38
|
+
});
|
|
39
|
+
}
|
|
26
40
|
}
|
|
@@ -261,7 +261,7 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
261
261
|
} else {
|
|
262
262
|
let entityMaster =
|
|
263
263
|
await this.entityMasterService.getEntityData(entityType);
|
|
264
|
-
tableName = entityMaster.
|
|
264
|
+
tableName = entityMaster.db_table_name;
|
|
265
265
|
}
|
|
266
266
|
return await this.entityListService.getMaxSequenceNumber(
|
|
267
267
|
tableName,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Controller, Get, Request, UseGuards } from '@nestjs/common';
|
|
2
|
-
import { MenuService } from '../service/menu.service';
|
|
3
|
-
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
4
|
-
|
|
5
|
-
@Controller('menu')
|
|
6
|
-
export class MenuController {
|
|
7
|
-
constructor(private readonly menuService: MenuService) {}
|
|
8
|
-
|
|
9
|
-
@UseGuards(JwtAuthGuard)
|
|
10
|
-
@Get()
|
|
11
|
-
async getMenu(@Request() req) {
|
|
12
|
-
const userId = req.user.userId;
|
|
13
|
-
return this.menuService.getUserMenu(userId);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
import { Controller, Get, Request, UseGuards } from '@nestjs/common';
|
|
2
|
+
import { MenuService } from '../service/menu.service';
|
|
3
|
+
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
4
|
+
|
|
5
|
+
@Controller('menu')
|
|
6
|
+
export class MenuController {
|
|
7
|
+
constructor(private readonly menuService: MenuService) {}
|
|
8
|
+
|
|
9
|
+
@UseGuards(JwtAuthGuard)
|
|
10
|
+
@Get()
|
|
11
|
+
async getMenu(@Request() req) {
|
|
12
|
+
const userId = req.user.userId;
|
|
13
|
+
return this.menuService.getUserMenu(userId);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
|
1
|
+
import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
|
|
2
2
|
import { ModuleAccessService } from '../service/module-access.service';
|
|
3
|
+
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
3
4
|
|
|
4
5
|
@Controller('module-access')
|
|
6
|
+
@UseGuards(JwtAuthGuard)
|
|
5
7
|
export class ModuleAccessController {
|
|
6
8
|
constructor(private readonly moduleAccessService: ModuleAccessService) {}
|
|
7
9
|
|
|
10
|
+
|
|
8
11
|
@Get('roles')
|
|
9
12
|
async getRoles() {
|
|
10
13
|
return this.moduleAccessService.getRoles();
|
|
@@ -31,4 +34,16 @@ export class ModuleAccessController {
|
|
|
31
34
|
async updateModuleAccess(@Body() moduleAccessData: any[]) {
|
|
32
35
|
return this.moduleAccessService.updateModuleAccess(moduleAccessData);
|
|
33
36
|
}
|
|
37
|
+
|
|
38
|
+
@Post('create-role')
|
|
39
|
+
async createRole(@Body() body: {
|
|
40
|
+
name: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
status?: 'ACTIVE' | 'INACTIVE';
|
|
43
|
+
copyFromRoleId?: number;
|
|
44
|
+
}) {
|
|
45
|
+
return this.moduleAccessService.createRole(body);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
34
49
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
-
|
|
3
|
-
@Entity({ name: 'cr_module_access' })
|
|
4
|
-
export class ModuleAccess {
|
|
5
|
-
@PrimaryGeneratedColumn()
|
|
6
|
-
id: number;
|
|
7
|
-
|
|
8
|
-
@Column({type: 'varchar', length: 100, nullable: true})
|
|
9
|
-
module_code: string;
|
|
10
|
-
|
|
11
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
12
|
-
role_code: string;
|
|
13
|
-
|
|
14
|
-
@Column({type: 'int', nullable: true })
|
|
15
|
-
access_flag: number;
|
|
16
|
-
|
|
17
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
18
|
-
action_type: string;
|
|
19
|
-
|
|
20
|
-
@Column({type: 'varchar', length: 100, nullable: true})
|
|
21
|
-
app_code: string;
|
|
22
|
-
}
|
|
1
|
+
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
@Entity({ name: 'cr_module_access' })
|
|
4
|
+
export class ModuleAccess {
|
|
5
|
+
@PrimaryGeneratedColumn()
|
|
6
|
+
id: number;
|
|
7
|
+
|
|
8
|
+
@Column({type: 'varchar', length: 100, nullable: true})
|
|
9
|
+
module_code: string;
|
|
10
|
+
|
|
11
|
+
@Column({type: 'varchar', length: 100, nullable: true })
|
|
12
|
+
role_code: string;
|
|
13
|
+
|
|
14
|
+
@Column({type: 'int', nullable: true })
|
|
15
|
+
access_flag: number;
|
|
16
|
+
|
|
17
|
+
@Column({type: 'varchar', length: 100, nullable: true })
|
|
18
|
+
action_type: string;
|
|
19
|
+
|
|
20
|
+
@Column({type: 'varchar', length: 100, nullable: true})
|
|
21
|
+
app_code: string;
|
|
22
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
-
|
|
3
|
-
@Entity({ name: 'module_action' })
|
|
4
|
-
export class ModuleAction {
|
|
5
|
-
@PrimaryGeneratedColumn()
|
|
6
|
-
id: number;
|
|
7
|
-
|
|
8
|
-
@Column({type: 'int', nullable: true})
|
|
9
|
-
module_id: number;
|
|
10
|
-
|
|
11
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
12
|
-
module_code: string;
|
|
13
|
-
|
|
14
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
15
|
-
action_name:string
|
|
16
|
-
|
|
17
|
-
@Column({type: 'varchar', length: 50, nullable: true })
|
|
18
|
-
action_type: string;
|
|
19
|
-
}
|
|
1
|
+
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
@Entity({ name: 'module_action' })
|
|
4
|
+
export class ModuleAction {
|
|
5
|
+
@PrimaryGeneratedColumn()
|
|
6
|
+
id: number;
|
|
7
|
+
|
|
8
|
+
@Column({type: 'int', nullable: true})
|
|
9
|
+
module_id: number;
|
|
10
|
+
|
|
11
|
+
@Column({type: 'varchar', length: 100, nullable: true })
|
|
12
|
+
module_code: string;
|
|
13
|
+
|
|
14
|
+
@Column({type: 'varchar', length: 100, nullable: true })
|
|
15
|
+
action_name:string
|
|
16
|
+
|
|
17
|
+
@Column({type: 'varchar', length: 50, nullable: true })
|
|
18
|
+
action_type: string;
|
|
19
|
+
}
|
|
@@ -5,6 +5,7 @@ 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';
|
|
7
7
|
import { ModuleData } from '../entity/module.entity';
|
|
8
|
+
import { ClockIDGenService } from 'src/utils/service/clockIDGenUtil.service';
|
|
8
9
|
|
|
9
10
|
@Injectable()
|
|
10
11
|
export class ModuleAccessRepository {
|
|
@@ -17,15 +18,27 @@ export class ModuleAccessRepository {
|
|
|
17
18
|
private readonly moduleAccessRepo: Repository<ModuleAccess>,
|
|
18
19
|
@InjectRepository(ModuleAction)
|
|
19
20
|
private readonly moduleActionRepo: Repository<ModuleAction>,
|
|
21
|
+
private readonly clockIDGenService: ClockIDGenService,
|
|
22
|
+
|
|
20
23
|
) {}
|
|
21
24
|
|
|
22
25
|
async getRoles() {
|
|
23
|
-
|
|
26
|
+
const roles = await this.roleRepo.find();
|
|
27
|
+
return roles.map(role => ({
|
|
28
|
+
label: role.name,
|
|
29
|
+
value: role.id,
|
|
30
|
+
}));
|
|
24
31
|
}
|
|
32
|
+
|
|
25
33
|
|
|
26
34
|
async getModules() {
|
|
27
|
-
|
|
35
|
+
const modules = await this.moduleRepo.find({ where: { module_level: 'MAINMOD' } });
|
|
36
|
+
return modules.map(mod => ({
|
|
37
|
+
label: mod.name,
|
|
38
|
+
value: mod.id,
|
|
39
|
+
}));
|
|
28
40
|
}
|
|
41
|
+
|
|
29
42
|
|
|
30
43
|
async getAccessListing(roleIds: number[]) {
|
|
31
44
|
// Fetch roles using role IDs
|
|
@@ -81,10 +94,10 @@ export class ModuleAccessRepository {
|
|
|
81
94
|
// Function to recursively build module hierarchy
|
|
82
95
|
const buildHierarchy = (parentWbs: string) => {
|
|
83
96
|
return modules
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
.filter(mod => {
|
|
98
|
+
return mod.wbs_code.startsWith(parentWbs + '.') &&
|
|
99
|
+
mod.wbs_code.split('.').length === parentWbs.split('.').length + 1;
|
|
100
|
+
})
|
|
88
101
|
.map((mod) => ({
|
|
89
102
|
name: mod.name,
|
|
90
103
|
code: mod.module_code,
|
|
@@ -140,4 +153,59 @@ export class ModuleAccessRepository {
|
|
|
140
153
|
return false;
|
|
141
154
|
}
|
|
142
155
|
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
async createRole(body: {
|
|
159
|
+
name: string;
|
|
160
|
+
description?: string;
|
|
161
|
+
status?: 'ACTIVE' | 'INACTIVE';
|
|
162
|
+
copyFromRoleId?: number;
|
|
163
|
+
}) {
|
|
164
|
+
const { name, description, status, copyFromRoleId } = body;
|
|
165
|
+
|
|
166
|
+
const code = this.clockIDGenService.idGenerator('ROL');; // Replace with your custom clock ID generator
|
|
167
|
+
|
|
168
|
+
const newRole = this.roleRepo.create({
|
|
169
|
+
name,
|
|
170
|
+
code,
|
|
171
|
+
description,
|
|
172
|
+
status: status || 'ACTIVE',
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const savedRole = await this.roleRepo.save(newRole);
|
|
176
|
+
|
|
177
|
+
if (copyFromRoleId) {
|
|
178
|
+
const sourceRole = await this.roleRepo.findOne({ where: { id: copyFromRoleId } });
|
|
179
|
+
|
|
180
|
+
if (!sourceRole) {
|
|
181
|
+
throw new Error('Source role not found');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const sourcePermissions = await this.moduleAccessRepo.find({
|
|
185
|
+
where: { role_code: sourceRole.code },
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const clonedPermissions = sourcePermissions.map((perm) =>
|
|
189
|
+
this.moduleAccessRepo.create({
|
|
190
|
+
role_code: code,
|
|
191
|
+
module_code: perm.module_code,
|
|
192
|
+
action_type: perm.action_type,
|
|
193
|
+
access_flag: perm.access_flag,
|
|
194
|
+
app_code: perm.app_code,
|
|
195
|
+
})
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
await this.moduleAccessRepo.save(clonedPermissions);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
success: true,
|
|
203
|
+
msg: 'Role created successfully',
|
|
204
|
+
role: {
|
|
205
|
+
id: savedRole.id,
|
|
206
|
+
name: savedRole.name,
|
|
207
|
+
code: savedRole.code,
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
143
211
|
}
|
|
@@ -39,4 +39,14 @@ export class ModuleAccessService {
|
|
|
39
39
|
return { success: false, msg: 'Failed to update module access' };
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
async createRole(body: {
|
|
44
|
+
name: string;
|
|
45
|
+
description?: string;
|
|
46
|
+
status?: 'ACTIVE' | 'INACTIVE';
|
|
47
|
+
copyFromRoleId?: number;
|
|
48
|
+
}) {
|
|
49
|
+
return this.moduleAccessRepository.createRole(body);
|
|
50
|
+
}
|
|
51
|
+
|
|
42
52
|
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Body,
|
|
3
|
-
Controller,
|
|
4
|
-
HttpStatus,
|
|
5
|
-
Inject,
|
|
6
|
-
Post,
|
|
7
|
-
Res,
|
|
8
|
-
ValidationPipe,
|
|
9
|
-
} from '@nestjs/common';
|
|
10
|
-
import { UserService } from '../service/user.service';
|
|
11
|
-
import { CreateUserDto } from '../dto/create-user.dto';
|
|
12
|
-
import { Response } from 'express';
|
|
13
|
-
|
|
14
|
-
@Controller('user')
|
|
15
|
-
export class UserController {
|
|
16
|
-
constructor(
|
|
17
|
-
@Inject('UserService') private readonly userService: UserService,
|
|
18
|
-
) {}
|
|
19
|
-
|
|
20
|
-
@Post('signup')
|
|
21
|
-
async signup(
|
|
22
|
-
@Body(new ValidationPipe()) createUserDto: CreateUserDto,
|
|
23
|
-
@Res() res: Response,
|
|
24
|
-
) {
|
|
25
|
-
const result = await this.userService.createEntity(createUserDto, null);
|
|
26
|
-
res.status(HttpStatus.OK).json(result);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
Controller,
|
|
4
|
+
HttpStatus,
|
|
5
|
+
Inject,
|
|
6
|
+
Post,
|
|
7
|
+
Res,
|
|
8
|
+
ValidationPipe,
|
|
9
|
+
} from '@nestjs/common';
|
|
10
|
+
import { UserService } from '../service/user.service';
|
|
11
|
+
import { CreateUserDto } from '../dto/create-user.dto';
|
|
12
|
+
import { Response } from 'express';
|
|
13
|
+
|
|
14
|
+
@Controller('user')
|
|
15
|
+
export class UserController {
|
|
16
|
+
constructor(
|
|
17
|
+
@Inject('UserService') private readonly userService: UserService,
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
@Post('signup')
|
|
21
|
+
async signup(
|
|
22
|
+
@Body(new ValidationPipe()) createUserDto: CreateUserDto,
|
|
23
|
+
@Res() res: Response,
|
|
24
|
+
) {
|
|
25
|
+
const result = await this.userService.createEntity(createUserDto, null);
|
|
26
|
+
res.status(HttpStatus.OK).json(result);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PartialType } from '@nestjs/mapped-types';
|
|
2
|
-
import { CreateUserDto } from './create-user.dto';
|
|
3
|
-
|
|
4
|
-
export class UpdateUserDto extends PartialType(CreateUserDto) {}
|
|
1
|
+
import { PartialType } from '@nestjs/mapped-types';
|
|
2
|
+
import { CreateUserDto } from './create-user.dto';
|
|
3
|
+
|
|
4
|
+
export class UpdateUserDto extends PartialType(CreateUserDto) {}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
-
|
|
3
|
-
@Entity({ name: 'cr_user_role_mapping' })
|
|
4
|
-
export class UserRoleMapping {
|
|
5
|
-
constructor(user_id: number, role_id: number) {
|
|
6
|
-
this.user_id = user_id;
|
|
7
|
-
this.role_id = role_id;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
@PrimaryGeneratedColumn()
|
|
11
|
-
id: number;
|
|
12
|
-
|
|
13
|
-
@Column({ type: 'bigint', nullable: true })
|
|
14
|
-
user_id: number;
|
|
15
|
-
|
|
16
|
-
@Column({ type: 'bigint', nullable: true })
|
|
17
|
-
role_id: number;
|
|
18
|
-
|
|
19
|
-
@Column({ type: 'int', nullable: true })
|
|
20
|
-
is_default: number;
|
|
21
|
-
}
|
|
1
|
+
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
@Entity({ name: 'cr_user_role_mapping' })
|
|
4
|
+
export class UserRoleMapping {
|
|
5
|
+
constructor(user_id: number, role_id: number) {
|
|
6
|
+
this.user_id = user_id;
|
|
7
|
+
this.role_id = role_id;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@PrimaryGeneratedColumn()
|
|
11
|
+
id: number;
|
|
12
|
+
|
|
13
|
+
@Column({ type: 'bigint', nullable: true })
|
|
14
|
+
user_id: number;
|
|
15
|
+
|
|
16
|
+
@Column({ type: 'bigint', nullable: true })
|
|
17
|
+
role_id: number;
|
|
18
|
+
|
|
19
|
+
@Column({ type: 'int', nullable: true })
|
|
20
|
+
is_default: number;
|
|
21
|
+
}
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
-
|
|
3
|
-
@Entity({ name: 'cr_user_session' })
|
|
4
|
-
export class UserSession {
|
|
5
|
-
@PrimaryGeneratedColumn()
|
|
6
|
-
id: number;
|
|
7
|
-
|
|
8
|
-
@Column({
|
|
9
|
-
name: 'is_session_loggedout',
|
|
10
|
-
nullable: true,
|
|
11
|
-
type: 'int',
|
|
12
|
-
})
|
|
13
|
-
is_session_loggedout: number;
|
|
14
|
-
|
|
15
|
-
@Column({
|
|
16
|
-
name: 'login_id',
|
|
17
|
-
nullable: true,
|
|
18
|
-
length: 50,
|
|
19
|
-
})
|
|
20
|
-
login_id: string;
|
|
21
|
-
|
|
22
|
-
@Column({
|
|
23
|
-
name: 'login_time',
|
|
24
|
-
nullable: true,
|
|
25
|
-
})
|
|
26
|
-
login_time: Date;
|
|
27
|
-
|
|
28
|
-
@Column({
|
|
29
|
-
name: 'logout_time',
|
|
30
|
-
nullable: true,
|
|
31
|
-
})
|
|
32
|
-
logout_time: Date;
|
|
33
|
-
|
|
34
|
-
@Column({
|
|
35
|
-
name: 'session_key',
|
|
36
|
-
nullable: true,
|
|
37
|
-
length: 100,
|
|
38
|
-
})
|
|
39
|
-
session_key: string;
|
|
40
|
-
|
|
41
|
-
@Column({
|
|
42
|
-
name: 'user_id',
|
|
43
|
-
nullable: true,
|
|
44
|
-
type: 'bigint',
|
|
45
|
-
})
|
|
46
|
-
user_id: number;
|
|
47
|
-
|
|
48
|
-
@Column({
|
|
49
|
-
name: 'access_token',
|
|
50
|
-
nullable: true,
|
|
51
|
-
type: 'varchar',
|
|
52
|
-
length: 5000,
|
|
53
|
-
})
|
|
54
|
-
access_token: string;
|
|
55
|
-
|
|
56
|
-
@Column({
|
|
57
|
-
name: 'expiry_date',
|
|
58
|
-
nullable: true,
|
|
59
|
-
})
|
|
60
|
-
expiry_date: Date;
|
|
61
|
-
}
|
|
1
|
+
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
@Entity({ name: 'cr_user_session' })
|
|
4
|
+
export class UserSession {
|
|
5
|
+
@PrimaryGeneratedColumn()
|
|
6
|
+
id: number;
|
|
7
|
+
|
|
8
|
+
@Column({
|
|
9
|
+
name: 'is_session_loggedout',
|
|
10
|
+
nullable: true,
|
|
11
|
+
type: 'int',
|
|
12
|
+
})
|
|
13
|
+
is_session_loggedout: number;
|
|
14
|
+
|
|
15
|
+
@Column({
|
|
16
|
+
name: 'login_id',
|
|
17
|
+
nullable: true,
|
|
18
|
+
length: 50,
|
|
19
|
+
})
|
|
20
|
+
login_id: string;
|
|
21
|
+
|
|
22
|
+
@Column({
|
|
23
|
+
name: 'login_time',
|
|
24
|
+
nullable: true,
|
|
25
|
+
})
|
|
26
|
+
login_time: Date;
|
|
27
|
+
|
|
28
|
+
@Column({
|
|
29
|
+
name: 'logout_time',
|
|
30
|
+
nullable: true,
|
|
31
|
+
})
|
|
32
|
+
logout_time: Date;
|
|
33
|
+
|
|
34
|
+
@Column({
|
|
35
|
+
name: 'session_key',
|
|
36
|
+
nullable: true,
|
|
37
|
+
length: 100,
|
|
38
|
+
})
|
|
39
|
+
session_key: string;
|
|
40
|
+
|
|
41
|
+
@Column({
|
|
42
|
+
name: 'user_id',
|
|
43
|
+
nullable: true,
|
|
44
|
+
type: 'bigint',
|
|
45
|
+
})
|
|
46
|
+
user_id: number;
|
|
47
|
+
|
|
48
|
+
@Column({
|
|
49
|
+
name: 'access_token',
|
|
50
|
+
nullable: true,
|
|
51
|
+
type: 'varchar',
|
|
52
|
+
length: 5000,
|
|
53
|
+
})
|
|
54
|
+
access_token: string;
|
|
55
|
+
|
|
56
|
+
@Column({
|
|
57
|
+
name: 'expiry_date',
|
|
58
|
+
nullable: true,
|
|
59
|
+
})
|
|
60
|
+
expiry_date: Date;
|
|
61
|
+
}
|