rez_core 6.5.2 → 6.5.5
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/app.module.js +1 -1
- package/dist/app.module.js.map +1 -1
- package/dist/config/database.config.js +1 -1
- package/dist/config/database.config.js.map +1 -1
- package/dist/constant/status.constant.d.ts +4 -0
- package/dist/constant/status.constant.js +9 -0
- package/dist/constant/status.constant.js.map +1 -0
- package/dist/core.module.js +60 -38
- package/dist/core.module.js.map +1 -1
- package/dist/module/auth/strategies/jwt.strategy.d.ts +1 -1
- package/dist/module/auth/strategies/jwt.strategy.js +2 -2
- package/dist/module/auth/strategies/jwt.strategy.js.map +1 -1
- package/dist/module/dashboard/dashboard.module.js +1 -1
- package/dist/module/dashboard/dashboard.module.js.map +1 -1
- package/dist/module/dashboard/service/dashboard.service.js +2 -3
- package/dist/module/dashboard/service/dashboard.service.js.map +1 -1
- package/dist/module/enterprise/controller/organization.controller.d.ts +1 -3
- package/dist/module/enterprise/controller/organization.controller.js +2 -6
- package/dist/module/enterprise/controller/organization.controller.js.map +1 -1
- package/dist/module/enterprise/enterprise.module.js +1 -3
- package/dist/module/enterprise/enterprise.module.js.map +1 -1
- package/dist/module/enterprise/entity/organization.entity.d.ts +2 -1
- package/dist/module/enterprise/entity/organization.entity.js +4 -2
- package/dist/module/enterprise/entity/organization.entity.js.map +1 -1
- package/dist/module/enterprise/repository/enterprise.repository.d.ts +2 -0
- package/dist/module/enterprise/repository/enterprise.repository.js +10 -0
- package/dist/module/enterprise/repository/enterprise.repository.js.map +1 -1
- package/dist/module/enterprise/service/organization.service.d.ts +2 -2
- package/dist/module/enterprise/service/organization.service.js +4 -4
- package/dist/module/enterprise/service/organization.service.js.map +1 -1
- package/dist/module/filter/service/filter.service.js +2 -2
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/layout/controller/layout.controller.d.ts +1 -3
- package/dist/module/layout/controller/layout.controller.js +3 -7
- package/dist/module/layout/controller/layout.controller.js.map +1 -1
- package/dist/module/layout/entity/header-section.entity.d.ts +0 -2
- package/dist/module/layout/entity/header-section.entity.js +0 -8
- package/dist/module/layout/entity/header-section.entity.js.map +1 -1
- package/dist/module/layout/layout.module.js +1 -2
- package/dist/module/layout/layout.module.js.map +1 -1
- package/dist/module/layout/repository/header-section.repository.d.ts +0 -1
- package/dist/module/layout/repository/header-section.repository.js +0 -5
- package/dist/module/layout/repository/header-section.repository.js.map +1 -1
- package/dist/module/layout/service/header-section.service.d.ts +1 -1
- package/dist/module/layout/service/header-section.service.js +1 -1
- package/dist/module/layout/service/header-section.service.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.js +1 -8
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/meta/entity/app-master.entity.d.ts +8 -4
- package/dist/module/meta/entity/app-master.entity.js +30 -12
- package/dist/module/meta/entity/app-master.entity.js.map +1 -1
- package/dist/module/meta/repository/app-master.repository.js +1 -1
- package/dist/module/meta/repository/app-master.repository.js.map +1 -1
- package/dist/module/meta/service/attribute-master.service.js +0 -2
- package/dist/module/meta/service/attribute-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.js +2 -6
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/module/controller/menu.controller.js +2 -2
- package/dist/module/module/controller/menu.controller.js.map +1 -1
- package/dist/module/module/controller/module-access.controller.d.ts +5 -6
- package/dist/module/module/controller/module-access.controller.js +33 -28
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/entity/menu.entity.d.ts +6 -2
- package/dist/module/module/entity/menu.entity.js +19 -7
- package/dist/module/module/entity/menu.entity.js.map +1 -1
- package/dist/module/module/entity/module-access.entity.d.ts +15 -0
- package/dist/module/module/entity/module-access.entity.js +50 -0
- package/dist/module/module/entity/module-access.entity.js.map +1 -1
- package/dist/module/module/entity/module-action.entity.d.ts +4 -1
- package/dist/module/module/entity/module-action.entity.js +12 -3
- package/dist/module/module/entity/module-action.entity.js.map +1 -1
- package/dist/module/module/entity/module.entity.d.ts +3 -5
- package/dist/module/module/entity/module.entity.js +8 -18
- package/dist/module/module/entity/module.entity.js.map +1 -1
- package/dist/module/module/module.module.d.ts +1 -1
- package/dist/module/module/module.module.js +7 -9
- package/dist/module/module/module.module.js.map +1 -1
- package/dist/module/module/repository/menu.repository.d.ts +4 -4
- package/dist/module/module/repository/menu.repository.js +17 -27
- package/dist/module/module/repository/menu.repository.js.map +1 -1
- package/dist/module/module/repository/module-access.repository.d.ts +11 -12
- package/dist/module/module/repository/module-access.repository.js +37 -40
- package/dist/module/module/repository/module-access.repository.js.map +1 -1
- package/dist/module/module/service/menu.service.d.ts +3 -5
- package/dist/module/module/service/menu.service.js +9 -12
- package/dist/module/module/service/menu.service.js.map +1 -1
- package/dist/module/module/service/module-access.service.d.ts +13 -17
- package/dist/module/module/service/module-access.service.js +17 -25
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/notification/service/otp.service.js.map +1 -1
- package/dist/module/user/controller/user.controller.d.ts +0 -2
- package/dist/module/user/controller/user.controller.js +0 -13
- package/dist/module/user/controller/user.controller.js.map +1 -1
- package/dist/module/user/dto/create-user.dto.d.ts +6 -3
- package/dist/module/user/dto/create-user.dto.js +17 -11
- package/dist/module/user/dto/create-user.dto.js.map +1 -1
- package/dist/module/user/entity/role.entity.d.ts +19 -6
- package/dist/module/user/entity/role.entity.js +68 -19
- package/dist/module/user/entity/role.entity.js.map +1 -1
- package/dist/module/user/entity/user-role-mapping.entity.d.ts +10 -0
- package/dist/module/user/entity/user-role-mapping.entity.js +33 -1
- package/dist/module/user/entity/user-role-mapping.entity.js.map +1 -1
- package/dist/module/user/entity/user.entity.d.ts +19 -5
- package/dist/module/user/entity/user.entity.js +69 -15
- package/dist/module/user/entity/user.entity.js.map +1 -1
- package/dist/module/user/repository/role.repository.d.ts +5 -2
- package/dist/module/user/repository/role.repository.js +13 -8
- package/dist/module/user/repository/role.repository.js.map +1 -1
- package/dist/module/user/repository/user.repository.d.ts +3 -2
- package/dist/module/user/repository/user.repository.js +9 -6
- package/dist/module/user/repository/user.repository.js.map +1 -1
- package/dist/module/user/service/login.service.d.ts +3 -5
- package/dist/module/user/service/login.service.js +37 -42
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/user/service/role.service.d.ts +21 -11
- package/dist/module/user/service/role.service.js +32 -38
- package/dist/module/user/service/role.service.js.map +1 -1
- package/dist/module/user/service/user-session.service.d.ts +1 -1
- package/dist/module/user/service/user-session.service.js +4 -4
- package/dist/module/user/service/user-session.service.js.map +1 -1
- package/dist/module/user/service/user.service.d.ts +28 -20
- package/dist/module/user/service/user.service.js +41 -56
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/module/user/user.module.js +1 -5
- package/dist/module/user/user.module.js.map +1 -1
- package/dist/module/workflow/repository/action-data.repository.d.ts +1 -1
- package/dist/module/workflow/repository/action-data.repository.js +6 -8
- package/dist/module/workflow/repository/action-data.repository.js.map +1 -1
- package/dist/module/workflow/repository/action.repository.d.ts +1 -1
- package/dist/module/workflow/repository/action.repository.js +10 -10
- package/dist/module/workflow/repository/action.repository.js.map +1 -1
- package/dist/module/workflow/repository/form-master.repository.d.ts +1 -1
- package/dist/module/workflow/repository/form-master.repository.js +2 -2
- package/dist/module/workflow/repository/form-master.repository.js.map +1 -1
- package/dist/module/workflow/service/action-data.service.js +1 -2
- package/dist/module/workflow/service/action-data.service.js.map +1 -1
- package/dist/module/workflow/service/action.service.js +2 -2
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/module/workflow/service/comm-template.service.js +0 -2
- package/dist/module/workflow/service/comm-template.service.js.map +1 -1
- package/dist/module/workflow/service/entity-modification.service.js +0 -1
- package/dist/module/workflow/service/entity-modification.service.js.map +1 -1
- package/dist/module/workflow/service/form-master.service.js +2 -2
- package/dist/module/workflow/service/form-master.service.js.map +1 -1
- package/dist/module/workflow/service/task.service.js +0 -3
- package/dist/module/workflow/service/task.service.js.map +1 -1
- package/dist/module/workflow/service/workflow-meta.service.js +2 -7
- package/dist/module/workflow/service/workflow-meta.service.js.map +1 -1
- package/dist/module/workflow/service/workflow.service.js +2 -2
- package/dist/module/workflow/service/workflow.service.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.js +1 -4
- package/dist/module/workflow-automation/service/workflow-automation.service.js.map +1 -1
- package/dist/module/workflow-schedule/service/workflow-schedule.service.js +0 -2
- package/dist/module/workflow-schedule/service/workflow-schedule.service.js.map +1 -1
- package/dist/table.config.d.ts +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/app.module.ts +3 -3
- package/src/config/database.config.ts +1 -1
- package/src/constant/status.constant.ts +4 -0
- package/src/core.module.ts +55 -44
- package/src/module/auth/strategies/jwt.strategy.ts +2 -2
- package/src/module/dashboard/dashboard.module.ts +3 -3
- package/src/module/dashboard/service/dashboard.service.ts +2 -3
- package/src/module/enterprise/controller/organization.controller.ts +0 -1
- package/src/module/enterprise/enterprise.module.ts +1 -2
- package/src/module/enterprise/entity/organization.entity.ts +5 -3
- package/src/module/enterprise/repository/enterprise.repository.ts +14 -0
- package/src/module/enterprise/service/organization.service.ts +1 -1
- package/src/module/filter/service/filter.service.ts +2 -3
- package/src/module/layout/controller/layout.controller.ts +1 -8
- package/src/module/layout/entity/header-section.entity.ts +0 -6
- package/src/module/layout/layout.module.ts +1 -1
- package/src/module/layout/repository/header-section.repository.ts +0 -6
- package/src/module/layout/service/header-section.service.ts +1 -1
- package/src/module/listmaster/service/list-master.service.ts +1 -9
- package/src/module/meta/entity/app-master.entity.ts +22 -9
- package/src/module/meta/repository/app-master.repository.ts +1 -1
- package/src/module/meta/service/attribute-master.service.ts +0 -2
- package/src/module/meta/service/entity-service-impl.service.ts +2 -6
- package/src/module/module/controller/menu.controller.ts +2 -2
- package/src/module/module/controller/module-access.controller.ts +25 -20
- package/src/module/module/entity/menu.entity.ts +17 -7
- package/src/module/module/entity/module-access.entity.ts +41 -1
- package/src/module/module/entity/module-action.entity.ts +11 -4
- package/src/module/module/entity/module.entity.ts +7 -14
- package/src/module/module/module.module.ts +3 -4
- package/src/module/module/repository/menu.repository.ts +19 -31
- package/src/module/module/repository/module-access.repository.ts +43 -47
- package/src/module/module/service/menu.service.ts +11 -13
- package/src/module/module/service/module-access.service.ts +24 -40
- package/src/module/notification/service/otp.service.ts +3 -2
- package/src/module/user/controller/user.controller.ts +0 -9
- package/src/module/user/dto/create-user.dto.ts +19 -6
- package/src/module/user/entity/role.entity.ts +62 -16
- package/src/module/user/entity/user-role-mapping.entity.ts +29 -3
- package/src/module/user/entity/user.entity.ts +54 -13
- package/src/module/user/repository/role.repository.ts +19 -11
- package/src/module/user/repository/user.repository.ts +10 -6
- package/src/module/user/service/login.service.ts +38 -50
- package/src/module/user/service/role.service.ts +40 -60
- package/src/module/user/service/user-session.service.ts +4 -4
- package/src/module/user/service/user.service.ts +59 -91
- package/src/module/user/user.module.ts +3 -4
- package/src/module/workflow/repository/action-data.repository.ts +6 -8
- package/src/module/workflow/repository/action.repository.ts +11 -11
- package/src/module/workflow/repository/form-master.repository.ts +2 -2
- package/src/module/workflow/service/action-data.service.ts +3 -2
- package/src/module/workflow/service/action.service.ts +2 -2
- package/src/module/workflow/service/comm-template.service.ts +0 -2
- package/src/module/workflow/service/entity-modification.service.ts +0 -1
- package/src/module/workflow/service/form-master.service.ts +2 -2
- package/src/module/workflow/service/task.service.ts +0 -3
- package/src/module/workflow/service/workflow-meta.service.ts +2 -7
- package/src/module/workflow/service/workflow.service.ts +2 -2
- package/src/module/workflow-automation/service/workflow-automation.service.ts +1 -4
- package/src/module/workflow-schedule/service/workflow-schedule.service.ts +0 -2
- package/src/resources/dev.properties.yaml +2 -2
- package/.claude/settings.local.json +0 -26
- package/.idea/250218_nodejs_core.iml +0 -9
- package/.idea/codeStyles/Project.xml +0 -59
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/copilot.data.migration.agent.xml +0 -6
- package/.idea/copilot.data.migration.ask.xml +0 -6
- package/.idea/copilot.data.migration.ask2agent.xml +0 -6
- package/.idea/copilot.data.migration.edit.xml +0 -6
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -6
- package/.idea/vcs.xml +0 -6
- package/server.log +0 -850
|
@@ -25,11 +25,11 @@ export class ModuleAccessRepository {
|
|
|
25
25
|
) {}
|
|
26
26
|
|
|
27
27
|
async getRoles({
|
|
28
|
-
|
|
28
|
+
appId,
|
|
29
29
|
level_type,
|
|
30
30
|
level_id,
|
|
31
31
|
}: {
|
|
32
|
-
|
|
32
|
+
appId: number;
|
|
33
33
|
level_type?: string;
|
|
34
34
|
level_id?: number;
|
|
35
35
|
}) {
|
|
@@ -37,7 +37,7 @@ export class ModuleAccessRepository {
|
|
|
37
37
|
.createQueryBuilder()
|
|
38
38
|
.select('*')
|
|
39
39
|
.from('sso_role', 'role')
|
|
40
|
-
.where('role.
|
|
40
|
+
.where('role.app_id = :appId', { appId })
|
|
41
41
|
.andWhere('(role.is_factory IS NULL OR role.is_factory != 1)');
|
|
42
42
|
|
|
43
43
|
if (level_type) {
|
|
@@ -59,20 +59,20 @@ export class ModuleAccessRepository {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
async getModules({
|
|
62
|
-
|
|
62
|
+
app_id,
|
|
63
63
|
loggedInUser,
|
|
64
64
|
}: {
|
|
65
|
-
|
|
65
|
+
app_id: any;
|
|
66
66
|
loggedInUser: any;
|
|
67
67
|
}) {
|
|
68
68
|
let modules: any[];
|
|
69
69
|
if (loggedInUser.level_type == 'SCH') {
|
|
70
70
|
modules = await this.moduleRepo.find({
|
|
71
|
-
where: { module_level: 'MAINMOD',
|
|
71
|
+
where: { module_level: 'MAINMOD', app_id, level_type: 'SCH' },
|
|
72
72
|
});
|
|
73
73
|
} else {
|
|
74
74
|
modules = await this.moduleRepo.find({
|
|
75
|
-
where: { module_level: 'MAINMOD',
|
|
75
|
+
where: { module_level: 'MAINMOD', app_id },
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -87,7 +87,7 @@ export class ModuleAccessRepository {
|
|
|
87
87
|
|
|
88
88
|
async getAccessListing(
|
|
89
89
|
roleIds: (number | string)[],
|
|
90
|
-
|
|
90
|
+
appId: number,
|
|
91
91
|
levelType: string,
|
|
92
92
|
levelId?: number, // add levelId as input so we can fetch roles based on it
|
|
93
93
|
) {
|
|
@@ -96,7 +96,7 @@ export class ModuleAccessRepository {
|
|
|
96
96
|
if (roleIds.length === 1 && roleIds[0] === -1) {
|
|
97
97
|
// Internally call getRoles
|
|
98
98
|
const fetchedRoles = await this.getRoles({
|
|
99
|
-
|
|
99
|
+
appId,
|
|
100
100
|
level_type: levelType,
|
|
101
101
|
level_id: levelId,
|
|
102
102
|
});
|
|
@@ -105,52 +105,51 @@ export class ModuleAccessRepository {
|
|
|
105
105
|
roles = await this.roleRepo.find({
|
|
106
106
|
where: {
|
|
107
107
|
id: In(fetchedRoleIds),
|
|
108
|
-
|
|
108
|
+
app_id: appId,
|
|
109
109
|
},
|
|
110
110
|
});
|
|
111
111
|
} else {
|
|
112
112
|
roles = await this.roleRepo.find({
|
|
113
113
|
where: {
|
|
114
114
|
id: In(roleIds.map((id) => Number(id))),
|
|
115
|
-
|
|
115
|
+
app_id: appId,
|
|
116
116
|
},
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
if (!roles.length) return [];
|
|
121
121
|
|
|
122
|
-
const roleCodes = roles.map((role) => role.code);
|
|
123
|
-
|
|
124
122
|
const moduleAccesses = await this.moduleAccessRepo.find({
|
|
125
123
|
where: {
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
role_id: In(roles.map((role) => role.id)),
|
|
125
|
+
app_id: appId,
|
|
126
|
+
level_type: levelType,
|
|
128
127
|
},
|
|
129
128
|
});
|
|
130
129
|
|
|
131
130
|
return roles.map((role) => ({
|
|
132
|
-
|
|
131
|
+
role_id: role.id,
|
|
133
132
|
name: role.name,
|
|
134
133
|
permission: moduleAccesses
|
|
135
|
-
.filter((access) => access.
|
|
134
|
+
.filter((access) => access.role_id === role.id)
|
|
136
135
|
.map((access) => ({
|
|
137
|
-
|
|
136
|
+
action_id: access.action_id,
|
|
138
137
|
access: access.access_flag,
|
|
139
|
-
|
|
138
|
+
module_id: access.module_id,
|
|
140
139
|
level_type: access.level_type,
|
|
141
|
-
|
|
140
|
+
app_id: access.app_id,
|
|
142
141
|
})),
|
|
143
142
|
}));
|
|
144
143
|
}
|
|
145
144
|
|
|
146
|
-
async getAllModulesByLevel(mainModIds: string[],
|
|
145
|
+
async getAllModulesByLevel(mainModIds: string[], app_id: number, levelType) {
|
|
147
146
|
const mainModules =
|
|
148
147
|
mainModIds.length === 1 && mainModIds[0] === '-1'
|
|
149
148
|
? await this.moduleRepo.find({
|
|
150
|
-
|
|
149
|
+
where: { module_level: 'MAINMOD', app_id },
|
|
151
150
|
})
|
|
152
151
|
: await this.moduleRepo.find({
|
|
153
|
-
where: { id: In(mainModIds), module_level: 'MAINMOD',
|
|
152
|
+
where: { id: In(mainModIds), module_level: 'MAINMOD', app_id },
|
|
154
153
|
});
|
|
155
154
|
|
|
156
155
|
if (!mainModules.length) return {};
|
|
@@ -165,7 +164,7 @@ export class ModuleAccessRepository {
|
|
|
165
164
|
.join(' OR '),
|
|
166
165
|
Object.fromEntries(wbsCodes.map((code) => [`code${code}`, `${code}%`])),
|
|
167
166
|
)
|
|
168
|
-
.andWhere('module.
|
|
167
|
+
.andWhere('module.app_id = :app_id', { app_id })
|
|
169
168
|
.andWhere('module.module_code != :excludedCode', {
|
|
170
169
|
excludedCode: 'all_organization_adm_org',
|
|
171
170
|
})
|
|
@@ -175,10 +174,10 @@ export class ModuleAccessRepository {
|
|
|
175
174
|
(mod) => mod.module_code != 'all_organization_adm_org',
|
|
176
175
|
);
|
|
177
176
|
|
|
178
|
-
const
|
|
177
|
+
const modules = allModules.map((m) => m.id);
|
|
179
178
|
|
|
180
179
|
const allActions = await this.moduleActionRepo.find({
|
|
181
|
-
where: {
|
|
180
|
+
where: { module_id: In(modules) },
|
|
182
181
|
});
|
|
183
182
|
|
|
184
183
|
// Map actions by module_code with VIEW action first
|
|
@@ -187,11 +186,11 @@ export class ModuleAccessRepository {
|
|
|
187
186
|
if (!acc[action.module_code]) acc[action.module_code] = [];
|
|
188
187
|
|
|
189
188
|
const actionItem = {
|
|
190
|
-
action: action.
|
|
189
|
+
action: action.action_code,
|
|
191
190
|
name: action.action_name,
|
|
192
191
|
};
|
|
193
192
|
|
|
194
|
-
if (action.
|
|
193
|
+
if (action.action_code === 'VIEW') {
|
|
195
194
|
acc[action.module_code].unshift(actionItem); // ➕ Add VIEW at start
|
|
196
195
|
} else {
|
|
197
196
|
acc[action.module_code].push(actionItem); // ➕ Add others at end
|
|
@@ -219,7 +218,7 @@ export class ModuleAccessRepository {
|
|
|
219
218
|
)
|
|
220
219
|
.map((mod) => ({
|
|
221
220
|
name: mod.name,
|
|
222
|
-
|
|
221
|
+
module_id: mod.id,
|
|
223
222
|
permission: actionMap[mod.module_code] || [],
|
|
224
223
|
submod: buildHierarchy(mod.wbs_code),
|
|
225
224
|
}));
|
|
@@ -228,7 +227,7 @@ export class ModuleAccessRepository {
|
|
|
228
227
|
.filter((mod) => mod.level_type === lvl)
|
|
229
228
|
.map((mod) => ({
|
|
230
229
|
name: mod.name,
|
|
231
|
-
|
|
230
|
+
module_id: mod.id,
|
|
232
231
|
permission: actionMap[mod.module_code] || [],
|
|
233
232
|
submod: buildHierarchy(mod.wbs_code),
|
|
234
233
|
}));
|
|
@@ -242,11 +241,11 @@ export class ModuleAccessRepository {
|
|
|
242
241
|
|
|
243
242
|
async updateModuleAccess(
|
|
244
243
|
accessList: {
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
role_id: number;
|
|
245
|
+
module_id: number;
|
|
247
246
|
action_type: string;
|
|
248
247
|
access_flag: number;
|
|
249
|
-
|
|
248
|
+
app_id: number;
|
|
250
249
|
level_type: string;
|
|
251
250
|
}[],
|
|
252
251
|
): Promise<boolean> {
|
|
@@ -254,10 +253,10 @@ export class ModuleAccessRepository {
|
|
|
254
253
|
for (const access of accessList) {
|
|
255
254
|
const existing = await this.moduleAccessRepo.findOne({
|
|
256
255
|
where: {
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
role_id: access.role_id,
|
|
257
|
+
module_id: access.module_id,
|
|
259
258
|
action_type: access.action_type,
|
|
260
|
-
|
|
259
|
+
app_id: access.app_id,
|
|
261
260
|
level_type: access.level_type,
|
|
262
261
|
},
|
|
263
262
|
});
|
|
@@ -278,20 +277,17 @@ export class ModuleAccessRepository {
|
|
|
278
277
|
}
|
|
279
278
|
}
|
|
280
279
|
|
|
281
|
-
async getModuleUIConfig(
|
|
280
|
+
async getModuleUIConfig(moduleId: number, roleIds: number[]) {
|
|
282
281
|
const module = await this.moduleRepo.findOne({
|
|
283
|
-
where: {
|
|
282
|
+
where: { id: moduleId },
|
|
284
283
|
});
|
|
285
284
|
|
|
286
285
|
if (!module) throw new BadRequestException('Module not found');
|
|
287
286
|
|
|
288
|
-
const roles = await this.roleRepo.find({ where: { id: In(roleIds) } });
|
|
289
|
-
const roleCodes = roles.map((role) => role.code);
|
|
290
|
-
|
|
291
287
|
const actions = await this.moduleAccessRepo.find({
|
|
292
288
|
where: {
|
|
293
|
-
|
|
294
|
-
|
|
289
|
+
module_id: moduleId,
|
|
290
|
+
role_id: In(roleIds),
|
|
295
291
|
access_flag: 1,
|
|
296
292
|
},
|
|
297
293
|
});
|
|
@@ -301,16 +297,16 @@ export class ModuleAccessRepository {
|
|
|
301
297
|
return {
|
|
302
298
|
entity_type: module.entity_type,
|
|
303
299
|
title: module.title,
|
|
304
|
-
ui_config: module.ui_config || {},
|
|
305
300
|
action: uniqueActions,
|
|
306
301
|
};
|
|
307
302
|
}
|
|
308
|
-
|
|
303
|
+
|
|
304
|
+
async getModuleAccessByRoles(roleIds: number[], app_id: number) {
|
|
309
305
|
// Step 1: Get role codes from sso_role
|
|
310
306
|
const roles = await this.roleRepo.find({
|
|
311
307
|
where: {
|
|
312
308
|
id: In(roleIds),
|
|
313
|
-
|
|
309
|
+
app_id,
|
|
314
310
|
},
|
|
315
311
|
select: ['id', 'code'],
|
|
316
312
|
});
|
|
@@ -329,7 +325,7 @@ export class ModuleAccessRepository {
|
|
|
329
325
|
'access.appcode AS appcode',
|
|
330
326
|
])
|
|
331
327
|
.where('access.role_code IN (:...roleCodes)', { roleCodes })
|
|
332
|
-
.andWhere('access.
|
|
328
|
+
.andWhere('access.app_id = :app_id', { app_id })
|
|
333
329
|
.getRawMany();
|
|
334
330
|
|
|
335
331
|
// Step 3: Format output
|
|
@@ -1,45 +1,43 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { MenuRepository } from '../repository/menu.repository';
|
|
3
3
|
import { MenuData } from '../entity/menu.entity';
|
|
4
|
-
import { DataSource } from 'typeorm';
|
|
5
|
-
import { UserRoleMapping } from 'src/module/user/entity/user-role-mapping.entity';
|
|
6
4
|
|
|
7
5
|
@Injectable()
|
|
8
6
|
export class MenuService {
|
|
9
7
|
constructor(
|
|
10
8
|
private readonly menuRepository: MenuRepository,
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
) {
|
|
10
|
+
}
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* Fetch and construct menu hierarchy for a given user.
|
|
16
14
|
*/
|
|
17
15
|
async getUserMenu(
|
|
18
16
|
userId: number,
|
|
19
|
-
|
|
17
|
+
app_id: number,
|
|
20
18
|
levelType: 'ORG' | 'SCH',
|
|
21
19
|
levelId: number,
|
|
22
20
|
): Promise<{ menu: any[] }> {
|
|
23
21
|
// Step 1: Resolve roles (with fallback logic inside)
|
|
24
22
|
const roleCodes = await this.menuRepository.resolveUserRoles(
|
|
25
23
|
userId,
|
|
26
|
-
|
|
24
|
+
app_id,
|
|
27
25
|
levelType,
|
|
28
26
|
levelId,
|
|
29
27
|
);
|
|
30
28
|
if (!roleCodes.length) return { menu: [] };
|
|
31
29
|
|
|
32
30
|
// Step 2: Get accessible modules
|
|
33
|
-
const
|
|
31
|
+
const modules = await this.menuRepository.getAccessibleModules(
|
|
34
32
|
roleCodes,
|
|
35
|
-
|
|
33
|
+
app_id,
|
|
36
34
|
);
|
|
37
|
-
if (!
|
|
35
|
+
if (!modules.length) return { menu: [] };
|
|
38
36
|
|
|
39
37
|
// Step 3: Get menu items for the given level type
|
|
40
38
|
const menuItems = await this.menuRepository.getMenuItems(
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
modules,
|
|
40
|
+
app_id,
|
|
43
41
|
levelType,
|
|
44
42
|
);
|
|
45
43
|
|
|
@@ -76,7 +74,7 @@ export class MenuService {
|
|
|
76
74
|
}
|
|
77
75
|
|
|
78
76
|
// get user roles
|
|
79
|
-
async getUserRoles(userId: number,
|
|
80
|
-
return this.menuRepository.getUserRoles(userId,
|
|
77
|
+
async getUserRoles(userId: number, app_id: number): Promise<any> {
|
|
78
|
+
return this.menuRepository.getUserRoles(userId, app_id);
|
|
81
79
|
}
|
|
82
80
|
}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import { BadRequestException,
|
|
1
|
+
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
2
|
import { ModuleAccessRepository } from '../repository/module-access.repository';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
ENTITYTYPE_ROLE,
|
|
7
|
-
STATUS_INACTIVE,
|
|
8
|
-
} from '../../../constant/global.constant';
|
|
9
|
-
import { Role } from '../../user/entity/role.entity';
|
|
10
|
-
import { DataSource, EntityManager } from 'typeorm';
|
|
3
|
+
import { STATUS_INACTIVE } from '../../../constant/global.constant';
|
|
4
|
+
import { DataSource } from 'typeorm';
|
|
11
5
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
12
6
|
import { MenuRepository } from '../repository/menu.repository';
|
|
13
|
-
import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
|
|
14
7
|
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
15
8
|
|
|
16
9
|
@Injectable()
|
|
@@ -19,25 +12,23 @@ export class ModuleAccessService {
|
|
|
19
12
|
private readonly moduleAccessRepository: ModuleAccessRepository,
|
|
20
13
|
private readonly menuRepository: MenuRepository,
|
|
21
14
|
private readonly dataSource: DataSource,
|
|
22
|
-
@Inject('ListMasterService')
|
|
23
|
-
private readonly listMasterService: ListMasterService,
|
|
24
15
|
private readonly reflectionHelper: ReflectionHelper,
|
|
25
16
|
) {
|
|
26
17
|
}
|
|
27
18
|
|
|
28
|
-
async getModules({
|
|
19
|
+
async getModules({ app_id, loggedInUser }: { app_id: number, loggedInUser: UserData }) {
|
|
29
20
|
return this.moduleAccessRepository.getModules({
|
|
30
|
-
|
|
21
|
+
app_id, loggedInUser,
|
|
31
22
|
});
|
|
32
23
|
}
|
|
33
24
|
|
|
34
25
|
async getRoles({
|
|
35
|
-
|
|
26
|
+
appId,
|
|
36
27
|
level_type,
|
|
37
28
|
level_id,
|
|
38
29
|
include,
|
|
39
30
|
}: {
|
|
40
|
-
|
|
31
|
+
appId: number;
|
|
41
32
|
level_type?: string;
|
|
42
33
|
level_id?: number;
|
|
43
34
|
include?: boolean;
|
|
@@ -46,7 +37,7 @@ export class ModuleAccessService {
|
|
|
46
37
|
.createQueryBuilder()
|
|
47
38
|
.select('*')
|
|
48
39
|
.from('sso_role', 'role')
|
|
49
|
-
.where('role.
|
|
40
|
+
.where('role.app_id = :appId', { appId });
|
|
50
41
|
|
|
51
42
|
// Only add this condition if `include` is false (exclude factory roles)
|
|
52
43
|
if (!include) {
|
|
@@ -70,13 +61,13 @@ export class ModuleAccessService {
|
|
|
70
61
|
|
|
71
62
|
async getAccessListing(
|
|
72
63
|
roleIds: number[],
|
|
73
|
-
|
|
64
|
+
appId: number,
|
|
74
65
|
levelType: string,
|
|
75
66
|
level_id?: number,
|
|
76
67
|
) {
|
|
77
68
|
return this.moduleAccessRepository.getAccessListing(
|
|
78
69
|
roleIds,
|
|
79
|
-
|
|
70
|
+
appId,
|
|
80
71
|
levelType,
|
|
81
72
|
level_id,
|
|
82
73
|
);
|
|
@@ -84,27 +75,27 @@ export class ModuleAccessService {
|
|
|
84
75
|
|
|
85
76
|
async getMenuListing(
|
|
86
77
|
mainModIds: string[],
|
|
87
|
-
|
|
78
|
+
appId: number,
|
|
88
79
|
levelType: string,
|
|
89
80
|
): Promise<Record<string, any[]>> {
|
|
90
|
-
if (!
|
|
91
|
-
throw new BadRequestException('
|
|
81
|
+
if (!appId) {
|
|
82
|
+
throw new BadRequestException('AppId is required');
|
|
92
83
|
}
|
|
93
84
|
|
|
94
85
|
return this.moduleAccessRepository.getAllModulesByLevel(
|
|
95
86
|
mainModIds,
|
|
96
|
-
|
|
87
|
+
appId,
|
|
97
88
|
levelType,
|
|
98
89
|
);
|
|
99
90
|
}
|
|
100
91
|
|
|
101
92
|
async updateModuleAccess(
|
|
102
93
|
moduleAccessData: {
|
|
103
|
-
|
|
104
|
-
|
|
94
|
+
role_id: number;
|
|
95
|
+
module_id: number;
|
|
105
96
|
action_type: string;
|
|
106
97
|
access_flag: number;
|
|
107
|
-
|
|
98
|
+
app_id: number;
|
|
108
99
|
level_type: string;
|
|
109
100
|
}[],
|
|
110
101
|
): Promise<{ success: boolean; msg: string }> {
|
|
@@ -124,27 +115,25 @@ export class ModuleAccessService {
|
|
|
124
115
|
|
|
125
116
|
// src/module/module-access/service/module-access.service.ts
|
|
126
117
|
|
|
127
|
-
async getModuleUIConfig(
|
|
128
|
-
return this.moduleAccessRepository.getModuleUIConfig(
|
|
118
|
+
async getModuleUIConfig(moduleId: number, roleIds: number[]) {
|
|
119
|
+
return this.moduleAccessRepository.getModuleUIConfig(moduleId, roleIds);
|
|
129
120
|
}
|
|
130
121
|
|
|
131
122
|
async getUserPermissions({
|
|
132
123
|
userId,
|
|
133
|
-
|
|
124
|
+
app_id,
|
|
134
125
|
level_type,
|
|
135
126
|
level_id,
|
|
136
|
-
enterprise_id,
|
|
137
127
|
}: {
|
|
138
128
|
userId: number;
|
|
139
|
-
|
|
129
|
+
app_id: number;
|
|
140
130
|
level_type: string;
|
|
141
131
|
level_id: number;
|
|
142
|
-
enterprise_id: number;
|
|
143
132
|
}) {
|
|
144
133
|
// Step 1: Resolve roles
|
|
145
134
|
const roleCodes = await this.menuRepository.resolveUserRoles(
|
|
146
135
|
userId,
|
|
147
|
-
|
|
136
|
+
app_id,
|
|
148
137
|
level_type,
|
|
149
138
|
level_id,
|
|
150
139
|
);
|
|
@@ -159,7 +148,7 @@ export class ModuleAccessService {
|
|
|
159
148
|
const allPermissions =
|
|
160
149
|
await this.moduleAccessRepository.getModuleAccessByRoles(
|
|
161
150
|
roleIds,
|
|
162
|
-
|
|
151
|
+
app_id,
|
|
163
152
|
);
|
|
164
153
|
|
|
165
154
|
// Step 3: If level_type is SCH, check school status using raw query
|
|
@@ -172,12 +161,7 @@ export class ModuleAccessService {
|
|
|
172
161
|
},
|
|
173
162
|
});
|
|
174
163
|
|
|
175
|
-
|
|
176
|
-
STATUS_INACTIVE,
|
|
177
|
-
enterprise_id || 0,
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
if (!school || school.status === resolveStatus.id) {
|
|
164
|
+
if (!school || school.status === STATUS_INACTIVE) {
|
|
181
165
|
// Return only VIEW permissions
|
|
182
166
|
return allPermissions.filter((perm) => perm.action === 'VIEW');
|
|
183
167
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataSource } from 'typeorm';
|
|
2
|
-
import {
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
3
|
import { ConfigService } from '@nestjs/config';
|
|
4
4
|
import { ClockIDGenService } from '../../../utils/service/clockIDGenUtil.service';
|
|
5
5
|
import { Otp } from '../entity/otp.entity';
|
|
@@ -16,7 +16,8 @@ export class OtpService {
|
|
|
16
16
|
private readonly loginService: LoginService,
|
|
17
17
|
private readonly emailService: EmailService,
|
|
18
18
|
private readonly dataSource: DataSource,
|
|
19
|
-
) {
|
|
19
|
+
) {
|
|
20
|
+
}
|
|
20
21
|
|
|
21
22
|
VERIFY_OTP = this.configService.get('VERIFY_OTP') || 'true';
|
|
22
23
|
DEFAULT_OTP = this.configService.get('DEFAULT_OTP') || '123456';
|
|
@@ -18,15 +18,6 @@ export class UserController {
|
|
|
18
18
|
@Inject('UserService') private readonly userService: UserService,
|
|
19
19
|
) {}
|
|
20
20
|
|
|
21
|
-
@Post('user/signup')
|
|
22
|
-
async signup(
|
|
23
|
-
@Body(new ValidationPipe()) createUserDto: CreateUserDto,
|
|
24
|
-
@Res() res: Response,
|
|
25
|
-
) {
|
|
26
|
-
const result = await this.userService.createEntity(createUserDto, null);
|
|
27
|
-
res.status(HttpStatus.OK).json(result);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
21
|
@Post('check-email')
|
|
31
22
|
@HttpCode(HttpStatus.OK)
|
|
32
23
|
async checkEmail(@Body() body, @Res() res: Response) {
|
|
@@ -2,12 +2,26 @@ import { IsNotEmpty, IsString, Matches } from 'class-validator';
|
|
|
2
2
|
import { BaseEntity } from '../../meta/entity/base-entity.entity';
|
|
3
3
|
import { ENTITYTYPE_USER } from '../../../constant/global.constant';
|
|
4
4
|
import { Expose } from 'class-transformer';
|
|
5
|
+
import { Column } from 'typeorm';
|
|
5
6
|
|
|
6
|
-
export class CreateUserDto
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export class CreateUserDto{
|
|
8
|
+
|
|
9
|
+
status: string;
|
|
10
|
+
|
|
11
|
+
code: string;
|
|
12
|
+
|
|
13
|
+
@Column({ name: 'enterprise_id', type: 'int', nullable: true })
|
|
14
|
+
@Expose()
|
|
15
|
+
enterprise_id: number | undefined;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@Column({ name: 'level_id', type: 'varchar', length: 100, nullable: true })
|
|
19
|
+
@Expose()
|
|
20
|
+
level_id: string;
|
|
21
|
+
|
|
22
|
+
@Column({ name: 'level_type', type: 'varchar', length: 100, nullable: true })
|
|
23
|
+
@Expose()
|
|
24
|
+
level_type: string;
|
|
11
25
|
|
|
12
26
|
@IsString()
|
|
13
27
|
@IsNotEmpty()
|
|
@@ -47,7 +61,6 @@ export class CreateUserDto extends BaseEntity {
|
|
|
47
61
|
@Expose()
|
|
48
62
|
mobile: string;
|
|
49
63
|
|
|
50
|
-
@Expose()
|
|
51
64
|
roles: any[];
|
|
52
65
|
|
|
53
66
|
is_firstlogin: number;
|
|
@@ -1,14 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
Column,
|
|
3
|
+
CreateDateColumn,
|
|
4
|
+
Entity,
|
|
5
|
+
JoinColumn,
|
|
6
|
+
ManyToOne,
|
|
7
|
+
PrimaryGeneratedColumn,
|
|
8
|
+
UpdateDateColumn,
|
|
9
|
+
} from 'typeorm';
|
|
4
10
|
import { Exclude } from 'class-transformer';
|
|
11
|
+
import { EnterpriseData } from '../../enterprise/entity/enterprise.entity';
|
|
12
|
+
import { AppMaster } from '../../meta/entity/app-master.entity';
|
|
5
13
|
|
|
6
14
|
@Entity({ name: 'sso_role' })
|
|
7
|
-
export class Role
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
export class Role {
|
|
16
|
+
|
|
17
|
+
@PrimaryGeneratedColumn({ type: 'bigint' })
|
|
18
|
+
id: number;
|
|
19
|
+
|
|
20
|
+
@Column({ name: 'name', type: 'varchar', length: 100, nullable: true })
|
|
21
|
+
name: string;
|
|
22
|
+
|
|
23
|
+
@Column({ name: 'status', type: 'varchar', nullable: true, length: 100 })
|
|
24
|
+
status: string;
|
|
25
|
+
|
|
26
|
+
@Column({ name: 'code', type: 'varchar', length: 100, nullable: true })
|
|
27
|
+
code: string;
|
|
28
|
+
|
|
29
|
+
@Column({ name: 'created_by', type: 'bigint', nullable: true })
|
|
30
|
+
created_by: number;
|
|
31
|
+
|
|
32
|
+
@CreateDateColumn()
|
|
33
|
+
created_date: Date;
|
|
34
|
+
|
|
35
|
+
@Column({ name: 'modified_by', type: 'bigint', nullable: true })
|
|
36
|
+
modified_by: number;
|
|
37
|
+
|
|
38
|
+
@UpdateDateColumn()
|
|
39
|
+
modified_date: Date;
|
|
40
|
+
|
|
41
|
+
@Column({ name: 'enterprise_id', type: 'int', nullable: true })
|
|
42
|
+
enterprise_id: number;
|
|
43
|
+
|
|
44
|
+
@ManyToOne(() => EnterpriseData, { nullable: true, onDelete: 'SET NULL' })
|
|
45
|
+
@JoinColumn({ name: 'enterprise_id', referencedColumnName: 'id' })
|
|
46
|
+
enterprise: EnterpriseData;
|
|
47
|
+
|
|
48
|
+
@Column({ name: 'organization_id', type: 'int', nullable: true })
|
|
49
|
+
organization_id: number;
|
|
50
|
+
|
|
51
|
+
@Column({ name: 'appcode', type: 'varchar', length: 100, nullable: true })
|
|
52
|
+
appcode: string;
|
|
53
|
+
|
|
54
|
+
@Column({ name: 'app_id', type: 'int', nullable: true })
|
|
55
|
+
app_id: number;
|
|
56
|
+
|
|
57
|
+
@ManyToOne(() => AppMaster, { nullable: true, onDelete: 'SET NULL' })
|
|
58
|
+
@JoinColumn({ name: 'app_id' , referencedColumnName: 'id' })
|
|
59
|
+
app: AppMaster;
|
|
60
|
+
|
|
61
|
+
@Column({ name: 'level_id', type: 'varchar', length: 100, nullable: true })
|
|
62
|
+
level_id: string;
|
|
63
|
+
|
|
64
|
+
@Column({ name: 'level_type', type: 'varchar', length: 100, nullable: true })
|
|
65
|
+
level_type: string;
|
|
12
66
|
|
|
13
67
|
@Column({ type: 'int', nullable: true })
|
|
14
68
|
is_system: number;
|
|
@@ -16,18 +70,10 @@ export class Role extends BaseEntity {
|
|
|
16
70
|
@Column({ type: 'varchar', length: 250, nullable: true })
|
|
17
71
|
description: string;
|
|
18
72
|
|
|
19
|
-
@Column({ type: 'int', nullable: true })
|
|
20
|
-
organization_id: number;
|
|
21
|
-
|
|
22
73
|
@Exclude()
|
|
23
74
|
copy_from_role_id: number;
|
|
24
75
|
|
|
25
76
|
@Column({ type: 'int', nullable: true })
|
|
26
77
|
is_factory: number;
|
|
27
78
|
|
|
28
|
-
@Column({ type: 'varchar', length: 250, nullable: true })
|
|
29
|
-
parent_type: string;
|
|
30
|
-
|
|
31
|
-
@Column({ type: 'int', nullable: true })
|
|
32
|
-
parent_id: number;
|
|
33
79
|
}
|