rez_core 2.2.7 → 2.2.9
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 -1
- package/dist/constant/global.constant.js +3 -2
- package/dist/constant/global.constant.js.map +1 -1
- package/dist/module/enterprise/repository/school.repository.js +18 -2
- package/dist/module/enterprise/repository/school.repository.js.map +1 -1
- package/dist/module/filter/controller/filter.controller.d.ts +1 -1
- package/dist/module/filter/controller/filter.controller.js +7 -4
- package/dist/module/filter/controller/filter.controller.js.map +1 -1
- package/dist/module/filter/dto/filter-request.dto.d.ts +1 -0
- package/dist/module/filter/service/filter.service.js +26 -4
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/layout_preference/controller/layout_preference.controller.js +4 -4
- package/dist/module/layout_preference/controller/layout_preference.controller.js.map +1 -1
- package/dist/module/layout_preference/entity/layout_preference.entity.d.ts +2 -0
- package/dist/module/layout_preference/entity/layout_preference.entity.js +13 -0
- package/dist/module/layout_preference/entity/layout_preference.entity.js.map +1 -1
- package/dist/module/layout_preference/repository/layout_preference.repository.d.ts +1 -1
- package/dist/module/layout_preference/repository/layout_preference.repository.js +4 -2
- package/dist/module/layout_preference/repository/layout_preference.repository.js.map +1 -1
- package/dist/module/layout_preference/service/layout_preference.service.d.ts +1 -1
- package/dist/module/layout_preference/service/layout_preference.service.js +17 -4
- package/dist/module/layout_preference/service/layout_preference.service.js.map +1 -1
- package/dist/module/listmaster/entity/list-master-items.entity.js +5 -5
- package/dist/module/listmaster/entity/list-master-items.entity.js.map +1 -1
- package/dist/module/meta/controller/media.controller.d.ts +1 -1
- package/dist/module/meta/controller/media.controller.js +1 -1
- package/dist/module/meta/controller/media.controller.js.map +1 -1
- package/dist/module/meta/entity/base-entity.entity.js.map +1 -1
- package/dist/module/module/controller/module-access.controller.d.ts +1 -1
- package/dist/module/module/controller/module-access.controller.js +6 -6
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/service/module-access.service.d.ts +2 -1
- package/dist/module/module/service/module-access.service.js +5 -3
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/workflow/controller/action-category.controller.d.ts +8 -0
- package/dist/module/workflow/controller/action-category.controller.js +45 -0
- package/dist/module/workflow/controller/action-category.controller.js.map +1 -0
- package/dist/module/workflow/controller/action.controller.d.ts +28 -0
- package/dist/module/workflow/controller/action.controller.js +88 -0
- package/dist/module/workflow/controller/action.controller.js.map +1 -0
- 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/entity-modification.controller.d.ts +8 -0
- package/dist/module/workflow/controller/entity-modification.controller.js +44 -0
- package/dist/module/workflow/controller/entity-modification.controller.js.map +1 -0
- package/dist/module/workflow/controller/stage-group.controller.d.ts +10 -0
- package/dist/module/workflow/controller/stage-group.controller.js +43 -0
- package/dist/module/workflow/controller/stage-group.controller.js.map +1 -0
- 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/task.controller.d.ts +21 -0
- package/dist/module/workflow/controller/task.controller.js +58 -0
- package/dist/module/workflow/controller/task.controller.js.map +1 -0
- package/dist/module/workflow/controller/workflow-meta.controller.d.ts +15 -0
- package/dist/module/workflow/controller/workflow-meta.controller.js +70 -0
- package/dist/module/workflow/controller/workflow-meta.controller.js.map +1 -0
- package/dist/module/workflow/controller/workflow.controller.d.ts +25 -10
- package/dist/module/workflow/controller/workflow.controller.js +32 -15
- package/dist/module/workflow/controller/workflow.controller.js.map +1 -1
- package/dist/module/workflow/entity/action-category.entity.d.ts +1 -0
- package/dist/module/workflow/entity/action-category.entity.js +4 -0
- package/dist/module/workflow/entity/action-category.entity.js.map +1 -1
- package/dist/module/workflow/entity/action-data.entity.d.ts +15 -0
- package/dist/module/workflow/entity/action-data.entity.js +70 -0
- package/dist/module/workflow/entity/action-data.entity.js.map +1 -0
- package/dist/module/workflow/entity/action.entity.d.ts +7 -2
- package/dist/module/workflow/entity/action.entity.js +30 -10
- package/dist/module/workflow/entity/action.entity.js.map +1 -1
- package/dist/module/workflow/entity/comm-template.entity.d.ts +5 -0
- package/dist/module/workflow/entity/comm-template.entity.js +21 -1
- package/dist/module/workflow/entity/comm-template.entity.js.map +1 -1
- package/dist/module/workflow/entity/entity-modification.entity.d.ts +13 -0
- package/dist/module/workflow/entity/entity-modification.entity.js +63 -0
- package/dist/module/workflow/entity/entity-modification.entity.js.map +1 -0
- 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-movement-data.entity.d.ts +4 -0
- package/dist/module/workflow/entity/stage-movement-data.entity.js +16 -0
- package/dist/module/workflow/entity/stage-movement-data.entity.js.map +1 -1
- package/dist/module/workflow/entity/stage.entity.d.ts +2 -2
- package/dist/module/workflow/entity/stage.entity.js +5 -5
- package/dist/module/workflow/entity/stage.entity.js.map +1 -1
- package/dist/module/workflow/entity/task-data.entity.d.ts +25 -0
- package/dist/module/workflow/entity/task-data.entity.js +110 -0
- package/dist/module/workflow/entity/task-data.entity.js.map +1 -0
- package/dist/module/workflow/entity/template-attach-mapper.entity.d.ts +11 -0
- package/dist/module/workflow/entity/template-attach-mapper.entity.js +54 -0
- package/dist/module/workflow/entity/template-attach-mapper.entity.js.map +1 -0
- package/dist/module/workflow/entity/workflow-level-mapping.entity.d.ts +7 -0
- package/dist/module/workflow/entity/workflow-level-mapping.entity.js +38 -0
- package/dist/module/workflow/entity/workflow-level-mapping.entity.js.map +1 -0
- package/dist/module/workflow/entity/workflow.entity.d.ts +2 -0
- package/dist/module/workflow/entity/workflow.entity.js +8 -0
- package/dist/module/workflow/entity/workflow.entity.js.map +1 -1
- package/dist/module/workflow/repository/action-data.repository.d.ts +10 -0
- package/dist/module/workflow/repository/action-data.repository.js +85 -0
- package/dist/module/workflow/repository/action-data.repository.js.map +1 -0
- package/dist/module/workflow/repository/action.repository.d.ts +17 -0
- package/dist/module/workflow/repository/action.repository.js +97 -0
- package/dist/module/workflow/repository/action.repository.js.map +1 -0
- package/dist/module/workflow/repository/comm-template.repository.d.ts +14 -0
- package/dist/module/workflow/repository/comm-template.repository.js +87 -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-movement.repository.d.ts +23 -0
- package/dist/module/workflow/repository/stage-movement.repository.js +142 -0
- package/dist/module/workflow/repository/stage-movement.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/repository/task.repository.d.ts +10 -0
- package/dist/module/workflow/repository/task.repository.js +77 -0
- package/dist/module/workflow/repository/task.repository.js.map +1 -0
- package/dist/module/workflow/repository/workflow.repository.d.ts +9 -1
- package/dist/module/workflow/repository/workflow.repository.js +38 -6
- package/dist/module/workflow/repository/workflow.repository.js.map +1 -1
- package/dist/module/workflow/service/action-category.service.d.ts +5 -0
- package/dist/module/workflow/service/action-category.service.js +23 -1
- package/dist/module/workflow/service/action-category.service.js.map +1 -1
- package/dist/module/workflow/service/action-data.service.d.ts +11 -0
- package/dist/module/workflow/service/action-data.service.js +36 -0
- package/dist/module/workflow/service/action-data.service.js.map +1 -0
- package/dist/module/workflow/service/action.service.d.ts +19 -1
- package/dist/module/workflow/service/action.service.js +159 -10
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/module/workflow/service/comm-template.service.d.ts +11 -0
- package/dist/module/workflow/service/comm-template.service.js +59 -1
- package/dist/module/workflow/service/comm-template.service.js.map +1 -1
- package/dist/module/workflow/service/entity-modification.service.d.ts +8 -0
- package/dist/module/workflow/service/entity-modification.service.js +52 -0
- package/dist/module/workflow/service/entity-modification.service.js.map +1 -0
- package/dist/module/workflow/service/populate-workflow.service.d.ts +21 -0
- package/dist/module/workflow/service/populate-workflow.service.js +124 -0
- package/dist/module/workflow/service/populate-workflow.service.js.map +1 -0
- package/dist/module/workflow/service/stage-group.service.d.ts +13 -0
- package/dist/module/workflow/service/stage-group.service.js +39 -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/task.service.d.ts +18 -0
- package/dist/module/workflow/service/task.service.js +63 -0
- package/dist/module/workflow/service/task.service.js.map +1 -0
- package/dist/module/workflow/service/workflow-list-master.service.js +4 -4
- package/dist/module/workflow/service/workflow-meta.service.d.ts +20 -0
- package/dist/module/workflow/service/workflow-meta.service.js +137 -0
- package/dist/module/workflow/service/workflow-meta.service.js.map +1 -0
- package/dist/module/workflow/service/workflow.service.d.ts +28 -5
- package/dist/module/workflow/service/workflow.service.js +108 -41
- package/dist/module/workflow/service/workflow.service.js.map +1 -1
- package/dist/module/workflow/workflow.module.js +82 -15
- package/dist/module/workflow/workflow.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/constant/global.constant.ts +3 -1
- package/src/module/enterprise/repository/school.repository.ts +23 -2
- package/src/module/filter/controller/filter.controller.ts +10 -4
- package/src/module/filter/dto/filter-request.dto.ts +1 -0
- package/src/module/filter/service/filter.service.ts +39 -5
- package/src/module/layout_preference/controller/layout_preference.controller.ts +6 -4
- package/src/module/layout_preference/entity/layout_preference.entity.ts +11 -0
- package/src/module/layout_preference/repository/layout_preference.repository.ts +6 -2
- package/src/module/layout_preference/service/layout_preference.service.ts +31 -6
- package/src/module/listmaster/entity/list-master-items.entity.ts +5 -5
- package/src/module/meta/controller/media.controller.ts +5 -7
- package/src/module/meta/entity/base-entity.entity.ts +1 -1
- package/src/module/module/controller/module-access.controller.ts +9 -4
- package/src/module/module/service/module-access.service.ts +15 -8
- package/src/module/workflow/controller/action-category.controller.ts +35 -0
- package/src/module/workflow/controller/action.controller.ts +73 -0
- package/src/module/workflow/controller/comm-template.controller.ts +32 -0
- package/src/module/workflow/controller/entity-modification.controller.ts +35 -0
- package/src/module/workflow/controller/stage-group.controller.ts +33 -0
- package/src/module/workflow/controller/stage.controller.ts +50 -0
- package/src/module/workflow/controller/task.controller.ts +57 -0
- package/src/module/workflow/controller/workflow-meta.controller.ts +76 -0
- package/src/module/workflow/controller/workflow.controller.ts +32 -12
- package/src/module/workflow/entity/action-category.entity.ts +3 -0
- package/src/module/workflow/entity/action-data.entity.ts +43 -0
- package/src/module/workflow/entity/action.entity.ts +18 -3
- package/src/module/workflow/entity/comm-template.entity.ts +18 -1
- package/src/module/workflow/entity/entity-modification.entity.ts +38 -0
- package/src/module/workflow/entity/stage-group.entity.ts +1 -1
- package/src/module/workflow/entity/stage-movement-data.entity.ts +12 -0
- package/src/module/workflow/entity/stage.entity.ts +4 -4
- package/src/module/workflow/entity/task-data.entity.ts +73 -0
- package/src/module/workflow/entity/template-attach-mapper.entity.ts +30 -0
- package/src/module/workflow/entity/workflow-level-mapping.entity.ts +18 -0
- package/src/module/workflow/entity/workflow.entity.ts +6 -0
- package/src/module/workflow/repository/action-data.repository.ts +93 -0
- package/src/module/workflow/repository/action.repository.ts +104 -0
- package/src/module/workflow/repository/comm-template.repository.ts +102 -0
- package/src/module/workflow/repository/stage-group.repository.ts +46 -0
- package/src/module/workflow/repository/stage-movement.repository.ts +219 -0
- package/src/module/workflow/repository/stage.repository.ts +47 -0
- package/src/module/workflow/repository/task.repository.ts +85 -0
- package/src/module/workflow/repository/workflow.repository.ts +40 -2
- package/src/module/workflow/service/action-category.service.ts +26 -1
- package/src/module/workflow/service/action-data.service.ts +45 -0
- package/src/module/workflow/service/action-template-mapping.service.ts +1 -1
- package/src/module/workflow/service/action.service.ts +279 -19
- package/src/module/workflow/service/comm-template.service.ts +90 -1
- package/src/module/workflow/service/entity-modification.service.ts +67 -0
- package/src/module/workflow/service/populate-workflow.service.ts +189 -0
- package/src/module/workflow/service/stage-group.service.ts +67 -2
- package/src/module/workflow/service/stage.service.ts +104 -28
- package/src/module/workflow/service/task.service.ts +95 -0
- package/src/module/workflow/service/workflow-list-master.service.ts +4 -4
- package/src/module/workflow/service/workflow-meta.service.ts +231 -0
- package/src/module/workflow/service/workflow.service.ts +181 -50
- package/src/module/workflow/workflow.module.ts +82 -15
|
@@ -1,4 +1,42 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
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';
|
|
2
5
|
|
|
3
6
|
@Injectable()
|
|
4
|
-
export class
|
|
7
|
+
export class WorkflowRepository {
|
|
8
|
+
constructor(
|
|
9
|
+
@InjectRepository(Workflow)
|
|
10
|
+
private readonly workflowRepository: Repository<Workflow>,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
// async getWorkflowById(id: number) {
|
|
14
|
+
// return this.workflowRepository.findOne(id);
|
|
15
|
+
// }
|
|
16
|
+
|
|
17
|
+
async getAllWorkflowsByFilters(
|
|
18
|
+
entity_type: string,
|
|
19
|
+
level_id: string,
|
|
20
|
+
level_type: string,
|
|
21
|
+
): Promise<Workflow[]> {
|
|
22
|
+
return this.workflowRepository.find({
|
|
23
|
+
where: {
|
|
24
|
+
mapped_entity_type: entity_type,
|
|
25
|
+
level_id,
|
|
26
|
+
level_type,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async deleteWorkflowById(id: number) {
|
|
32
|
+
const result = await this.workflowRepository.delete(id);
|
|
33
|
+
|
|
34
|
+
if (result.affected === 0) {
|
|
35
|
+
throw new NotFoundException(`Workflow with ID ${id} not found`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
message: `Workflow has been successfully deleted.`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
3
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
4
|
+
import { DataSource } from 'typeorm';
|
|
3
5
|
|
|
4
6
|
@Injectable()
|
|
5
|
-
export class ActionCategoryService extends EntityServiceImpl {
|
|
7
|
+
export class ActionCategoryService extends EntityServiceImpl {
|
|
8
|
+
constructor(private readonly dataSource: DataSource) {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async getActionsCat(loggedInUser: UserData, entity_type: string) {
|
|
13
|
+
const { organization_id } = loggedInUser;
|
|
14
|
+
|
|
15
|
+
const result = await this.dataSource.query(
|
|
16
|
+
`
|
|
17
|
+
SELECT id, name
|
|
18
|
+
FROM cr_wf_action_category
|
|
19
|
+
WHERE mapped_entity_type = ?
|
|
20
|
+
AND organization_id = ?
|
|
21
|
+
`,
|
|
22
|
+
[entity_type, organization_id],
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return result.map((row: any) => ({
|
|
26
|
+
label: row.name,
|
|
27
|
+
value: row.id,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
3
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
4
|
+
import { DataSource } from 'typeorm';
|
|
5
|
+
import { ActionDataRepository } from '../repository/action-data.repository';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class ActionDataService extends EntityServiceImpl {
|
|
9
|
+
constructor(
|
|
10
|
+
private readonly dataSource: DataSource,
|
|
11
|
+
private readonly actionDataRepo: ActionDataRepository,
|
|
12
|
+
) {
|
|
13
|
+
super();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async saveActionData(
|
|
17
|
+
action: any,
|
|
18
|
+
loggedInUser: UserData,
|
|
19
|
+
mapped_entity_id,
|
|
20
|
+
mapped_entity_type,
|
|
21
|
+
): Promise<any> {
|
|
22
|
+
return this.actionDataRepo.saveActionData(
|
|
23
|
+
action,
|
|
24
|
+
loggedInUser,
|
|
25
|
+
mapped_entity_id,
|
|
26
|
+
mapped_entity_type,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async updateActionStatus(
|
|
31
|
+
loggedInUser: UserData,
|
|
32
|
+
mapped_entity_type: string,
|
|
33
|
+
mapped_entity_id: number,
|
|
34
|
+
stage_id: number,
|
|
35
|
+
action_id: number,
|
|
36
|
+
): Promise<any> {
|
|
37
|
+
return this.actionDataRepo.updateActionStatus(
|
|
38
|
+
loggedInUser,
|
|
39
|
+
mapped_entity_type,
|
|
40
|
+
mapped_entity_id,
|
|
41
|
+
stage_id,
|
|
42
|
+
action_id,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -36,7 +36,7 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
|
|
|
36
36
|
[mode],
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
-
if (!listMasterItemData?.length) return [];
|
|
39
|
+
if (!listMasterItemData?.length) return [];
|
|
40
40
|
|
|
41
41
|
const templateCodes = templates.map((t) => t.template_code);
|
|
42
42
|
if (!templateCodes.length) return [];
|
|
@@ -1,23 +1,46 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
2
|
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
|
-
import { DataSource, EntityManager } from 'typeorm';
|
|
5
|
+
import { DataSource, EntityManager, Repository } from 'typeorm';
|
|
6
|
+
import { ActionRepository } from '../repository/action.repository';
|
|
7
|
+
import { ActionEntity } from '../entity/action.entity';
|
|
6
8
|
|
|
7
9
|
@Injectable()
|
|
8
10
|
export class ActionService extends EntityServiceImpl {
|
|
9
|
-
constructor(
|
|
11
|
+
constructor(
|
|
12
|
+
private readonly dataSource: DataSource,
|
|
13
|
+
private readonly actionRepository: ActionRepository,
|
|
14
|
+
) {
|
|
10
15
|
super();
|
|
11
16
|
}
|
|
12
17
|
|
|
18
|
+
async getEntityData(
|
|
19
|
+
entityType: string,
|
|
20
|
+
id: number,
|
|
21
|
+
loggedInUser,
|
|
22
|
+
): Promise<any> {
|
|
23
|
+
const actionData = await super.getEntityData(entityType, id, loggedInUser);
|
|
24
|
+
|
|
25
|
+
if (!actionData) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const template = await this.dataSource.query(
|
|
30
|
+
`SELECT template_code FROM cr_wf_action_template_mapping WHERE stg_act_mapping_id =
|
|
31
|
+
(SELECT id FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type = 'STGM')`,
|
|
32
|
+
[actionData.id],
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return { ...actionData, template: template.map((t) => t.template_code) };
|
|
36
|
+
}
|
|
37
|
+
|
|
13
38
|
async createEntity(
|
|
14
39
|
entityData: BaseEntity,
|
|
15
40
|
loggedInUser: UserData | null,
|
|
16
41
|
manager?: EntityManager | null,
|
|
17
42
|
appcode?: string,
|
|
18
43
|
): Promise<any> {
|
|
19
|
-
console.log('entityData', entityData);
|
|
20
|
-
|
|
21
44
|
let actionData = entityData as any;
|
|
22
45
|
|
|
23
46
|
let action = await super.createEntity(
|
|
@@ -27,6 +50,7 @@ export class ActionService extends EntityServiceImpl {
|
|
|
27
50
|
appcode,
|
|
28
51
|
);
|
|
29
52
|
|
|
53
|
+
// stage mapping
|
|
30
54
|
let stageActionMapping = {
|
|
31
55
|
action_id: action.id,
|
|
32
56
|
stage_id: actionData.stage_id,
|
|
@@ -40,24 +64,12 @@ export class ActionService extends EntityServiceImpl {
|
|
|
40
64
|
appcode,
|
|
41
65
|
);
|
|
42
66
|
|
|
67
|
+
// template mapping
|
|
43
68
|
if (Array.isArray(actionData.template) && actionData.template.length > 0) {
|
|
44
69
|
const templates = actionData.template;
|
|
45
70
|
|
|
46
71
|
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;
|
|
72
|
+
const templateCode = templates[i];
|
|
61
73
|
|
|
62
74
|
// Create Action-Template Mapping
|
|
63
75
|
const actionTemplateMapping = {
|
|
@@ -77,4 +89,252 @@ export class ActionService extends EntityServiceImpl {
|
|
|
77
89
|
|
|
78
90
|
return actionData;
|
|
79
91
|
}
|
|
92
|
+
|
|
93
|
+
async updateEntity(
|
|
94
|
+
entityData: BaseEntity,
|
|
95
|
+
loggedInUser: UserData,
|
|
96
|
+
): Promise<any> {
|
|
97
|
+
console.log('entityData', entityData);
|
|
98
|
+
|
|
99
|
+
// Extract template from entityData, keep the rest for ActionEntity
|
|
100
|
+
const { template, stage_id, ...actionData } = entityData as ActionEntity & {
|
|
101
|
+
template?: number[];
|
|
102
|
+
stage_id?: string;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Pass only actionData (without template) to super.updateEntity
|
|
106
|
+
let action = await super.updateEntity({ ...actionData }, loggedInUser);
|
|
107
|
+
|
|
108
|
+
if (!action) {
|
|
109
|
+
throw new Error('Action not found or could not be updated');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const stageMapID = await this.dataSource.query(
|
|
113
|
+
`SELECT id FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type = 'STGM'`,
|
|
114
|
+
[action.id],
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
// stage mapping
|
|
118
|
+
let stageActionMapping = {
|
|
119
|
+
action_id: action.id,
|
|
120
|
+
stage_id: stage_id,
|
|
121
|
+
entity_type: 'STGM',
|
|
122
|
+
id: stageMapID.length > 0 ? stageMapID[0].id : null,
|
|
123
|
+
} as any;
|
|
124
|
+
|
|
125
|
+
let stageActionMappingData = await super.updateEntity(
|
|
126
|
+
stageActionMapping,
|
|
127
|
+
loggedInUser,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
// delete existing template mappings for this action
|
|
131
|
+
await this.dataSource.query(
|
|
132
|
+
`DELETE FROM cr_wf_action_template_mapping WHERE stg_act_mapping_id = ?`,
|
|
133
|
+
[stageActionMappingData.id],
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
// Handle template mapping (using the extracted template)
|
|
137
|
+
if (Array.isArray(template) && template.length > 0) {
|
|
138
|
+
for (let i = 0; i < template.length; i++) {
|
|
139
|
+
const templateCode = template[i];
|
|
140
|
+
|
|
141
|
+
// Create Action-Template Mapping
|
|
142
|
+
const actionTemplateMapping = {
|
|
143
|
+
stg_act_mapping_id: stageActionMappingData.id,
|
|
144
|
+
template_code: templateCode,
|
|
145
|
+
entity_type: 'ATMP',
|
|
146
|
+
} as any;
|
|
147
|
+
|
|
148
|
+
await super.createEntity(actionTemplateMapping, loggedInUser);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return action; // Return the action entity instead of actionData
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async deleteEntity(
|
|
156
|
+
entityType: string,
|
|
157
|
+
id: number,
|
|
158
|
+
loggedInUser: UserData,
|
|
159
|
+
): Promise<any> {
|
|
160
|
+
await this.dataSource.query(
|
|
161
|
+
`DELETE FROM cr_wf_action_template_mapping WHERE stg_act_mapping_id IN (SELECT
|
|
162
|
+
id FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type = 'STGM')`,
|
|
163
|
+
[id],
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
await this.dataSource.query(
|
|
167
|
+
`DELETE FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type ='STGM'`,
|
|
168
|
+
[id],
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const deleteAction = await super.deleteEntity(entityType, id, loggedInUser);
|
|
172
|
+
|
|
173
|
+
return deleteAction;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async getReasonCode(loggedInUser: UserData): Promise<any> {
|
|
177
|
+
const { organization_id } = loggedInUser;
|
|
178
|
+
const result = await this.dataSource.query(
|
|
179
|
+
`
|
|
180
|
+
SELECT name, type
|
|
181
|
+
FROM cr_list_master
|
|
182
|
+
WHERE organization_id = ? AND source = 'master'
|
|
183
|
+
`,
|
|
184
|
+
[organization_id],
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const formatted = result.map((item: any) => ({
|
|
188
|
+
label: item.name,
|
|
189
|
+
value: item.type,
|
|
190
|
+
}));
|
|
191
|
+
|
|
192
|
+
return formatted;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async defaultReasonCode(list_type: string, loggedInUser: UserData) {
|
|
196
|
+
const { organization_id } = loggedInUser;
|
|
197
|
+
if (!list_type) {
|
|
198
|
+
throw new BadRequestException('list_type is required');
|
|
199
|
+
}
|
|
200
|
+
const result = await this.dataSource.query(
|
|
201
|
+
`
|
|
202
|
+
SELECT name, id
|
|
203
|
+
FROM cr_list_master_items
|
|
204
|
+
WHERE listtype = ? AND organization_id = ?
|
|
205
|
+
`,
|
|
206
|
+
[list_type, organization_id],
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
// Format as array of key-value pairs
|
|
210
|
+
return result.map((row: any) => ({
|
|
211
|
+
label: row.name,
|
|
212
|
+
value: row.id,
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async getActions(loggedInUser: UserData, stage_id: number) {
|
|
217
|
+
const { organization_id } = loggedInUser;
|
|
218
|
+
|
|
219
|
+
// Step 1: Get all action_ids for the provided stage_id
|
|
220
|
+
const stageActions = await this.dataSource.query(
|
|
221
|
+
`
|
|
222
|
+
SELECT id, action_id
|
|
223
|
+
FROM cr_wf_stage_action_mapping
|
|
224
|
+
WHERE stage_id = ?
|
|
225
|
+
`,
|
|
226
|
+
[stage_id],
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
if (!stageActions?.length) return [];
|
|
230
|
+
|
|
231
|
+
const actionIds = stageActions.map((sa) => sa.action_id);
|
|
232
|
+
const mappingIds = stageActions.map((sa) => sa.id);
|
|
233
|
+
|
|
234
|
+
// Step 2: Get template codes with mapping IDs
|
|
235
|
+
const templateMappings = await this.dataSource.query(
|
|
236
|
+
`
|
|
237
|
+
SELECT stg_act_mapping_id, template_code
|
|
238
|
+
FROM cr_wf_action_template_mapping
|
|
239
|
+
WHERE stg_act_mapping_id IN (${mappingIds.map(() => '?').join(',')})
|
|
240
|
+
`,
|
|
241
|
+
mappingIds,
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
const templateCodes = templateMappings.map((tm) => tm.template_code);
|
|
245
|
+
|
|
246
|
+
// Step 3: Fetch template names from cr_wf_comm_template
|
|
247
|
+
const templateCodeToName: Record<string, string> = {};
|
|
248
|
+
|
|
249
|
+
if (templateCodes.length > 0) {
|
|
250
|
+
const templates = await this.dataSource
|
|
251
|
+
.createQueryBuilder()
|
|
252
|
+
.select(['t.code AS code', 't.name AS name'])
|
|
253
|
+
.from('cr_wf_comm_template', 't')
|
|
254
|
+
.where('t.code IN (:...codes)', { codes: templateCodes })
|
|
255
|
+
.andWhere('t.organization_id = :orgId', { orgId: organization_id })
|
|
256
|
+
.getRawMany();
|
|
257
|
+
|
|
258
|
+
templates.forEach((tpl) => {
|
|
259
|
+
templateCodeToName[tpl.code] = tpl.name;
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Step 4: Build map of mapping_id → template names
|
|
264
|
+
const mappingIdToTemplates: Record<number, string[]> = {};
|
|
265
|
+
|
|
266
|
+
for (const tm of templateMappings) {
|
|
267
|
+
const mappingId = tm.stg_act_mapping_id;
|
|
268
|
+
const name = templateCodeToName[tm.template_code];
|
|
269
|
+
if (name) {
|
|
270
|
+
if (!mappingIdToTemplates[mappingId]) {
|
|
271
|
+
mappingIdToTemplates[mappingId] = [];
|
|
272
|
+
}
|
|
273
|
+
mappingIdToTemplates[mappingId].push(name);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Step 5: Build action_id → template names using mappingIdToTemplates + stageActions
|
|
278
|
+
const actionIdToTemplates: Record<number, string[]> = {};
|
|
279
|
+
|
|
280
|
+
for (const sa of stageActions) {
|
|
281
|
+
const mappingId = sa.id;
|
|
282
|
+
const templates = mappingIdToTemplates[mappingId];
|
|
283
|
+
if (templates?.length) {
|
|
284
|
+
if (!actionIdToTemplates[sa.action_id]) {
|
|
285
|
+
actionIdToTemplates[sa.action_id] = [];
|
|
286
|
+
}
|
|
287
|
+
actionIdToTemplates[sa.action_id].push(...templates);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Step 6: Fetch action details
|
|
292
|
+
const actionResults = await this.dataSource
|
|
293
|
+
.createQueryBuilder()
|
|
294
|
+
.select([
|
|
295
|
+
'a.*',
|
|
296
|
+
'ac.name AS action_category',
|
|
297
|
+
'ar.name AS action_requirement',
|
|
298
|
+
])
|
|
299
|
+
.from('cr_wf_action', 'a')
|
|
300
|
+
.leftJoin('cr_wf_action_category', 'ac', 'ac.id = a.action_category')
|
|
301
|
+
.leftJoin(
|
|
302
|
+
'cr_list_master_items',
|
|
303
|
+
'ar',
|
|
304
|
+
`ar.id = a.action_requirement AND ar.listtype = 'ACRQ' AND ar.organization_id = :orgId`,
|
|
305
|
+
{ orgId: organization_id },
|
|
306
|
+
)
|
|
307
|
+
.where('a.organization_id = :orgId', { orgId: organization_id })
|
|
308
|
+
.andWhere('a.id IN (:...actionIds)', { actionIds })
|
|
309
|
+
.getRawMany();
|
|
310
|
+
|
|
311
|
+
// Step 7: Enrich result with template field
|
|
312
|
+
const enrichedResult = actionResults.map((row) => {
|
|
313
|
+
const actionId = Number(row.id); // Ensure numeric ID match
|
|
314
|
+
const templates = actionIdToTemplates[actionId] || [];
|
|
315
|
+
const uniqueTemplates = [...new Set(templates)]; // remove duplicates
|
|
316
|
+
|
|
317
|
+
return {
|
|
318
|
+
...row,
|
|
319
|
+
template: uniqueTemplates.join(', '),
|
|
320
|
+
};
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
return enrichedResult;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
async getAction(
|
|
327
|
+
loggedInUser: UserData,
|
|
328
|
+
stage_id: number,
|
|
329
|
+
mapped_entity_id: number,
|
|
330
|
+
mapped_entity_type: string,
|
|
331
|
+
) {
|
|
332
|
+
const { organization_id } = loggedInUser;
|
|
333
|
+
return this.actionRepository.getAction(
|
|
334
|
+
organization_id,
|
|
335
|
+
stage_id,
|
|
336
|
+
mapped_entity_id,
|
|
337
|
+
mapped_entity_type,
|
|
338
|
+
);
|
|
339
|
+
}
|
|
80
340
|
}
|
|
@@ -1,5 +1,94 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { CommTemplateRepository } from '../repository/comm-template.repository';
|
|
2
3
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
4
|
+
import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
5
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
3
6
|
|
|
4
7
|
@Injectable()
|
|
5
|
-
export class CommTemplateService extends EntityServiceImpl {
|
|
8
|
+
export class CommTemplateService extends EntityServiceImpl {
|
|
9
|
+
constructor(private readonly commTemplateRepository: CommTemplateRepository) {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async createEntity(entityData: any, loggedInUser: any): Promise<any> {
|
|
14
|
+
const { attachments, ...templateData } = entityData;
|
|
15
|
+
|
|
16
|
+
const tempData = await super.createEntity(templateData, loggedInUser);
|
|
17
|
+
|
|
18
|
+
// attachment mapper create and update
|
|
19
|
+
if (attachments && attachments.length > 0) {
|
|
20
|
+
const attachmentEntities = attachments.map((attachment) => ({
|
|
21
|
+
entity_type: templateData.entity_type,
|
|
22
|
+
template_id: tempData.id,
|
|
23
|
+
media_id: attachment,
|
|
24
|
+
organization_id: loggedInUser.organization_id,
|
|
25
|
+
appcode: loggedInUser.appcode,
|
|
26
|
+
level_id: loggedInUser.level_id,
|
|
27
|
+
level_type: loggedInUser.level_type,
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
await this.commTemplateRepository.save(attachmentEntities);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return tempData;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async updateEntity(entityData: any, loggedInUser: UserData): Promise<any> {
|
|
37
|
+
const { attachments, ...templateData } = entityData;
|
|
38
|
+
|
|
39
|
+
const tempData = await super.updateEntity(templateData, loggedInUser);
|
|
40
|
+
|
|
41
|
+
// delete existing mapper
|
|
42
|
+
await this.commTemplateRepository.delete({
|
|
43
|
+
template_id: tempData.id,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// attachment mapper create and update
|
|
47
|
+
if (attachments && attachments.length > 0) {
|
|
48
|
+
const attachmentEntities = attachments.map((attachment) => ({
|
|
49
|
+
entity_type: templateData.entity_type,
|
|
50
|
+
template_id: tempData.id,
|
|
51
|
+
media_id: attachment,
|
|
52
|
+
organization_id: loggedInUser.organization_id,
|
|
53
|
+
appcode: loggedInUser.appcode,
|
|
54
|
+
level_id: loggedInUser.level_id,
|
|
55
|
+
level_type: loggedInUser.level_type,
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
await this.commTemplateRepository.save(attachmentEntities);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return tempData;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async getEntityData(
|
|
65
|
+
entityType: string,
|
|
66
|
+
id: number,
|
|
67
|
+
loggedInUser,
|
|
68
|
+
): Promise<any> {
|
|
69
|
+
//TODO: check if current level_id and levl_type has that code if not go to parent level
|
|
70
|
+
|
|
71
|
+
const getTemplate = await this.commTemplateRepository.getTemplateByCode(
|
|
72
|
+
entityType,
|
|
73
|
+
id,
|
|
74
|
+
loggedInUser,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return getTemplate;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async getAllCommTemplate(entity_type: string, loggedInUser) {
|
|
81
|
+
const commTemplateData =
|
|
82
|
+
await this.commTemplateRepository.getAllCommTemplate(
|
|
83
|
+
entity_type,
|
|
84
|
+
loggedInUser,
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const response = commTemplateData.map((item) => ({
|
|
88
|
+
value: item.code,
|
|
89
|
+
label: item.name,
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
return response;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BadRequestException,
|
|
3
|
+
Injectable,
|
|
4
|
+
NotFoundException,
|
|
5
|
+
} from '@nestjs/common';
|
|
6
|
+
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
7
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
8
|
+
import { DataSource } from 'typeorm';
|
|
9
|
+
|
|
10
|
+
@Injectable()
|
|
11
|
+
export class EntityModificationService extends EntityServiceImpl {
|
|
12
|
+
constructor(private readonly dataSource: DataSource) {
|
|
13
|
+
super();
|
|
14
|
+
}
|
|
15
|
+
async logModification(modificationData: any, loggedInUser: UserData) {
|
|
16
|
+
const { mapped_entity_type, mapped_entity_id, attribute_key } =
|
|
17
|
+
modificationData;
|
|
18
|
+
const { organization_id } = loggedInUser;
|
|
19
|
+
|
|
20
|
+
if (!mapped_entity_type || !mapped_entity_id || !attribute_key) {
|
|
21
|
+
throw new BadRequestException(
|
|
22
|
+
'Missing required modification data: mapped_entity_type, mapped_entity_id, or attribute_key',
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Step 1: Fetch db_table_name from cr_entity_master
|
|
27
|
+
const [entityMeta] = await this.dataSource.query(
|
|
28
|
+
`
|
|
29
|
+
SELECT db_table_name
|
|
30
|
+
FROM cr_entity_master
|
|
31
|
+
WHERE mapped_entity_type = ? AND organization_id = ?
|
|
32
|
+
`,
|
|
33
|
+
[mapped_entity_type, organization_id],
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
if (!entityMeta || !entityMeta.db_table_name) {
|
|
37
|
+
throw new NotFoundException(
|
|
38
|
+
'Entity metadata not found in cr_entity_master',
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const tableName = entityMeta.db_table_name;
|
|
43
|
+
|
|
44
|
+
// Step 2: Get the row from the target table using mapped_entity_id
|
|
45
|
+
const [entityRow] = await this.dataSource.query(
|
|
46
|
+
`
|
|
47
|
+
SELECT * FROM ${tableName} WHERE id = ?
|
|
48
|
+
`,
|
|
49
|
+
[mapped_entity_id],
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
if (!entityRow) {
|
|
53
|
+
throw new NotFoundException(
|
|
54
|
+
`No record found in ${tableName} with ID ${mapped_entity_id}`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Step 3: Extract current value from the target column
|
|
59
|
+
const currentAttributeValue = entityRow[attribute_key];
|
|
60
|
+
|
|
61
|
+
// Step 4: Set current_value in modificationData
|
|
62
|
+
modificationData.current_value = currentAttributeValue;
|
|
63
|
+
|
|
64
|
+
// Step 5: Call super.createEntity with updated modificationData
|
|
65
|
+
return await super.createEntity(modificationData, loggedInUser);
|
|
66
|
+
}
|
|
67
|
+
}
|