rez_core 2.2.38 → 2.2.40
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/module/workflow/controller/stage-group.controller.d.ts +1 -3
- package/dist/module/workflow/controller/stage-group.controller.js +3 -4
- package/dist/module/workflow/controller/stage-group.controller.js.map +1 -1
- package/dist/module/workflow/service/stage-group.service.d.ts +6 -4
- package/dist/module/workflow/service/stage-group.service.js +27 -4
- package/dist/module/workflow/service/stage-group.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/workflow/controller/stage-group.controller.ts +2 -6
- package/src/module/workflow/service/stage-group.service.ts +32 -7
package/package.json
CHANGED
|
@@ -34,15 +34,11 @@ export class StageGroupController {
|
|
|
34
34
|
|
|
35
35
|
@Post('/get-all-stage-groups-and-stages')
|
|
36
36
|
@HttpCode(HttpStatus.OK)
|
|
37
|
-
async getAllStageGroupAndStageHierarchy(
|
|
38
|
-
@Req() req: Request & { user: any },
|
|
39
|
-
@Body() body: { workflow_id: number },
|
|
40
|
-
) {
|
|
37
|
+
async getAllStageGroupAndStageHierarchy(@Req() req: Request & { user: any }) {
|
|
41
38
|
const loggedInUser = req.user.userData;
|
|
42
39
|
|
|
43
40
|
return this.stageGroupService.getAllStageGroupAndStageHierarchy(
|
|
44
|
-
|
|
45
|
-
loggedInUser.organization_id,
|
|
41
|
+
loggedInUser,
|
|
46
42
|
);
|
|
47
43
|
}
|
|
48
44
|
}
|
|
@@ -4,7 +4,9 @@ import { StageGroupRepository } from '../repository/stage-group.repository';
|
|
|
4
4
|
import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
5
5
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
6
6
|
import { StageService } from './stage.service';
|
|
7
|
-
import { DataSource } from 'typeorm';
|
|
7
|
+
import { DataSource, Repository } from 'typeorm';
|
|
8
|
+
import { WorkflowLevelMappingEntity } from '../entity/workflow-level-mapping.entity';
|
|
9
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
8
10
|
|
|
9
11
|
@Injectable()
|
|
10
12
|
export class StageGroupService extends EntityServiceImpl {
|
|
@@ -13,6 +15,8 @@ export class StageGroupService extends EntityServiceImpl {
|
|
|
13
15
|
@Inject('StageService')
|
|
14
16
|
private readonly stageService: StageService,
|
|
15
17
|
private readonly dataSource: DataSource,
|
|
18
|
+
@InjectRepository(WorkflowLevelMappingEntity)
|
|
19
|
+
private readonly workflowLevelMappingRepo: Repository<WorkflowLevelMappingEntity>,
|
|
16
20
|
) {
|
|
17
21
|
super();
|
|
18
22
|
}
|
|
@@ -23,13 +27,34 @@ export class StageGroupService extends EntityServiceImpl {
|
|
|
23
27
|
);
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
async getAllStageGroupAndStageHierarchy(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
async getAllStageGroupAndStageHierarchy(loggedInUser: UserData) {
|
|
31
|
+
// Try finding mapping at user's level
|
|
32
|
+
let workflowLevelMapping = await this.workflowLevelMappingRepo.findOne({
|
|
33
|
+
where: {
|
|
34
|
+
mapped_level_type: loggedInUser.level_type,
|
|
35
|
+
mapped_level_id: loggedInUser.level_id,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
console.log('Workflow Level Mapping:', workflowLevelMapping);
|
|
40
|
+
|
|
41
|
+
// If not found, fallback to organization-level mapping
|
|
42
|
+
if (!workflowLevelMapping) {
|
|
43
|
+
workflowLevelMapping = await this.workflowLevelMappingRepo.findOne({
|
|
44
|
+
where: {
|
|
45
|
+
mapped_level_type: 'ORG',
|
|
46
|
+
mapped_level_id: String(loggedInUser.organization_id),
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
console.log('Fallback Workflow Level Mapping:', workflowLevelMapping);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// If still not found, return null
|
|
53
|
+
if (!workflowLevelMapping) return null;
|
|
54
|
+
|
|
30
55
|
return await this.stageGroupRepository.getAllStageGroupAndStageHierarchy(
|
|
31
|
-
workflow_id,
|
|
32
|
-
organization_id,
|
|
56
|
+
workflowLevelMapping.workflow_id,
|
|
57
|
+
loggedInUser.organization_id,
|
|
33
58
|
);
|
|
34
59
|
}
|
|
35
60
|
|