rez_core 0.0.1 → 0.0.2
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/data/master.xlsx +0 -0
- package/dist/config/database.config.js +2 -2
- package/dist/config/database.config.js.map +1 -1
- package/dist/constant/global.constant.d.ts +1 -1
- package/dist/constant/global.constant.js +1 -1
- package/dist/module/enterprise/service/organization.service.d.ts +11 -0
- package/dist/module/enterprise/service/organization.service.js +48 -0
- package/dist/module/enterprise/service/organization.service.js.map +1 -0
- package/dist/module/meta/controller/entity.controller.d.ts +1 -0
- package/dist/module/meta/controller/entity.controller.js +20 -1
- package/dist/module/meta/controller/entity.controller.js.map +1 -1
- package/dist/module/meta/entity/entity-master.entity.js +1 -2
- package/dist/module/meta/entity/entity-master.entity.js.map +1 -1
- package/dist/module/meta/entity/entity-table-column.entity.d.ts +15 -0
- package/dist/module/meta/entity/entity-table-column.entity.js +70 -0
- package/dist/module/meta/entity/entity-table-column.entity.js.map +1 -1
- package/dist/module/meta/entity/entity-table.entity.d.ts +17 -0
- package/dist/module/meta/entity/entity-table.entity.js +78 -0
- package/dist/module/meta/entity/entity-table.entity.js.map +1 -1
- package/dist/module/meta/entity.module.js +20 -2
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.d.ts +6 -2
- package/dist/module/meta/service/entity-service-impl.service.js +7 -1
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/meta/service/entity.service.d.ts +2 -0
- package/dist/module/meta/service/preference.service.d.ts +2 -1
- package/dist/module/meta/service/preference.service.js +4 -2
- package/dist/module/meta/service/preference.service.js.map +1 -1
- package/dist/module/module/controller/module-access.controller.d.ts +20 -4
- package/dist/module/module/controller/module-access.controller.js +40 -11
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/entity/module.entity.d.ts +1 -0
- package/dist/module/module/entity/module.entity.js +4 -0
- package/dist/module/module/entity/module.entity.js.map +1 -1
- package/dist/module/module/repository/module-access.repository.d.ts +25 -7
- package/dist/module/module/repository/module-access.repository.js +64 -21
- package/dist/module/module/repository/module-access.repository.js.map +1 -1
- package/dist/module/module/service/module-access.service.d.ts +20 -4
- package/dist/module/module/service/module-access.service.js +12 -3
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/user/entity/role.entity.js +1 -1
- package/dist/module/user/entity/role.entity.js.map +1 -1
- package/dist/module/user/service/role.service.d.ts +2 -1
- package/dist/module/user/service/role.service.js +4 -2
- package/dist/module/user/service/role.service.js.map +1 -1
- package/dist/module/user/service/user-session.service.d.ts +3 -1
- package/dist/module/user/service/user-session.service.js +5 -3
- package/dist/module/user/service/user-session.service.js.map +1 -1
- package/dist/module/user/service/user.service.d.ts +4 -1
- package/dist/module/user/service/user.service.js +11 -5
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/module/user/user.module.js +2 -2
- package/dist/module/user/user.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/service/clockIDGenUtil.service.d.ts +6 -6
- package/dist/utils/service/clockIDGenUtil.service.js +11 -10
- package/dist/utils/service/clockIDGenUtil.service.js.map +1 -1
- package/dist/utils/utils.module.js +3 -4
- package/dist/utils/utils.module.js.map +1 -1
- package/package.json +1 -1
- package/src/config/database.config.ts +2 -2
- package/src/constant/global.constant.ts +1 -1
- package/src/module/enterprise/service/organization.service.ts +34 -0
- package/src/module/meta/controller/entity.controller.ts +24 -5
- package/src/module/meta/dto/entity-list-data.dto.ts +6 -0
- package/src/module/meta/dto/entity-tab.dto.ts +4 -0
- package/src/module/meta/entity/entity-master.entity.ts +1 -2
- package/src/module/meta/entity/entity-table-column.entity.ts +44 -0
- package/src/module/meta/entity/entity-table.entity.ts +51 -0
- package/src/module/meta/entity.module.ts +20 -2
- package/src/module/meta/repository/entity-table-column.repository.ts +21 -0
- package/src/module/meta/repository/entity-table.repository.ts +18 -0
- package/src/module/meta/service/entity-list.service.ts +138 -0
- package/src/module/meta/service/entity-service-impl.service.ts +25 -2
- package/src/module/meta/service/entity-table-column.service.ts +18 -0
- package/src/module/meta/service/entity-table.service.ts +11 -0
- package/src/module/meta/service/entity.service.ts +11 -0
- package/src/module/meta/service/preference.service.ts +8 -1
- package/src/module/module/controller/module-access.controller.ts +23 -9
- package/src/module/module/entity/module.entity.ts +3 -0
- package/src/module/module/repository/module-access.repository.ts +86 -24
- package/src/module/module/service/module-access.service.ts +16 -4
- package/src/module/user/entity/role.entity.ts +1 -1
- package/src/module/user/service/role.service.ts +3 -1
- package/src/module/user/service/user-session.service.ts +2 -1
- package/src/module/user/service/user.service.ts +16 -7
- package/src/module/user/user.module.ts +3 -2
- package/src/utils/service/clockIDGenUtil.service.ts +10 -12
- package/src/utils/utils.module.ts +7 -9
|
@@ -4,6 +4,7 @@ import { PreferenceRepository } from '../repository/preference.repository';
|
|
|
4
4
|
import { EntityMasterService } from './entity-master.service';
|
|
5
5
|
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
6
6
|
import { LoggingService } from '../../../utils/service/loggingUtil.service';
|
|
7
|
+
import { EntityListService } from './entity-list.service';
|
|
7
8
|
|
|
8
9
|
@Injectable()
|
|
9
10
|
export class PreferenceService extends EntityServiceImpl {
|
|
@@ -11,9 +12,15 @@ export class PreferenceService extends EntityServiceImpl {
|
|
|
11
12
|
entityMasterService: EntityMasterService,
|
|
12
13
|
reflectionHelper: ReflectionHelper,
|
|
13
14
|
loggingService: LoggingService,
|
|
15
|
+
entityListService: EntityListService,
|
|
14
16
|
private readonly preferenceRepository: PreferenceRepository,
|
|
15
17
|
) {
|
|
16
|
-
super(
|
|
18
|
+
super(
|
|
19
|
+
entityMasterService,
|
|
20
|
+
reflectionHelper,
|
|
21
|
+
entityListService,
|
|
22
|
+
loggingService,
|
|
23
|
+
);
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
async getPreferenceValue(preferenceKey: string): Promise<string | undefined> {
|
|
@@ -1,20 +1,34 @@
|
|
|
1
|
-
import { Controller,
|
|
1
|
+
import { Controller, Get, Post, Body, Query } from '@nestjs/common';
|
|
2
2
|
import { ModuleAccessService } from '../service/module-access.service';
|
|
3
3
|
|
|
4
4
|
@Controller('module-access')
|
|
5
5
|
export class ModuleAccessController {
|
|
6
6
|
constructor(private readonly moduleAccessService: ModuleAccessService) {}
|
|
7
7
|
|
|
8
|
+
@Get('roles')
|
|
9
|
+
async getRoles() {
|
|
10
|
+
return this.moduleAccessService.getRoles();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Get('modules')
|
|
14
|
+
async getModules() {
|
|
15
|
+
return this.moduleAccessService.getModules();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Get('access-listing')
|
|
19
|
+
async getAccessListing(@Query('roles') roleIds: string) {
|
|
20
|
+
const roleIdArray = roleIds.split(',').map(Number);
|
|
21
|
+
return this.moduleAccessService.getAccessListing(roleIdArray);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Get('menu-listing')
|
|
25
|
+
async getMenuListing(@Query('mainmod') mainModIds: string) {
|
|
26
|
+
const mainModArray = mainModIds.split(',').map(String);
|
|
27
|
+
return this.moduleAccessService.getMenuListing(mainModArray);
|
|
28
|
+
}
|
|
29
|
+
|
|
8
30
|
@Post('update')
|
|
9
31
|
async updateModuleAccess(@Body() moduleAccessData: any[]) {
|
|
10
32
|
return this.moduleAccessService.updateModuleAccess(moduleAccessData);
|
|
11
33
|
}
|
|
12
|
-
|
|
13
|
-
@Get('list')
|
|
14
|
-
async getModuleAccess(
|
|
15
|
-
@Query('role_code') roleCode?: string,
|
|
16
|
-
@Query('mainmod') mainMod?: string
|
|
17
|
-
) {
|
|
18
|
-
return this.moduleAccessService.getModuleAccess(roleCode, mainMod);
|
|
19
|
-
}
|
|
20
34
|
}
|
|
@@ -12,6 +12,9 @@ export class ModuleData {
|
|
|
12
12
|
@Column({type: 'varchar', length: 100, nullable: true })
|
|
13
13
|
module_code: string;
|
|
14
14
|
|
|
15
|
+
@Column({type: 'varchar', length: 100, nullable: true })
|
|
16
|
+
wbs_code: string;
|
|
17
|
+
|
|
15
18
|
@Column({type: 'varchar', length: 100, nullable: true })
|
|
16
19
|
status: StatusType;
|
|
17
20
|
|
|
@@ -1,21 +1,102 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
3
|
import { Repository, In } from 'typeorm';
|
|
4
|
+
import { Role } from 'src/module/user/entity/role.entity';
|
|
4
5
|
import { ModuleAccess } from '../entity/module-access.entity';
|
|
6
|
+
import { ModuleAction } from '../entity/module-action.entity';
|
|
5
7
|
import { ModuleData } from '../entity/module.entity';
|
|
6
|
-
import { Role } from 'src/module/user/entity/role.entity';
|
|
7
8
|
|
|
8
9
|
@Injectable()
|
|
9
10
|
export class ModuleAccessRepository {
|
|
10
11
|
constructor(
|
|
11
|
-
@InjectRepository(ModuleAccess)
|
|
12
|
-
private readonly moduleAccessRepo: Repository<ModuleAccess>,
|
|
13
12
|
@InjectRepository(Role)
|
|
14
13
|
private readonly roleRepo: Repository<Role>,
|
|
15
14
|
@InjectRepository(ModuleData)
|
|
16
|
-
private readonly moduleRepo: Repository<ModuleData
|
|
15
|
+
private readonly moduleRepo: Repository<ModuleData>,
|
|
16
|
+
@InjectRepository(ModuleAccess)
|
|
17
|
+
private readonly moduleAccessRepo: Repository<ModuleAccess>,
|
|
18
|
+
@InjectRepository(ModuleAction)
|
|
19
|
+
private readonly moduleActionRepo: Repository<ModuleAction>
|
|
17
20
|
) {}
|
|
18
21
|
|
|
22
|
+
async getRoles() {
|
|
23
|
+
return this.roleRepo.find();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async getModules() {
|
|
27
|
+
return this.moduleRepo.find({ where: { module_level: 'MAINMOD' }});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async getAccessListing(roleIds: number[]) {
|
|
31
|
+
// Fetch roles using role IDs
|
|
32
|
+
const roles = await this.roleRepo.find({ where: { id: In(roleIds) } });
|
|
33
|
+
|
|
34
|
+
// Extract role codes from roles
|
|
35
|
+
const roleCodes = roles.map(role => role.code);
|
|
36
|
+
|
|
37
|
+
// Fetch module access using role codes
|
|
38
|
+
const moduleAccesses = await this.moduleAccessRepo.find({ where: { role_code: In(roleCodes) } });
|
|
39
|
+
|
|
40
|
+
// Map role data to include access permissions
|
|
41
|
+
return roles.map(role => ({
|
|
42
|
+
role_code: role.code,
|
|
43
|
+
name: role.name,
|
|
44
|
+
permission: moduleAccesses
|
|
45
|
+
.filter(access => access.role_code === role.code)
|
|
46
|
+
.map(access => ({
|
|
47
|
+
action: access.action_type,
|
|
48
|
+
access: access.access_flag,
|
|
49
|
+
code: access.module_code
|
|
50
|
+
}))
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async getMenuListing(mainModIds: string[]) {
|
|
55
|
+
// Get MAINMOD modules using their IDs
|
|
56
|
+
const mainModules = await this.moduleRepo.find({
|
|
57
|
+
where: { id: In(mainModIds), module_level: 'MAINMOD' }
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (!mainModules.length) return [];
|
|
61
|
+
|
|
62
|
+
// Extract WBS codes of the MAINMOD modules
|
|
63
|
+
const wbsCodes = mainModules.map(mod => mod.wbs_code);
|
|
64
|
+
|
|
65
|
+
// Fetch all related modules using `LIKE` for WBS structure
|
|
66
|
+
const modules = await this.moduleRepo.createQueryBuilder("module")
|
|
67
|
+
.where(
|
|
68
|
+
wbsCodes.map(code => `module.wbs_code LIKE :code${code}`).join(" OR "),
|
|
69
|
+
Object.fromEntries(wbsCodes.map(code => [`code${code}`, `${code}%`]))
|
|
70
|
+
)
|
|
71
|
+
.getMany();
|
|
72
|
+
|
|
73
|
+
// Fetch module actions
|
|
74
|
+
const moduleActions = await this.moduleActionRepo.find();
|
|
75
|
+
|
|
76
|
+
// Function to recursively build module hierarchy
|
|
77
|
+
const buildHierarchy = (parentWbs: string) => {
|
|
78
|
+
return modules
|
|
79
|
+
.filter(mod => mod.wbs_code.startsWith(parentWbs) && mod.wbs_code !== parentWbs)
|
|
80
|
+
.map(mod => ({
|
|
81
|
+
name: mod.name,
|
|
82
|
+
code: mod.module_code,
|
|
83
|
+
permission: moduleActions
|
|
84
|
+
.filter(action => action.module_code === mod.module_code)
|
|
85
|
+
.map(action => ({ action: action.action_type, name: action.action_type })),
|
|
86
|
+
submod: buildHierarchy(mod.wbs_code)
|
|
87
|
+
}));
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Construct the final hierarchical response
|
|
91
|
+
return mainModules.map(mod => ({
|
|
92
|
+
name: mod.name,
|
|
93
|
+
code: mod.module_code,
|
|
94
|
+
permission: moduleActions
|
|
95
|
+
.filter(action => action.module_code === mod.module_code)
|
|
96
|
+
.map(action => ({ action: action.action_type, name: action.action_type })),
|
|
97
|
+
submod: buildHierarchy(mod.wbs_code)
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
19
100
|
async updateModuleAccess(moduleAccessData: any[]): Promise<boolean> {
|
|
20
101
|
try {
|
|
21
102
|
for (const access of moduleAccessData) {
|
|
@@ -44,23 +125,4 @@ export class ModuleAccessRepository {
|
|
|
44
125
|
return false;
|
|
45
126
|
}
|
|
46
127
|
}
|
|
47
|
-
|
|
48
|
-
async getModuleAccess(roleCode?: string, moduleCode?: string) {
|
|
49
|
-
const roles = await this.roleRepo.find({ take: 5 }); // Fetch top 5 roles
|
|
50
|
-
const modules = await this.moduleRepo.find(); // Fetch all modules
|
|
51
|
-
|
|
52
|
-
let filteredRoles = roles;
|
|
53
|
-
if (roleCode) {
|
|
54
|
-
const roleCodes = roleCode.split(',');
|
|
55
|
-
filteredRoles = filteredRoles.filter((role) => roleCodes.includes(role.code)); // Use correct property
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
let filteredModules = modules;
|
|
59
|
-
if (moduleCode) {
|
|
60
|
-
const moduleCodes = moduleCode.split(',');
|
|
61
|
-
filteredModules = filteredModules.filter((module) => moduleCodes.includes(module.module_code)); // Use correct property
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return { roles: filteredRoles, modules: filteredModules };
|
|
65
|
-
}
|
|
66
|
-
}
|
|
128
|
+
}
|
|
@@ -5,6 +5,22 @@ import { ModuleAccessRepository } from '../repository/module-access.repository';
|
|
|
5
5
|
export class ModuleAccessService {
|
|
6
6
|
constructor(private readonly moduleAccessRepository: ModuleAccessRepository) {}
|
|
7
7
|
|
|
8
|
+
async getRoles() {
|
|
9
|
+
return this.moduleAccessRepository.getRoles();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async getModules() {
|
|
13
|
+
return this.moduleAccessRepository.getModules();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async getAccessListing(roleIds: number[]) {
|
|
17
|
+
return this.moduleAccessRepository.getAccessListing(roleIds);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async getMenuListing(mainModIds: string[]) {
|
|
21
|
+
return this.moduleAccessRepository.getMenuListing(mainModIds);
|
|
22
|
+
}
|
|
23
|
+
|
|
8
24
|
async updateModuleAccess(moduleAccessData: any[]): Promise<{ success: boolean; msg: string }> {
|
|
9
25
|
if (!moduleAccessData || moduleAccessData.length === 0) {
|
|
10
26
|
return { success: false, msg: 'No data provided' };
|
|
@@ -18,8 +34,4 @@ export class ModuleAccessService {
|
|
|
18
34
|
return { success: false, msg: 'Failed to update module access' };
|
|
19
35
|
}
|
|
20
36
|
}
|
|
21
|
-
|
|
22
|
-
async getModuleAccess(roleCode?: string, mainMod?: string) {
|
|
23
|
-
return this.moduleAccessRepository.getModuleAccess(roleCode, mainMod);
|
|
24
|
-
}
|
|
25
37
|
}
|
|
@@ -6,15 +6,17 @@ import { LoggingService } from '../../../utils/service/loggingUtil.service';
|
|
|
6
6
|
import { BaseEntity } from '../../meta/entity/base-entity.entity';
|
|
7
7
|
import { UserData } from '../entity/user.entity';
|
|
8
8
|
import { Role } from '../entity/role.entity';
|
|
9
|
+
import {EntityListService} from "../../meta/service/entity-list.service";
|
|
9
10
|
|
|
10
11
|
@Injectable()
|
|
11
12
|
export class RoleService extends EntityServiceImpl {
|
|
12
13
|
constructor(
|
|
13
14
|
entityMasterService: EntityMasterService,
|
|
14
15
|
reflectionHelper: ReflectionHelper,
|
|
16
|
+
entityListService: EntityListService,
|
|
15
17
|
loggingService: LoggingService,
|
|
16
18
|
) {
|
|
17
|
-
super(entityMasterService, reflectionHelper, loggingService);
|
|
19
|
+
super(entityMasterService, reflectionHelper,entityListService, loggingService);
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
async createEntity(
|
|
@@ -9,9 +9,10 @@ export class UserSessionService {
|
|
|
9
9
|
constructor(
|
|
10
10
|
private readonly userSessionRepository: UserSessionRepository,
|
|
11
11
|
private readonly jwtAuthService: JwtAuthService,
|
|
12
|
+
private readonly clockIDGenService: ClockIDGenService
|
|
12
13
|
) {}
|
|
13
14
|
async createSession(user) {
|
|
14
|
-
const sessionToken =
|
|
15
|
+
const sessionToken = this.clockIDGenService.idGenerator('SES');
|
|
15
16
|
|
|
16
17
|
const userSession: any = new UserSession();
|
|
17
18
|
userSession.user_id = user.id;
|
|
@@ -6,7 +6,6 @@ import { LoggingService } from '../../../utils/service/loggingUtil.service';
|
|
|
6
6
|
import { UserData } from '../entity/user.entity';
|
|
7
7
|
import { BaseEntity } from '../../meta/entity/base-entity.entity';
|
|
8
8
|
import { UserRepository } from '../repository/user.repository';
|
|
9
|
-
import { StatusType } from '../../../constant/status.constant';
|
|
10
9
|
import { EncryptUtilService } from '../../../utils/service/encryptUtil.service';
|
|
11
10
|
import { ClockIDGenService } from '../../../utils/service/clockIDGenUtil.service';
|
|
12
11
|
import {
|
|
@@ -17,18 +16,26 @@ import {
|
|
|
17
16
|
import { CreateUserDto } from '../dto/create-user.dto';
|
|
18
17
|
import { UserRoleMappingService } from './user-role-mapping.service';
|
|
19
18
|
import { UserRoleMapping } from '../entity/user-role-mapping.entity';
|
|
20
|
-
import {plainToInstance} from
|
|
19
|
+
import { plainToInstance } from 'class-transformer';
|
|
20
|
+
import { EntityListService } from '../../meta/service/entity-list.service';
|
|
21
21
|
|
|
22
22
|
@Injectable()
|
|
23
23
|
export class UserService extends EntityServiceImpl {
|
|
24
24
|
constructor(
|
|
25
25
|
entityMasterService: EntityMasterService,
|
|
26
26
|
reflectionHelper: ReflectionHelper,
|
|
27
|
+
entityListService: EntityListService,
|
|
27
28
|
loggingService: LoggingService,
|
|
28
29
|
private userRepository: UserRepository,
|
|
29
30
|
private userRoleMappingService: UserRoleMappingService,
|
|
31
|
+
private readonly clockIDGenService: ClockIDGenService
|
|
30
32
|
) {
|
|
31
|
-
super(
|
|
33
|
+
super(
|
|
34
|
+
entityMasterService,
|
|
35
|
+
reflectionHelper,
|
|
36
|
+
entityListService,
|
|
37
|
+
loggingService,
|
|
38
|
+
);
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
async createEntity(
|
|
@@ -58,7 +65,7 @@ export class UserService extends EntityServiceImpl {
|
|
|
58
65
|
);
|
|
59
66
|
} else {
|
|
60
67
|
password = EncryptUtilService.encryptGCM(
|
|
61
|
-
|
|
68
|
+
this.clockIDGenService.idGenerator(''),
|
|
62
69
|
masterKey,
|
|
63
70
|
masterIv,
|
|
64
71
|
);
|
|
@@ -120,14 +127,16 @@ export class UserService extends EntityServiceImpl {
|
|
|
120
127
|
userDto.password = password;
|
|
121
128
|
}
|
|
122
129
|
|
|
123
|
-
let userData = plainToInstance(UserData, userDto, {
|
|
130
|
+
let userData = plainToInstance(UserData, userDto, {
|
|
131
|
+
excludeExtraneousValues: true,
|
|
132
|
+
});
|
|
124
133
|
let savedData = await super.updateEntity(userData, loggedInUserData);
|
|
125
134
|
if (userDto.roles) {
|
|
126
135
|
let roles = userDto.roles;
|
|
127
136
|
for (const role in roles) {
|
|
128
137
|
let userRoleMapping = new UserRoleMapping(
|
|
129
|
-
|
|
130
|
-
|
|
138
|
+
savedData.id,
|
|
139
|
+
Number(roles[role]),
|
|
131
140
|
);
|
|
132
141
|
await this.userRoleMappingService.assignUserRole(userRoleMapping);
|
|
133
142
|
}
|
|
@@ -19,6 +19,7 @@ import { UserRoleMapping } from './entity/user-role-mapping.entity';
|
|
|
19
19
|
import { UserRoleMappingRepository } from './repository/user-role-mapping.repository';
|
|
20
20
|
import { UserRoleMappingService } from './service/user-role-mapping.service';
|
|
21
21
|
import { RoleRepository } from './repository/role.repository';
|
|
22
|
+
import { EntityListService } from '../meta/service/entity-list.service';
|
|
22
23
|
|
|
23
24
|
@Module({
|
|
24
25
|
imports: [
|
|
@@ -37,14 +38,14 @@ import { RoleRepository } from './repository/role.repository';
|
|
|
37
38
|
JwtService,
|
|
38
39
|
UserRoleMappingRepository,
|
|
39
40
|
UserRoleMappingService,
|
|
40
|
-
RoleRepository
|
|
41
|
+
RoleRepository,
|
|
41
42
|
],
|
|
42
43
|
exports: [
|
|
43
44
|
'UserService',
|
|
44
45
|
UserSessionService,
|
|
45
46
|
'RoleService',
|
|
46
47
|
UserRoleMappingService,
|
|
47
|
-
RoleRepository
|
|
48
|
+
RoleRepository,
|
|
48
49
|
],
|
|
49
50
|
controllers: [LoginController, UserController],
|
|
50
51
|
})
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { Injectable } from "@nestjs/common";
|
|
2
2
|
|
|
3
3
|
@Injectable()
|
|
4
|
-
export class ClockIDGenService{
|
|
4
|
+
export class ClockIDGenService {
|
|
5
|
+
private _counter = 0n;
|
|
6
|
+
private timestampBits = 42;
|
|
7
|
+
private timestampMask = BigInt(Math.floor(Math.pow(2, this.timestampBits)) - 1);
|
|
8
|
+
private counterBits = 10;
|
|
9
|
+
private counterMask = BigInt(Math.floor(Math.pow(2, this.counterBits)) - 1);
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
static timestampBits = 42;
|
|
8
|
-
static timestampMask = BigInt(Math.floor(Math.pow(2, ClockIDGenService.timestampBits)) - 1);
|
|
9
|
-
static counterBits = 10;
|
|
10
|
-
static counterMask = BigInt(Math.floor(Math.pow(2, ClockIDGenService.counterBits)) - 1);
|
|
11
|
-
|
|
12
|
-
static idGenerator(prefix?: string) {
|
|
11
|
+
idGenerator(prefix?: string): string {
|
|
13
12
|
const timestamp = BigInt(Date.now()) & this.timestampMask;
|
|
14
13
|
const counter = BigInt(this._counter++) & this.counterMask;
|
|
15
|
-
let now = timestamp << BigInt(this.counterBits)
|
|
14
|
+
let now = timestamp << BigInt(this.counterBits);
|
|
16
15
|
now = now | counter;
|
|
17
16
|
const id = now.toString(36).toUpperCase();
|
|
18
|
-
return prefix + id;
|
|
17
|
+
return prefix ? prefix + id : id;
|
|
19
18
|
}
|
|
20
|
-
|
|
21
|
-
}
|
|
19
|
+
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { ExcelUtil } from './service/excelUtil.service';
|
|
1
|
+
import {Global, Module} from "@nestjs/common";
|
|
2
|
+
import { LoggingService } from "./service/loggingUtil.service";
|
|
3
|
+
import {ReflectionHelper} from "./service/reflection-helper.service";
|
|
4
|
+
import { ExcelUtil } from "./service/excelUtil.service";
|
|
5
|
+
import { ClockIDGenService } from "./service/clockIDGenUtil.service";
|
|
7
6
|
|
|
8
7
|
@Global()
|
|
9
8
|
@Module({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports: [LoggingService, ReflectionHelper, ExcelUtil],
|
|
9
|
+
providers: [LoggingService, ReflectionHelper,ExcelUtil,ClockIDGenService],
|
|
10
|
+
exports: [LoggingService, ReflectionHelper,ExcelUtil,ClockIDGenService],
|
|
13
11
|
})
|
|
14
12
|
export class UtilsModule {}
|