rez_core 2.1.139 → 2.1.141
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/comm-template.controller.d.ts +11 -0
- package/dist/module/workflow/controller/comm-template.controller.js +44 -0
- package/dist/module/workflow/controller/comm-template.controller.js.map +1 -0
- package/dist/module/workflow/controller/stage-group.controller.d.ts +8 -2
- package/dist/module/workflow/controller/stage-group.controller.js +17 -5
- package/dist/module/workflow/controller/stage-group.controller.js.map +1 -1
- package/dist/module/workflow/controller/stage.controller.d.ts +13 -0
- package/dist/module/workflow/controller/stage.controller.js +56 -0
- package/dist/module/workflow/controller/stage.controller.js.map +1 -0
- package/dist/module/workflow/controller/workflow.controller.d.ts +11 -1
- package/dist/module/workflow/controller/workflow.controller.js +13 -0
- package/dist/module/workflow/controller/workflow.controller.js.map +1 -1
- package/dist/module/workflow/entity/action.entity.d.ts +4 -1
- package/dist/module/workflow/entity/action.entity.js +20 -8
- package/dist/module/workflow/entity/action.entity.js.map +1 -1
- package/dist/module/workflow/entity/stage-group.entity.d.ts +1 -1
- package/dist/module/workflow/entity/stage-group.entity.js +1 -1
- package/dist/module/workflow/entity/stage-group.entity.js.map +1 -1
- package/dist/module/workflow/entity/stage.entity.d.ts +1 -2
- package/dist/module/workflow/entity/stage.entity.js +1 -5
- package/dist/module/workflow/entity/stage.entity.js.map +1 -1
- package/dist/module/workflow/repository/comm-template.repository.d.ts +7 -0
- package/dist/module/workflow/repository/comm-template.repository.js +39 -0
- package/dist/module/workflow/repository/comm-template.repository.js.map +1 -0
- package/dist/module/workflow/repository/stage-group.repository.d.ts +7 -0
- package/dist/module/workflow/repository/stage-group.repository.js +50 -0
- package/dist/module/workflow/repository/stage-group.repository.js.map +1 -0
- package/dist/module/workflow/repository/stage.repository.d.ts +7 -0
- package/dist/module/workflow/repository/stage.repository.js +50 -0
- package/dist/module/workflow/repository/stage.repository.js.map +1 -0
- package/dist/module/workflow/service/action.service.d.ts +3 -0
- package/dist/module/workflow/service/action.service.js +46 -7
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/module/workflow/service/comm-template.service.d.ts +8 -2
- package/dist/module/workflow/service/comm-template.service.js +18 -3
- package/dist/module/workflow/service/comm-template.service.js.map +1 -1
- package/dist/module/workflow/service/stage-group.service.d.ts +11 -0
- package/dist/module/workflow/service/stage-group.service.js +36 -1
- package/dist/module/workflow/service/stage-group.service.js.map +1 -1
- package/dist/module/workflow/service/stage.service.d.ts +14 -4
- package/dist/module/workflow/service/stage.service.js +57 -13
- package/dist/module/workflow/service/stage.service.js.map +1 -1
- package/dist/module/workflow/service/workflow.service.d.ts +15 -1
- package/dist/module/workflow/service/workflow.service.js +43 -2
- package/dist/module/workflow/service/workflow.service.js.map +1 -1
- package/dist/module/workflow/workflow.module.js +17 -2
- package/dist/module/workflow/workflow.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/workflow/controller/comm-template.controller.ts +31 -0
- package/src/module/workflow/controller/stage-group.controller.ts +27 -4
- package/src/module/workflow/controller/stage.controller.ts +50 -0
- package/src/module/workflow/controller/workflow.controller.ts +7 -1
- package/src/module/workflow/entity/action.entity.ts +10 -1
- package/src/module/workflow/entity/stage-group.entity.ts +1 -1
- package/src/module/workflow/entity/stage.entity.ts +1 -4
- package/src/module/workflow/repository/comm-template.repository.ts +22 -0
- package/src/module/workflow/repository/stage-group.repository.ts +46 -0
- package/src/module/workflow/repository/stage.repository.ts +47 -0
- package/src/module/workflow/service/action.service.ts +106 -14
- package/src/module/workflow/service/comm-template.service.ts +21 -2
- package/src/module/workflow/service/stage-group.service.ts +66 -2
- package/src/module/workflow/service/stage.service.ts +104 -28
- package/src/module/workflow/service/workflow.service.ts +70 -0
- package/src/module/workflow/workflow.module.ts +17 -2
package/package.json
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Controller,
|
|
3
|
+
Get,
|
|
4
|
+
HttpCode,
|
|
5
|
+
HttpStatus,
|
|
6
|
+
Query,
|
|
7
|
+
Req,
|
|
8
|
+
UseGuards,
|
|
9
|
+
} from '@nestjs/common';
|
|
10
|
+
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
11
|
+
import { CommTemplateService } from '../service/comm-template.service';
|
|
12
|
+
|
|
13
|
+
@Controller('/templates')
|
|
14
|
+
@UseGuards(JwtAuthGuard)
|
|
15
|
+
export class CommTemplateController {
|
|
16
|
+
constructor(private readonly commTemplateService: CommTemplateService) {}
|
|
17
|
+
|
|
18
|
+
@Get('/get-comm-template')
|
|
19
|
+
@HttpCode(HttpStatus.OK)
|
|
20
|
+
async getTemplate(
|
|
21
|
+
@Req() req: Request & { user: any },
|
|
22
|
+
@Query('entity_type') entityType?: string,
|
|
23
|
+
) {
|
|
24
|
+
const loggedInUser = req.user.userData;
|
|
25
|
+
const result = this.commTemplateService.getAllCommTemplate(
|
|
26
|
+
entityType || '',
|
|
27
|
+
loggedInUser,
|
|
28
|
+
);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,10 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
Controller,
|
|
4
|
+
Get,
|
|
5
|
+
Inject,
|
|
6
|
+
Post,
|
|
7
|
+
Req,
|
|
8
|
+
UseGuards,
|
|
9
|
+
} from '@nestjs/common';
|
|
2
10
|
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
11
|
+
import { StageGroupService } from '../service/stage-group.service';
|
|
3
12
|
|
|
4
13
|
@Controller('/stage-group')
|
|
5
14
|
@UseGuards(JwtAuthGuard)
|
|
6
15
|
export class StageGroupController {
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
9
|
-
|
|
16
|
+
constructor(
|
|
17
|
+
@Inject('StageGroupService')
|
|
18
|
+
private readonly stageGroupService: StageGroupService,
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
@Post('/getAllStageGroup')
|
|
22
|
+
async getAllStageGroup(
|
|
23
|
+
@Req() req: Request & { user: any },
|
|
24
|
+
@Body() body: { workflow_id: number },
|
|
25
|
+
) {
|
|
26
|
+
const { level_id, level_type } = req.user.userData;
|
|
27
|
+
return this.stageGroupService.getAllStageGroup(
|
|
28
|
+
body.workflow_id,
|
|
29
|
+
level_id,
|
|
30
|
+
level_type,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
10
33
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
Controller,
|
|
4
|
+
Get,
|
|
5
|
+
HttpCode,
|
|
6
|
+
HttpStatus,
|
|
7
|
+
Inject,
|
|
8
|
+
Post,
|
|
9
|
+
Req,
|
|
10
|
+
UseGuards,
|
|
11
|
+
} from '@nestjs/common';
|
|
12
|
+
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
13
|
+
import { StageService } from '../service/stage.service';
|
|
14
|
+
import { level } from 'winston';
|
|
15
|
+
|
|
16
|
+
@Controller('/stage')
|
|
17
|
+
@UseGuards(JwtAuthGuard)
|
|
18
|
+
export class StageController {
|
|
19
|
+
constructor(
|
|
20
|
+
@Inject('StageService')
|
|
21
|
+
private readonly stageGroupService: StageService,
|
|
22
|
+
) {}
|
|
23
|
+
|
|
24
|
+
@Post('/getAllStage')
|
|
25
|
+
async getAllStage(
|
|
26
|
+
@Req() req: Request & { user: any },
|
|
27
|
+
@Body() body: { stage_group_id: number },
|
|
28
|
+
) {
|
|
29
|
+
const { level_id, level_type } = req.user.userData;
|
|
30
|
+
return this.stageGroupService.getAllStage(
|
|
31
|
+
body.stage_group_id,
|
|
32
|
+
level_id,
|
|
33
|
+
level_type,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Post('/getStagesWithGroupName')
|
|
38
|
+
@HttpCode(HttpStatus.OK)
|
|
39
|
+
async getStagesWithGroupName(
|
|
40
|
+
@Body('workflow_id') workflow_id: number,
|
|
41
|
+
@Req() req: Request & { user: any },
|
|
42
|
+
) {
|
|
43
|
+
const { level_id, level_type } = req.user.userData;
|
|
44
|
+
return this.stageGroupService.getStagesWithGroupName(
|
|
45
|
+
workflow_id,
|
|
46
|
+
level_id,
|
|
47
|
+
level_type,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
} from '@nestjs/common';
|
|
15
15
|
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
16
16
|
import { WorkflowService } from '../service/workflow.service';
|
|
17
|
-
import { Request } from 'express';
|
|
18
17
|
|
|
19
18
|
@Controller('/workflow')
|
|
20
19
|
@UseGuards(JwtAuthGuard)
|
|
@@ -49,4 +48,11 @@ export class WorkflowController {
|
|
|
49
48
|
async deleteWorkflow(@Param('id') id: number) {
|
|
50
49
|
return this.workflowService.deleteWorkflowById(id);
|
|
51
50
|
}
|
|
51
|
+
|
|
52
|
+
@Put('/updateSequence')
|
|
53
|
+
@HttpCode(HttpStatus.OK)
|
|
54
|
+
async updateSequence(@Body() body: any, @Req() req: Request & { user: any }) {
|
|
55
|
+
const loggedInUser = req.user?.userData;
|
|
56
|
+
return this.workflowService.updateSequence(body, loggedInUser);
|
|
57
|
+
}
|
|
52
58
|
}
|
|
@@ -3,7 +3,7 @@ import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
|
3
3
|
import { Column, Entity } from 'typeorm';
|
|
4
4
|
|
|
5
5
|
@Entity({ name: 'cr_wf_action' })
|
|
6
|
-
export class
|
|
6
|
+
export class ActionEntity extends BaseEntity {
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
9
9
|
this.entity_type = ACTION;
|
|
@@ -17,4 +17,13 @@ export class Action extends BaseEntity {
|
|
|
17
17
|
|
|
18
18
|
@Column({ type: 'varchar', nullable: true })
|
|
19
19
|
action_requirement: string;
|
|
20
|
+
|
|
21
|
+
@Column({ type: 'varchar', nullable: true })
|
|
22
|
+
reason_code: string;
|
|
23
|
+
|
|
24
|
+
@Column({ type: 'varchar', nullable: true })
|
|
25
|
+
default_reason_code: string;
|
|
26
|
+
|
|
27
|
+
@Column({ default: 0, type: 'boolean' })
|
|
28
|
+
default_value: boolean;
|
|
20
29
|
}
|
|
@@ -12,9 +12,6 @@ export class Stage extends BaseEntity {
|
|
|
12
12
|
@Column({ type: 'int', nullable: true })
|
|
13
13
|
stage_group_id: number;
|
|
14
14
|
|
|
15
|
-
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
16
|
-
full_name: string;
|
|
17
|
-
|
|
18
15
|
@Column({ type: 'int', nullable: true })
|
|
19
|
-
|
|
16
|
+
sequence: number;
|
|
20
17
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
2
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
+
import { Workflow } from '../entity/workflow.entity';
|
|
4
|
+
import { Repository } from 'typeorm';
|
|
5
|
+
import { CommTemplate } from '../entity/comm-template.entity';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class CommTemplateRepository {
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectRepository(CommTemplate)
|
|
11
|
+
private readonly commTemplateRepository: Repository<CommTemplate>,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
async getAllCommTemplate(entity_type: string, loggedInUser) {
|
|
15
|
+
return this.commTemplateRepository.find({
|
|
16
|
+
select: ['name', 'code'],
|
|
17
|
+
where: {
|
|
18
|
+
entity_type: entity_type,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BadRequestException,
|
|
3
|
+
Inject,
|
|
4
|
+
Injectable,
|
|
5
|
+
NotFoundException,
|
|
6
|
+
} from '@nestjs/common';
|
|
7
|
+
import { StageGroup } from '../entity/stage-group.entity';
|
|
8
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
9
|
+
import { Repository } from 'typeorm';
|
|
10
|
+
|
|
11
|
+
@Injectable()
|
|
12
|
+
export class StageGroupRepository {
|
|
13
|
+
constructor(
|
|
14
|
+
@InjectRepository(StageGroup)
|
|
15
|
+
private readonly stageGroupRepository: Repository<StageGroup>,
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
async getAllStageGroup(
|
|
19
|
+
workflow_id: number,
|
|
20
|
+
level_id: string,
|
|
21
|
+
level_type: string,
|
|
22
|
+
) {
|
|
23
|
+
if (!workflow_id) {
|
|
24
|
+
throw new BadRequestException('workflow_id is required');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const result = await this.stageGroupRepository.find({
|
|
28
|
+
where: {
|
|
29
|
+
workflow_id,
|
|
30
|
+
level_id,
|
|
31
|
+
level_type,
|
|
32
|
+
},
|
|
33
|
+
order: {
|
|
34
|
+
sequence: 'ASC',
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (!result || result.length === 0) {
|
|
39
|
+
throw new NotFoundException(
|
|
40
|
+
'No stage groups found for the given workflow ID',
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BadRequestException,
|
|
3
|
+
Inject,
|
|
4
|
+
Injectable,
|
|
5
|
+
NotFoundException,
|
|
6
|
+
} from '@nestjs/common';
|
|
7
|
+
import { StageGroup } from '../entity/stage-group.entity';
|
|
8
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
9
|
+
import { Repository } from 'typeorm';
|
|
10
|
+
import { Stage } from '../entity/stage.entity';
|
|
11
|
+
|
|
12
|
+
@Injectable()
|
|
13
|
+
export class StageRepository {
|
|
14
|
+
constructor(
|
|
15
|
+
@InjectRepository(Stage)
|
|
16
|
+
private readonly stageRepository: Repository<Stage>,
|
|
17
|
+
) {}
|
|
18
|
+
|
|
19
|
+
async getAllStage(
|
|
20
|
+
stage_group_id: number,
|
|
21
|
+
level_id: string,
|
|
22
|
+
level_type: string,
|
|
23
|
+
) {
|
|
24
|
+
if (!stage_group_id) {
|
|
25
|
+
throw new BadRequestException('stage_group_id is required');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const result = await this.stageRepository.find({
|
|
29
|
+
where: {
|
|
30
|
+
stage_group_id,
|
|
31
|
+
level_id,
|
|
32
|
+
level_type,
|
|
33
|
+
},
|
|
34
|
+
order: {
|
|
35
|
+
sequence: 'ASC',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (!result || result.length === 0) {
|
|
40
|
+
throw new NotFoundException(
|
|
41
|
+
'No stage found for the given stage group ID',
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -3,6 +3,7 @@ import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
|
3
3
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
4
4
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
5
5
|
import { DataSource, EntityManager } from 'typeorm';
|
|
6
|
+
import { ActionEntity } from '../entity/action.entity';
|
|
6
7
|
|
|
7
8
|
@Injectable()
|
|
8
9
|
export class ActionService extends EntityServiceImpl {
|
|
@@ -10,6 +11,26 @@ export class ActionService extends EntityServiceImpl {
|
|
|
10
11
|
super();
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
async getEntityData(
|
|
15
|
+
entityType: string,
|
|
16
|
+
id: number,
|
|
17
|
+
loggedInUser,
|
|
18
|
+
): Promise<any> {
|
|
19
|
+
const actionData = await super.getEntityData(entityType, id, loggedInUser);
|
|
20
|
+
|
|
21
|
+
if (!actionData) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const template = await this.dataSource.query(
|
|
26
|
+
`SELECT template_code FROM cr_wf_action_template_mapping WHERE stg_act_mapping_id =
|
|
27
|
+
(SELECT id FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type = 'STGM')`,
|
|
28
|
+
[actionData.id],
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return { ...actionData, template: template.map((t) => t.template_code) };
|
|
32
|
+
}
|
|
33
|
+
|
|
13
34
|
async createEntity(
|
|
14
35
|
entityData: BaseEntity,
|
|
15
36
|
loggedInUser: UserData | null,
|
|
@@ -27,6 +48,7 @@ export class ActionService extends EntityServiceImpl {
|
|
|
27
48
|
appcode,
|
|
28
49
|
);
|
|
29
50
|
|
|
51
|
+
// stage mapping
|
|
30
52
|
let stageActionMapping = {
|
|
31
53
|
action_id: action.id,
|
|
32
54
|
stage_id: actionData.stage_id,
|
|
@@ -44,20 +66,7 @@ export class ActionService extends EntityServiceImpl {
|
|
|
44
66
|
const templates = actionData.template;
|
|
45
67
|
|
|
46
68
|
for (let i = 0; i < templates.length; i++) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
// Fetch the template code from `cr_wf_comm_template`
|
|
50
|
-
const templateResult = await this.dataSource.query(
|
|
51
|
-
`SELECT code FROM cr_wf_comm_template WHERE id = ?`,
|
|
52
|
-
[templateId],
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
if (templateResult.length === 0) {
|
|
56
|
-
console.warn(`Template not found for id: ${templateId}`);
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const templateCode = templateResult[0].code;
|
|
69
|
+
const templateCode = templates[i];
|
|
61
70
|
|
|
62
71
|
// Create Action-Template Mapping
|
|
63
72
|
const actionTemplateMapping = {
|
|
@@ -77,4 +86,87 @@ export class ActionService extends EntityServiceImpl {
|
|
|
77
86
|
|
|
78
87
|
return actionData;
|
|
79
88
|
}
|
|
89
|
+
|
|
90
|
+
async updateEntity(
|
|
91
|
+
entityData: BaseEntity,
|
|
92
|
+
loggedInUser: UserData,
|
|
93
|
+
): Promise<any> {
|
|
94
|
+
console.log('entityData', entityData);
|
|
95
|
+
|
|
96
|
+
// Extract template from entityData, keep the rest for ActionEntity
|
|
97
|
+
const { template, stage_id, ...actionData } = entityData as ActionEntity & {
|
|
98
|
+
template?: number[];
|
|
99
|
+
stage_id?: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Pass only actionData (without template) to super.updateEntity
|
|
103
|
+
let action = await super.updateEntity(actionData, loggedInUser);
|
|
104
|
+
|
|
105
|
+
if (!action) {
|
|
106
|
+
throw new Error('Action not found or could not be updated');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const stageMapID = await this.dataSource.query(
|
|
110
|
+
`SELECT id FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type = 'STGM'`,
|
|
111
|
+
[action.id],
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
// stage mapping
|
|
115
|
+
let stageActionMapping = {
|
|
116
|
+
action_id: action.id,
|
|
117
|
+
stage_id: stage_id,
|
|
118
|
+
entity_type: 'STGM',
|
|
119
|
+
id: stageMapID.length > 0 ? stageMapID[0].id : null,
|
|
120
|
+
} as any;
|
|
121
|
+
|
|
122
|
+
let stageActionMappingData = await super.updateEntity(
|
|
123
|
+
stageActionMapping,
|
|
124
|
+
loggedInUser,
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
// Handle template mapping (using the extracted template)
|
|
128
|
+
if (Array.isArray(template) && template.length > 0) {
|
|
129
|
+
for (let i = 0; i < template.length; i++) {
|
|
130
|
+
const templateCode = template[i];
|
|
131
|
+
|
|
132
|
+
// delete existing template mappings for this action
|
|
133
|
+
await this.dataSource.query(
|
|
134
|
+
`DELETE FROM cr_wf_action_template_mapping WHERE stg_act_mapping_id = ? AND template_code = ?`,
|
|
135
|
+
[stageActionMappingData.id, templateCode],
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
// Create Action-Template Mapping
|
|
139
|
+
const actionTemplateMapping = {
|
|
140
|
+
stg_act_mapping_id: stageActionMappingData.id,
|
|
141
|
+
template_code: templateCode,
|
|
142
|
+
entity_type: 'ATMP',
|
|
143
|
+
} as any;
|
|
144
|
+
|
|
145
|
+
await super.createEntity(actionTemplateMapping, loggedInUser);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return action; // Return the action entity instead of actionData
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async deleteEntity(
|
|
153
|
+
entityType: string,
|
|
154
|
+
id: number,
|
|
155
|
+
loggedInUser: UserData,
|
|
156
|
+
): Promise<any> {
|
|
157
|
+
await this.dataSource.query(
|
|
158
|
+
`DELETE FROM cr_wf_action_template_mapping WHERE stg_act_mapping_id IN (SELECT
|
|
159
|
+
id FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type = 'STGM')`,
|
|
160
|
+
[id],
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
await this.dataSource.query(
|
|
164
|
+
`DELETE FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type ='STGM'`,
|
|
165
|
+
[id],
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
const deleteAction = await super.deleteEntity(entityType, id, loggedInUser);
|
|
169
|
+
|
|
170
|
+
return deleteAction;
|
|
171
|
+
}
|
|
80
172
|
}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import {
|
|
2
|
+
import { CommTemplateRepository } from '../repository/comm-template.repository';
|
|
3
3
|
|
|
4
4
|
@Injectable()
|
|
5
|
-
export class CommTemplateService
|
|
5
|
+
export class CommTemplateService {
|
|
6
|
+
constructor(
|
|
7
|
+
private readonly commTemplateRepository: CommTemplateRepository,
|
|
8
|
+
) {}
|
|
9
|
+
|
|
10
|
+
async getAllCommTemplate(entity_type: string, loggedInUser) {
|
|
11
|
+
const commTemplateData =
|
|
12
|
+
await this.commTemplateRepository.getAllCommTemplate(
|
|
13
|
+
entity_type,
|
|
14
|
+
loggedInUser,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const response = commTemplateData.map((item) => ({
|
|
18
|
+
label: item.name,
|
|
19
|
+
value: item.code,
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
return response;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,5 +1,69 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
3
|
+
import { StageGroupRepository } from '../repository/stage-group.repository';
|
|
4
|
+
import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
5
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
6
|
+
import { StageService } from './stage.service';
|
|
3
7
|
|
|
4
8
|
@Injectable()
|
|
5
|
-
export class StageGroupService extends EntityServiceImpl {
|
|
9
|
+
export class StageGroupService extends EntityServiceImpl {
|
|
10
|
+
constructor(
|
|
11
|
+
private readonly stageGroupRepository: StageGroupRepository,
|
|
12
|
+
@Inject('StageService')
|
|
13
|
+
private readonly stageService: StageService,
|
|
14
|
+
) {
|
|
15
|
+
super();
|
|
16
|
+
}
|
|
17
|
+
async getAllStageGroup(
|
|
18
|
+
workflow_id: number,
|
|
19
|
+
level_id: string,
|
|
20
|
+
level_type: string,
|
|
21
|
+
) {
|
|
22
|
+
return await this.stageGroupRepository.getAllStageGroup(
|
|
23
|
+
workflow_id,
|
|
24
|
+
level_id,
|
|
25
|
+
level_type,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async updateEntity(
|
|
30
|
+
entityData: BaseEntity,
|
|
31
|
+
loggedInUser: UserData,
|
|
32
|
+
): Promise<any> {
|
|
33
|
+
return await super.updateEntity(entityData, loggedInUser);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async getEntityData(
|
|
37
|
+
entityType: string,
|
|
38
|
+
id: number,
|
|
39
|
+
loggedInUser?: UserData,
|
|
40
|
+
): Promise<BaseEntity | null> {
|
|
41
|
+
return await super.getEntityData(entityType, id, loggedInUser);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async deleteEntity(
|
|
45
|
+
entityType: string,
|
|
46
|
+
id: number,
|
|
47
|
+
loggedInUser: UserData,
|
|
48
|
+
): Promise<any> {
|
|
49
|
+
const getAllStage = await this.stageService.getAllStage(
|
|
50
|
+
id,
|
|
51
|
+
loggedInUser.level_id,
|
|
52
|
+
loggedInUser.level_type,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
if (getAllStage.length > 0) {
|
|
56
|
+
for (const stage of getAllStage) {
|
|
57
|
+
await this.stageService.deleteEntity('STG', stage.id, loggedInUser);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const deleteStageGroup = await super.deleteEntity(
|
|
62
|
+
entityType,
|
|
63
|
+
id,
|
|
64
|
+
loggedInUser,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return deleteStageGroup;
|
|
68
|
+
}
|
|
69
|
+
}
|