rez_core 2.1.131 → 2.1.133
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/layout_preference/controller/layout_preference.controller.js +2 -2
- package/dist/module/layout_preference/controller/layout_preference.controller.js.map +1 -1
- package/dist/module/layout_preference/service/layout_preference.service.js +7 -0
- package/dist/module/layout_preference/service/layout_preference.service.js.map +1 -1
- package/dist/module/meta/service/entity-validation.service.js +1 -1
- package/dist/module/meta/service/entity-validation.service.js.map +1 -1
- package/dist/module/workflow/controller/workflow.controller.d.ts +16 -0
- package/dist/module/workflow/controller/workflow.controller.js +66 -0
- package/dist/module/workflow/controller/workflow.controller.js.map +1 -0
- package/dist/module/workflow/service/action-template-mapping.service.js +7 -5
- package/dist/module/workflow/service/action-template-mapping.service.js.map +1 -1
- package/dist/module/workflow/service/workflow.service.d.ts +9 -3
- package/dist/module/workflow/service/workflow.service.js +57 -5
- package/dist/module/workflow/service/workflow.service.js.map +1 -1
- package/dist/module/workflow/workflow.module.js +7 -3
- 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/layout_preference/controller/layout_preference.controller.ts +2 -2
- package/src/module/layout_preference/service/layout_preference.service.ts +7 -0
- package/src/module/meta/service/entity-validation.service.ts +1 -1
- package/src/module/workflow/controller/workflow.controller.ts +47 -0
- package/src/module/workflow/service/action-template-mapping.service.ts +8 -5
- package/src/module/workflow/service/workflow.service.ts +76 -5
- package/src/module/workflow/workflow.module.ts +7 -3
package/package.json
CHANGED
|
@@ -31,13 +31,13 @@ export class LayoutPreferenceController {
|
|
|
31
31
|
@Query('sort_by') sort_by: string,
|
|
32
32
|
@Req() req: Request & { user: any },
|
|
33
33
|
) {
|
|
34
|
-
const
|
|
34
|
+
const loggedInUser = req.user.userData;
|
|
35
35
|
|
|
36
36
|
return this.layoutPreferenceService.getColumnValue(
|
|
37
37
|
entity_type,
|
|
38
38
|
column,
|
|
39
39
|
sort_by,
|
|
40
|
-
|
|
40
|
+
loggedInUser,
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -77,6 +77,13 @@ export class LayoutPreferenceService extends EntityServiceImpl {
|
|
|
77
77
|
.addSelect(`COUNT(*) AS count`)
|
|
78
78
|
.from(tableName, tableName)
|
|
79
79
|
.where(`${column} IS NOT NULL`)
|
|
80
|
+
.andWhere(`organization_id = :organizationId`, {
|
|
81
|
+
organizationId: loggedInUser?.organization_id,
|
|
82
|
+
})
|
|
83
|
+
.andWhere(`level_id = :levelId`, { levelId: loggedInUser?.level_id })
|
|
84
|
+
.andWhere(`level_type = :levelType`, {
|
|
85
|
+
levelType: loggedInUser?.level_type,
|
|
86
|
+
})
|
|
80
87
|
.groupBy(column)
|
|
81
88
|
.getRawMany();
|
|
82
89
|
|
|
@@ -135,7 +135,7 @@ export class EntityValidationService {
|
|
|
135
135
|
const attributes =
|
|
136
136
|
await this.attributeMasterService.findAttributesByMappedEntityType(
|
|
137
137
|
entityData.entity_type,
|
|
138
|
-
loggedInUser
|
|
138
|
+
loggedInUser,
|
|
139
139
|
);
|
|
140
140
|
|
|
141
141
|
const requiredErrors = this.validateRequiredFields(entityData, attributes);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Controller,
|
|
3
|
+
Post,
|
|
4
|
+
Body,
|
|
5
|
+
HttpCode,
|
|
6
|
+
HttpStatus,
|
|
7
|
+
Req,
|
|
8
|
+
UseGuards,
|
|
9
|
+
Get,
|
|
10
|
+
Param,
|
|
11
|
+
Put,
|
|
12
|
+
} from '@nestjs/common';
|
|
13
|
+
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
14
|
+
import { WorkflowService } from '../service/workflow.service';
|
|
15
|
+
import { Request } from 'express';
|
|
16
|
+
|
|
17
|
+
@Controller('/workflow')
|
|
18
|
+
@UseGuards(JwtAuthGuard)
|
|
19
|
+
export class WorkflowController {
|
|
20
|
+
constructor(private readonly workflowService: WorkflowService) {}
|
|
21
|
+
|
|
22
|
+
@Post('/getWorkflow')
|
|
23
|
+
@HttpCode(HttpStatus.OK)
|
|
24
|
+
async getWorkflow(
|
|
25
|
+
@Body() body: { entity_type: string },
|
|
26
|
+
@Req() req: Request & { user: any },
|
|
27
|
+
) {
|
|
28
|
+
const loggedInUser = req.user.userData;
|
|
29
|
+
const result = await this.workflowService.getAllWorkflow(
|
|
30
|
+
body.entity_type,
|
|
31
|
+
loggedInUser,
|
|
32
|
+
);
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Get('/getWorkflowById/:id')
|
|
37
|
+
@HttpCode(HttpStatus.OK)
|
|
38
|
+
async getWorkflowById(@Param('id') id: number) {
|
|
39
|
+
return this.workflowService.getWorkflowById(id);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Post('/getContactDropdown')
|
|
43
|
+
@HttpCode(HttpStatus.OK)
|
|
44
|
+
async getLeadContactDropdown(@Body() body: { leadId: number; mode: string }) {
|
|
45
|
+
return this.workflowService.getLeadContactDropdown(body.leadId, body.mode);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -36,17 +36,20 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
|
|
|
36
36
|
[mode],
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
+
if (!listMasterItemData?.length) return []; // 🛑 No mode found
|
|
40
|
+
|
|
39
41
|
const templateCodes = templates.map((t) => t.template_code);
|
|
40
42
|
if (!templateCodes.length) return [];
|
|
41
43
|
|
|
42
44
|
const commTemplates = await this.dataSource.query(
|
|
43
45
|
`
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
SELECT id, name
|
|
47
|
+
FROM cr_wf_comm_template
|
|
48
|
+
WHERE code IN (?) AND mode = ? AND organization_id = ?
|
|
49
|
+
`,
|
|
48
50
|
[templateCodes, listMasterItemData[0].code, loggedInUser.organization_id],
|
|
49
51
|
);
|
|
50
|
-
|
|
52
|
+
|
|
53
|
+
return commTemplates;
|
|
51
54
|
}
|
|
52
55
|
}
|
|
@@ -1,9 +1,80 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import {
|
|
1
|
+
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
3
|
+
import { BaseEntity, DataSource } from 'typeorm';
|
|
3
4
|
|
|
4
5
|
@Injectable()
|
|
5
|
-
export class WorkflowService
|
|
6
|
-
constructor() {
|
|
7
|
-
|
|
6
|
+
export class WorkflowService {
|
|
7
|
+
constructor(private readonly dataSource: DataSource) {}
|
|
8
|
+
|
|
9
|
+
async getAllWorkflow(entity_type: string, loggedInUser: any) {
|
|
10
|
+
const { level_id, level_type } = loggedInUser;
|
|
11
|
+
|
|
12
|
+
const workflows = await this.dataSource.query(
|
|
13
|
+
`
|
|
14
|
+
SELECT *
|
|
15
|
+
FROM cr_workflow
|
|
16
|
+
WHERE mapped_entity_type = ?
|
|
17
|
+
AND level_id = ?
|
|
18
|
+
AND level_type = ?
|
|
19
|
+
`,
|
|
20
|
+
[entity_type, level_id, level_type],
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return workflows; // array of rows (each row is already in JSON format)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async getWorkflowById(id: number) {
|
|
27
|
+
const result = await this.dataSource.query(
|
|
28
|
+
`SELECT * FROM cr_workflow WHERE id = ?`,
|
|
29
|
+
[id],
|
|
30
|
+
);
|
|
31
|
+
return result[0] || null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async updateEntity(
|
|
35
|
+
entityData: BaseEntity,
|
|
36
|
+
loggedInUser: UserData,
|
|
37
|
+
): Promise<any> {}
|
|
38
|
+
|
|
39
|
+
async getLeadContactDropdown(leadId: number, mode: string): Promise<any[]> {
|
|
40
|
+
const lead = await this.dataSource.query(
|
|
41
|
+
`SELECT phone_number, father_mobile, mother_mobile, email, father_email, mother_email
|
|
42
|
+
FROM crm_lead
|
|
43
|
+
WHERE id = ?`,
|
|
44
|
+
[leadId],
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if (!lead?.length) {
|
|
48
|
+
throw new BadRequestException('Lead not found');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const data = lead[0];
|
|
52
|
+
const response: { label: string; value: any }[] = [];
|
|
53
|
+
|
|
54
|
+
if (mode === 'sms' || mode === 'whatsapp') {
|
|
55
|
+
if (data.phone_number) {
|
|
56
|
+
response.push({ label: 'Primary', value: data.phone_number });
|
|
57
|
+
}
|
|
58
|
+
if (data.father_mobile) {
|
|
59
|
+
response.push({ label: 'Father', value: data.father_mobile });
|
|
60
|
+
}
|
|
61
|
+
if (data.mother_mobile) {
|
|
62
|
+
response.push({ label: 'Mother', value: data.mother_mobile });
|
|
63
|
+
}
|
|
64
|
+
} else if (mode === 'email') {
|
|
65
|
+
if (data.email) {
|
|
66
|
+
response.push({ label: 'Primary', value: data.email });
|
|
67
|
+
}
|
|
68
|
+
if (data.father_email) {
|
|
69
|
+
response.push({ label: 'Father', value: data.father_email });
|
|
70
|
+
}
|
|
71
|
+
if (data.mother_email) {
|
|
72
|
+
response.push({ label: 'Mother', value: data.mother_email });
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
throw new BadRequestException('Invalid mode');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return response;
|
|
8
79
|
}
|
|
9
80
|
}
|
|
@@ -20,6 +20,7 @@ import { Action } from './entity/action.entity';
|
|
|
20
20
|
import { WorkflowListMasterService } from './service/workflow-list-master.service';
|
|
21
21
|
import { WorkflowListMasterController } from './controller/workflow-list-master.controller';
|
|
22
22
|
import { ActionTemplateMappingController } from './controller/action-template-mapping.controller';
|
|
23
|
+
import { WorkflowController } from './controller/workflow.controller';
|
|
23
24
|
|
|
24
25
|
@Module({
|
|
25
26
|
imports: [
|
|
@@ -36,7 +37,6 @@ import { ActionTemplateMappingController } from './controller/action-template-ma
|
|
|
36
37
|
EntityModule,
|
|
37
38
|
],
|
|
38
39
|
providers: [
|
|
39
|
-
{ provide: 'WorkflowService', useClass: WorkflowService },
|
|
40
40
|
{ provide: 'ActionCategoryService', useClass: ActionCategoryService },
|
|
41
41
|
{ provide: 'CommTemplateService', useClass: CommTemplateService },
|
|
42
42
|
{
|
|
@@ -48,9 +48,9 @@ import { ActionTemplateMappingController } from './controller/action-template-ma
|
|
|
48
48
|
{ provide: 'StageGroupService', useClass: StageGroupService },
|
|
49
49
|
WorkflowListMasterService,
|
|
50
50
|
ActionTemplateMappingService,
|
|
51
|
+
WorkflowService,
|
|
51
52
|
],
|
|
52
53
|
exports: [
|
|
53
|
-
'WorkflowService',
|
|
54
54
|
'ActionCategoryService',
|
|
55
55
|
'CommTemplateService',
|
|
56
56
|
'StageActionMappingService',
|
|
@@ -58,6 +58,10 @@ import { ActionTemplateMappingController } from './controller/action-template-ma
|
|
|
58
58
|
'StageService',
|
|
59
59
|
'StageGroupService',
|
|
60
60
|
],
|
|
61
|
-
controllers: [
|
|
61
|
+
controllers: [
|
|
62
|
+
WorkflowListMasterController,
|
|
63
|
+
ActionTemplateMappingController,
|
|
64
|
+
WorkflowController,
|
|
65
|
+
],
|
|
62
66
|
})
|
|
63
67
|
export class WorkflowModule {}
|