rez_core 1.0.42 → 1.0.44
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 -0
- package/dist/constant/global.constant.js +3 -1
- package/dist/constant/global.constant.js.map +1 -1
- package/dist/module/auth/guards/role.guard.js +3 -3
- package/dist/module/listmaster/controller/list-master.controller.js +4 -4
- package/dist/module/listmaster/controller/list-master.controller.js.map +1 -1
- package/dist/module/listmaster/entity/list-master.entity.d.ts +3 -6
- package/dist/module/listmaster/entity/list-master.entity.js +3 -15
- package/dist/module/listmaster/entity/list-master.entity.js.map +1 -1
- package/dist/module/listmaster/listmaster.module.js +2 -0
- package/dist/module/listmaster/listmaster.module.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.js +13 -5
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/master/controller/master.controller.d.ts +1 -1
- package/dist/module/master/controller/master.controller.js +5 -5
- package/dist/module/master/controller/master.controller.js.map +1 -1
- package/dist/module/master/service/master.service.d.ts +3 -8
- package/dist/module/master/service/master.service.js +60 -94
- package/dist/module/master/service/master.service.js.map +1 -1
- package/dist/module/meta/entity/attribute-master.entity.d.ts +1 -0
- package/dist/module/meta/entity/attribute-master.entity.js +5 -1
- package/dist/module/meta/entity/attribute-master.entity.js.map +1 -1
- package/dist/module/meta/entity/entity-master.entity.d.ts +1 -1
- package/dist/module/meta/entity/entity-master.entity.js +1 -1
- package/dist/module/meta/entity/entity-master.entity.js.map +1 -1
- package/dist/module/meta/entity/view-master.entity.d.ts +11 -0
- package/dist/module/meta/entity/view-master.entity.js +55 -0
- package/dist/module/meta/entity/view-master.entity.js.map +1 -0
- package/dist/module/meta/service/view-master.service.d.ts +10 -0
- package/dist/module/meta/service/view-master.service.js +35 -0
- package/dist/module/meta/service/view-master.service.js.map +1 -0
- package/dist/module/module/controller/module-access.controller.d.ts +14 -0
- package/dist/module/module/controller/module-access.controller.js +11 -0
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/repository/module-access.repository.d.ts +15 -0
- package/dist/module/module/repository/module-access.repository.js +66 -12
- package/dist/module/module/repository/module-access.repository.js.map +1 -1
- package/dist/module/module/service/module-access.service.d.ts +14 -0
- package/dist/module/module/service/module-access.service.js +11 -0
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/third-party-module/entity/third-party-api-registry.entity.d.ts +15 -0
- package/dist/module/third-party-module/entity/third-party-api-registry.entity.js +72 -0
- package/dist/module/third-party-module/entity/third-party-api-registry.entity.js.map +1 -0
- package/dist/module/third-party-module/repository/third-party-api-registry.repository.d.ts +7 -0
- package/dist/module/third-party-module/repository/third-party-api-registry.repository.js +38 -0
- package/dist/module/third-party-module/repository/third-party-api-registry.repository.js.map +1 -0
- package/dist/module/third-party-module/service/api-registry.service.d.ts +6 -0
- package/dist/module/third-party-module/service/api-registry.service.js +28 -0
- package/dist/module/third-party-module/service/api-registry.service.js.map +1 -0
- package/dist/module/third-party-module/third-party.module.d.ts +2 -0
- package/dist/module/third-party-module/third-party.module.js +25 -0
- package/dist/module/third-party-module/third-party.module.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -1
- package/src/constant/global.constant.ts +4 -0
- package/src/module/auth/guards/jwt.guard.ts +22 -22
- package/src/module/auth/guards/role.guard.ts +68 -68
- package/src/module/auth/services/jwt.service.ts +11 -11
- package/src/module/auth/strategies/local.strategy.ts +13 -13
- package/src/module/dev/dev.module.ts +12 -12
- package/src/module/dev/service/dev.service.ts +7 -7
- package/src/module/enterprise/entity/enterprise.entity.ts +37 -37
- package/src/module/enterprise/entity/organization.entity.ts +80 -80
- package/src/module/listmaster/controller/list-master.controller.ts +3 -3
- package/src/module/listmaster/entity/list-master.entity.ts +3 -12
- package/src/module/listmaster/listmaster.module.ts +2 -0
- package/src/module/listmaster/service/list-master.service.ts +23 -9
- package/src/module/master/controller/master.controller.ts +14 -6
- package/src/module/master/service/master.service.ts +75 -120
- package/src/module/meta/dto/entity-list-data.dto.ts +6 -6
- package/src/module/meta/entity/attribute-master.entity.ts +4 -1
- package/src/module/meta/entity/entity-master.entity.ts +3 -1
- package/src/module/meta/entity/preference.entity.ts +65 -65
- package/src/module/meta/entity/view-master.entity.ts +32 -0
- package/src/module/meta/repository/preference.repository.ts +20 -20
- package/src/module/meta/service/view-master.service.ts +41 -0
- package/src/module/module/controller/menu.controller.ts +15 -15
- package/src/module/module/controller/module-access.controller.ts +26 -10
- package/src/module/module/entity/module-access.entity.ts +22 -22
- package/src/module/module/entity/module-action.entity.ts +19 -19
- package/src/module/module/repository/module-access.repository.ts +95 -36
- package/src/module/module/service/module-access.service.ts +20 -0
- package/src/module/third-party-module/entity/third-party-api-registry.entity.ts +43 -0
- package/src/module/third-party-module/repository/third-party-api-registry.repository.ts +20 -0
- package/src/module/third-party-module/service/api-registry.service.ts +13 -0
- package/src/module/third-party-module/third-party.module.ts +12 -0
- package/src/module/user/controller/user.controller.ts +28 -28
- package/src/module/user/dto/update-user.dto.ts +4 -4
- package/src/module/user/entity/user-role-mapping.entity.ts +21 -21
- package/src/module/user/entity/user-session.entity.ts +61 -61
- package/src/module/user/repository/userSession.repository.ts +33 -33
- package/src/utils/service/encryptUtil.service.ts +97 -97
- package/src/utils/service/excelUtil.service.ts +15 -15
- package/src/utils/service/reflection-helper.service.ts +53 -53
- package/.idea/250218_nodejs_core.iml +0 -12
- package/.idea/codeStyles/Project.xml +0 -59
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/dataSources.xml +0 -12
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -6
- package/.idea/vcs.xml +0 -6
|
@@ -13,14 +13,22 @@ import { Express } from 'express';
|
|
|
13
13
|
export class MasterController {
|
|
14
14
|
constructor(private readonly masterService: MasterService) {}
|
|
15
15
|
|
|
16
|
-
@Post('upload')
|
|
16
|
+
// @Post('upload')
|
|
17
|
+
// @UseInterceptors(FileInterceptor('file'))
|
|
18
|
+
// async uploadFile(@UploadedFile() file) {
|
|
19
|
+
// if (!file) {
|
|
20
|
+
// throw new Error('File is required');
|
|
21
|
+
// }
|
|
22
|
+
// return this.masterService.processExcel(file);
|
|
23
|
+
// }
|
|
24
|
+
|
|
25
|
+
@Post('uploadMasterData')
|
|
17
26
|
@UseInterceptors(FileInterceptor('file'))
|
|
18
|
-
|
|
27
|
+
|
|
28
|
+
async uploadMasterDataXls(@UploadedFile() file: Express.Multer.File) {
|
|
19
29
|
if (!file) {
|
|
20
|
-
throw new
|
|
30
|
+
throw new BadRequestException('File is required');
|
|
21
31
|
}
|
|
22
|
-
return this.masterService.
|
|
32
|
+
return await this.masterService.uploadMasterData(file.buffer);
|
|
23
33
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
34
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { EntityManager } from 'typeorm';
|
|
2
|
+
import { EntityManager, Unique } from 'typeorm';
|
|
3
3
|
import { ExcelUtil } from 'src/utils/service/excelUtil.service';
|
|
4
4
|
import { EntityMasterService } from '../../meta/service/entity-master.service';
|
|
5
|
+
import { table } from 'console';
|
|
5
6
|
|
|
6
7
|
interface ParentEntity {
|
|
7
8
|
id: number;
|
|
8
|
-
code: string;
|
|
9
|
+
code: string;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
@Injectable()
|
|
@@ -17,145 +18,99 @@ export class MasterService {
|
|
|
17
18
|
) {}
|
|
18
19
|
|
|
19
20
|
private readonly metaSheets = [
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
21
|
+
'cr_entity_master',
|
|
22
|
+
'cr_attribute_master',
|
|
23
|
+
'cr_list_master',
|
|
24
|
+
'cr_list_master_items',
|
|
25
|
+
];
|
|
26
|
+
private readonly sequence = [
|
|
27
|
+
{
|
|
28
|
+
table: 'cr_entity_master',
|
|
29
|
+
unique_fields: ['mapped_entity_type'],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
table: 'cr_attribute_master',
|
|
33
|
+
unique_fields: ['mapped_entity_type', 'attribute_key'],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
table: 'cr_list_master',
|
|
37
|
+
unique_fields: ['type'],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
table: 'cr_list_master_items',
|
|
41
|
+
unique_fields: ['listtype', 'code'],
|
|
42
|
+
},
|
|
24
43
|
];
|
|
25
44
|
|
|
26
45
|
private isMetaSheet(sheetName: string): boolean {
|
|
27
46
|
return this.metaSheets.includes(sheetName.toLowerCase());
|
|
28
47
|
}
|
|
29
48
|
|
|
30
|
-
async
|
|
31
|
-
|
|
32
|
-
const data = ExcelUtil.readExcel(file.buffer) as Record<string, Record<string, any>[]>;
|
|
33
|
-
|
|
34
|
-
for (const [sheetName, records] of Object.entries(data)) {
|
|
35
|
-
if (!records.length) continue;
|
|
36
|
-
|
|
37
|
-
const isMeta = this.isMetaSheet(sheetName);
|
|
38
|
-
console.log(`📄 Processing sheet: ${sheetName} | Meta: ${isMeta}`);
|
|
39
|
-
|
|
40
|
-
if (isMeta) {
|
|
41
|
-
await this.upsertData(sheetName, records);
|
|
42
|
-
} else {
|
|
43
|
-
await this.processEntityData(records);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
49
|
+
async uploadMasterData(file) {
|
|
50
|
+
const data = ExcelUtil.readExcel(file.buffer);
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
for (let i = 0; i < this.sequence.length; i++) {
|
|
53
|
+
const { table, unique_fields } = this.sequence[i];
|
|
54
|
+
const sheetData = data[table];
|
|
49
55
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const entityType = row['entity_type'];
|
|
53
|
-
if (!entityType) {
|
|
54
|
-
console.warn('⚠️ Skipping row without entity_type:', row);
|
|
56
|
+
if (!sheetData) {
|
|
57
|
+
console.log(`Sheet ${table} not found in the Excel file.`);
|
|
55
58
|
continue;
|
|
56
59
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const transformed = this.transformRow(row, attrMap);
|
|
61
|
-
|
|
62
|
-
// Resolve parent_id if parent_type and parent_id are present
|
|
63
|
-
if (row['parent_id'] && row['parent_type']) {
|
|
64
|
-
transformed['parent_id'] = await this.resolveParentId(row['parent_type'], row['parent_id']);
|
|
65
|
-
transformed['parent_type'] = row['parent_type'];
|
|
60
|
+
if (this.isMetaSheet(table)) {
|
|
61
|
+
console.log(`Processing sheet: ${table}`);
|
|
62
|
+
await this.upsertData(table, unique_fields, sheetData);
|
|
66
63
|
}
|
|
64
|
+
else{
|
|
67
65
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
private async getEntityMeta(entityType: string): Promise<{ tableName: string; mappedEntityType: string }> {
|
|
73
|
-
const result = await this.entityManager.query(
|
|
74
|
-
`SELECT db_table_name, mapped_entity_type FROM entity_master WHERE mapped_entity_type = ? LIMIT 1`,
|
|
75
|
-
[entityType],
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
if (!result.length || !result[0].db_table_name) {
|
|
79
|
-
throw new Error(`❌ Entity metadata not found for entity_type: ${entityType}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
80
68
|
}
|
|
81
|
-
|
|
82
69
|
return {
|
|
83
|
-
|
|
84
|
-
mappedEntityType: result[0].mapped_entity_type,
|
|
70
|
+
message: 'Data uploaded successfully',
|
|
85
71
|
};
|
|
86
72
|
}
|
|
87
73
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
private async insertEntityRow(tableName: string, data: Record<string, any>): Promise<void> {
|
|
124
|
-
const keys = Object.keys(data);
|
|
125
|
-
if (!keys.length) {
|
|
126
|
-
console.warn('⚠️ Empty data, skipping insert');
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
await this.entityManager
|
|
131
|
-
.createQueryBuilder()
|
|
132
|
-
.insert()
|
|
133
|
-
.into(tableName)
|
|
134
|
-
.values(data)
|
|
135
|
-
.orUpdate({
|
|
136
|
-
overwrite: keys,
|
|
137
|
-
conflict_target: ['code'],
|
|
138
|
-
})
|
|
139
|
-
.execute();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
private async upsertData(tableName: string, records: Record<string, any>[]): Promise<void> {
|
|
143
|
-
if (!records.length) return;
|
|
144
|
-
|
|
145
|
-
const keys = Object.keys(records[0]);
|
|
146
|
-
await this.entityManager.transaction(async (manager) => {
|
|
147
|
-
for (const record of records) {
|
|
148
|
-
await manager
|
|
74
|
+
async upsertData(
|
|
75
|
+
tableName: string,
|
|
76
|
+
uniqueFields: string[],
|
|
77
|
+
data: any[],
|
|
78
|
+
): Promise<void> {
|
|
79
|
+
for (const row of data) {
|
|
80
|
+
const whereClause = uniqueFields
|
|
81
|
+
.map((field) => `${field} = :${field}`)
|
|
82
|
+
.join(' AND ');
|
|
83
|
+
|
|
84
|
+
const whereParams = uniqueFields.reduce((acc, field) => {
|
|
85
|
+
acc[field] = row[field];
|
|
86
|
+
return acc;
|
|
87
|
+
}, {});
|
|
88
|
+
|
|
89
|
+
const existing = await this.entityManager
|
|
90
|
+
.createQueryBuilder()
|
|
91
|
+
.select('*')
|
|
92
|
+
.from(tableName, tableName)
|
|
93
|
+
.where(whereClause, whereParams)
|
|
94
|
+
.limit(1)
|
|
95
|
+
.getRawMany();
|
|
96
|
+
|
|
97
|
+
if (existing.length > 0) {
|
|
98
|
+
// Update
|
|
99
|
+
await this.entityManager
|
|
100
|
+
.createQueryBuilder()
|
|
101
|
+
.update(tableName)
|
|
102
|
+
.set(row)
|
|
103
|
+
.where(whereClause, whereParams)
|
|
104
|
+
.execute();
|
|
105
|
+
} else {
|
|
106
|
+
// Insert
|
|
107
|
+
await this.entityManager
|
|
149
108
|
.createQueryBuilder()
|
|
150
109
|
.insert()
|
|
151
110
|
.into(tableName)
|
|
152
|
-
.values(
|
|
153
|
-
.orUpdate({
|
|
154
|
-
overwrite: keys,
|
|
155
|
-
conflict_target: ['id'],
|
|
156
|
-
})
|
|
111
|
+
.values(row)
|
|
157
112
|
.execute();
|
|
158
113
|
}
|
|
159
|
-
}
|
|
114
|
+
}
|
|
160
115
|
}
|
|
161
116
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EntityTab } from './entity-tab.dto';
|
|
2
|
-
|
|
3
|
-
export class EntityListData {
|
|
4
|
-
entity_list: any;
|
|
5
|
-
entity_tabs: EntityTab[];
|
|
6
|
-
}
|
|
1
|
+
import { EntityTab } from './entity-tab.dto';
|
|
2
|
+
|
|
3
|
+
export class EntityListData {
|
|
4
|
+
entity_list: any;
|
|
5
|
+
entity_tabs: EntityTab[];
|
|
6
|
+
}
|
|
@@ -6,7 +6,7 @@ export class AttributeMaster extends BaseEntity {
|
|
|
6
6
|
@Column({ name: 'mapped_entity_type', type: 'varchar', nullable: true })
|
|
7
7
|
mapped_entity_type: string;
|
|
8
8
|
|
|
9
|
-
@Column({ name: 'mapped_entity_id' })
|
|
9
|
+
@Column({ name: 'mapped_entity_id' ,nullable: true })
|
|
10
10
|
mapped_entity_id: number;
|
|
11
11
|
|
|
12
12
|
@Column({ name: 'element_type', type: 'varchar', nullable: true, length: 50 })
|
|
@@ -64,4 +64,7 @@ export class AttributeMaster extends BaseEntity {
|
|
|
64
64
|
|
|
65
65
|
@Column({ name: 'can_export', nullable: true })
|
|
66
66
|
can_export: number;
|
|
67
|
+
|
|
68
|
+
@Column({ name: 'appcode', nullable: true })
|
|
69
|
+
appcode:string;
|
|
67
70
|
}
|
|
@@ -18,7 +18,7 @@ export class EntityMaster extends BaseEntity {
|
|
|
18
18
|
mapped_entity_type: string;
|
|
19
19
|
|
|
20
20
|
@Column({ name: 'appcode', type: 'varchar', length: 50, nullable: true })
|
|
21
|
-
|
|
21
|
+
appcode: string;
|
|
22
22
|
|
|
23
23
|
@Column({ name: 'category', type: 'varchar', length: 50, nullable: true })
|
|
24
24
|
category: string;
|
|
@@ -60,4 +60,6 @@ export class EntityMaster extends BaseEntity {
|
|
|
60
60
|
|
|
61
61
|
@Column({ name: 'storage_type', nullable: true, length: 20 })
|
|
62
62
|
storage_type: string;
|
|
63
|
+
|
|
64
|
+
|
|
63
65
|
}
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import { BaseEntity } from './base-entity.entity';
|
|
2
|
-
import { Column, Entity } from 'typeorm';
|
|
3
|
-
import { ENTITYTYPE_PREFERENCEMASTER } from '../../../constant/global.constant';
|
|
4
|
-
|
|
5
|
-
@Entity({ name: 'cr_preference_master' })
|
|
6
|
-
export class PreferenceMaster extends BaseEntity {
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
|
-
this.entity_type = ENTITYTYPE_PREFERENCEMASTER;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@Column({ name: 'appcode', type: 'varchar', length: 200, nullable: true })
|
|
13
|
-
appCode: string;
|
|
14
|
-
|
|
15
|
-
@Column({
|
|
16
|
-
name: 'display_name',
|
|
17
|
-
type: 'varchar',
|
|
18
|
-
length: 200,
|
|
19
|
-
nullable: true,
|
|
20
|
-
})
|
|
21
|
-
display_name: string;
|
|
22
|
-
|
|
23
|
-
@Column({
|
|
24
|
-
name: 'preference_key',
|
|
25
|
-
type: 'varchar',
|
|
26
|
-
length: 200,
|
|
27
|
-
nullable: true,
|
|
28
|
-
})
|
|
29
|
-
preference_key: string;
|
|
30
|
-
|
|
31
|
-
@Column({
|
|
32
|
-
name: 'preference_value',
|
|
33
|
-
type: 'varchar',
|
|
34
|
-
length: 200,
|
|
35
|
-
nullable: true,
|
|
36
|
-
})
|
|
37
|
-
preference_value: string;
|
|
38
|
-
|
|
39
|
-
@Column({
|
|
40
|
-
name: 'description',
|
|
41
|
-
type: 'varchar',
|
|
42
|
-
length: 2000,
|
|
43
|
-
nullable: true,
|
|
44
|
-
})
|
|
45
|
-
description: string;
|
|
46
|
-
|
|
47
|
-
@Column({ name: 'reflect_on', type: 'varchar', length: 200, nullable: true })
|
|
48
|
-
reflect_on: string;
|
|
49
|
-
|
|
50
|
-
@Column({
|
|
51
|
-
name: 'default_value',
|
|
52
|
-
type: 'varchar',
|
|
53
|
-
length: 200,
|
|
54
|
-
nullable: true,
|
|
55
|
-
})
|
|
56
|
-
default_value: string;
|
|
57
|
-
|
|
58
|
-
@Column({
|
|
59
|
-
name: 'possible_values',
|
|
60
|
-
type: 'varchar',
|
|
61
|
-
length: 200,
|
|
62
|
-
nullable: true,
|
|
63
|
-
})
|
|
64
|
-
possible_values: string;
|
|
65
|
-
}
|
|
1
|
+
import { BaseEntity } from './base-entity.entity';
|
|
2
|
+
import { Column, Entity } from 'typeorm';
|
|
3
|
+
import { ENTITYTYPE_PREFERENCEMASTER } from '../../../constant/global.constant';
|
|
4
|
+
|
|
5
|
+
@Entity({ name: 'cr_preference_master' })
|
|
6
|
+
export class PreferenceMaster extends BaseEntity {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.entity_type = ENTITYTYPE_PREFERENCEMASTER;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@Column({ name: 'appcode', type: 'varchar', length: 200, nullable: true })
|
|
13
|
+
appCode: string;
|
|
14
|
+
|
|
15
|
+
@Column({
|
|
16
|
+
name: 'display_name',
|
|
17
|
+
type: 'varchar',
|
|
18
|
+
length: 200,
|
|
19
|
+
nullable: true,
|
|
20
|
+
})
|
|
21
|
+
display_name: string;
|
|
22
|
+
|
|
23
|
+
@Column({
|
|
24
|
+
name: 'preference_key',
|
|
25
|
+
type: 'varchar',
|
|
26
|
+
length: 200,
|
|
27
|
+
nullable: true,
|
|
28
|
+
})
|
|
29
|
+
preference_key: string;
|
|
30
|
+
|
|
31
|
+
@Column({
|
|
32
|
+
name: 'preference_value',
|
|
33
|
+
type: 'varchar',
|
|
34
|
+
length: 200,
|
|
35
|
+
nullable: true,
|
|
36
|
+
})
|
|
37
|
+
preference_value: string;
|
|
38
|
+
|
|
39
|
+
@Column({
|
|
40
|
+
name: 'description',
|
|
41
|
+
type: 'varchar',
|
|
42
|
+
length: 2000,
|
|
43
|
+
nullable: true,
|
|
44
|
+
})
|
|
45
|
+
description: string;
|
|
46
|
+
|
|
47
|
+
@Column({ name: 'reflect_on', type: 'varchar', length: 200, nullable: true })
|
|
48
|
+
reflect_on: string;
|
|
49
|
+
|
|
50
|
+
@Column({
|
|
51
|
+
name: 'default_value',
|
|
52
|
+
type: 'varchar',
|
|
53
|
+
length: 200,
|
|
54
|
+
nullable: true,
|
|
55
|
+
})
|
|
56
|
+
default_value: string;
|
|
57
|
+
|
|
58
|
+
@Column({
|
|
59
|
+
name: 'possible_values',
|
|
60
|
+
type: 'varchar',
|
|
61
|
+
length: 200,
|
|
62
|
+
nullable: true,
|
|
63
|
+
})
|
|
64
|
+
possible_values: string;
|
|
65
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseEntity } from './base-entity.entity';
|
|
2
|
+
import { Column, Entity } from 'typeorm';
|
|
3
|
+
import { ENTITYTYPE_VIEWMASTER } from '../../../constant/global.constant';
|
|
4
|
+
|
|
5
|
+
@Entity({ name: 'cr_view_master' })
|
|
6
|
+
export class ViewMaster extends BaseEntity {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.entity_type = ENTITYTYPE_VIEWMASTER;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@Column({ length: 50, nullable: true })
|
|
13
|
+
mapped_entity_type: string;
|
|
14
|
+
|
|
15
|
+
@Column({type: 'varchar', nullable: true})
|
|
16
|
+
section_layout: string;
|
|
17
|
+
|
|
18
|
+
@Column({nullable: true})
|
|
19
|
+
section_information: string;
|
|
20
|
+
|
|
21
|
+
@Column({nullable: true})
|
|
22
|
+
description: string;
|
|
23
|
+
|
|
24
|
+
@Column({type: 'json', nullable: true})
|
|
25
|
+
published_form_layout: string;
|
|
26
|
+
|
|
27
|
+
@Column({type: 'json', nullable: true})
|
|
28
|
+
published_form_fields: string;
|
|
29
|
+
|
|
30
|
+
@Column({type: 'int'})
|
|
31
|
+
is_default: number;
|
|
32
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
-
import { PreferenceMaster } from '../entity/preference.entity';
|
|
4
|
-
import { Repository } from 'typeorm';
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class PreferenceRepository {
|
|
8
|
-
constructor(
|
|
9
|
-
@InjectRepository(PreferenceMaster)
|
|
10
|
-
private readonly preferenceRepository: Repository<PreferenceMaster>,
|
|
11
|
-
) {}
|
|
12
|
-
|
|
13
|
-
async findByPreferenceKey(
|
|
14
|
-
preferenceKey: string,
|
|
15
|
-
): Promise<PreferenceMaster | null> {
|
|
16
|
-
return await this.preferenceRepository.findOne({
|
|
17
|
-
where: { preference_key: preferenceKey },
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
+
import { PreferenceMaster } from '../entity/preference.entity';
|
|
4
|
+
import { Repository } from 'typeorm';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class PreferenceRepository {
|
|
8
|
+
constructor(
|
|
9
|
+
@InjectRepository(PreferenceMaster)
|
|
10
|
+
private readonly preferenceRepository: Repository<PreferenceMaster>,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
async findByPreferenceKey(
|
|
14
|
+
preferenceKey: string,
|
|
15
|
+
): Promise<PreferenceMaster | null> {
|
|
16
|
+
return await this.preferenceRepository.findOne({
|
|
17
|
+
where: { preference_key: preferenceKey },
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { EntityServiceImpl } from './entity-service-impl.service';
|
|
3
|
+
import { BaseEntity } from '../entity/base-entity.entity';
|
|
4
|
+
import { UserData } from '../../user/entity/user.entity';
|
|
5
|
+
import { EntityManager } from 'typeorm';
|
|
6
|
+
import { ViewMaster } from '../entity/view-master.entity';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class ViewMasterService extends EntityServiceImpl {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async createEntity(
|
|
15
|
+
entityData: BaseEntity,
|
|
16
|
+
loggedInUser: UserData | null,
|
|
17
|
+
manager?: EntityManager,
|
|
18
|
+
): Promise<BaseEntity> {
|
|
19
|
+
const entityMaster = await this.entityMasterService.getEntityData(
|
|
20
|
+
entityData.entity_type,
|
|
21
|
+
);
|
|
22
|
+
entityData.parent_id = entityMaster.id;
|
|
23
|
+
entityData.parent_type = entityMaster.entity_type;
|
|
24
|
+
|
|
25
|
+
const savedEntity = await super.createEntity(
|
|
26
|
+
entityData,
|
|
27
|
+
loggedInUser,
|
|
28
|
+
manager,
|
|
29
|
+
);
|
|
30
|
+
return savedEntity;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async updateEntity(
|
|
34
|
+
entityData: ViewMaster,
|
|
35
|
+
loggedInUserData: UserData | null,
|
|
36
|
+
): Promise<BaseEntity> {
|
|
37
|
+
|
|
38
|
+
return entityData;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Controller, Get, Request, UseGuards } from '@nestjs/common';
|
|
2
|
-
import { MenuService } from '../service/menu.service';
|
|
3
|
-
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
4
|
-
|
|
5
|
-
@Controller('menu')
|
|
6
|
-
export class MenuController {
|
|
7
|
-
constructor(private readonly menuService: MenuService) {}
|
|
8
|
-
|
|
9
|
-
@UseGuards(JwtAuthGuard)
|
|
10
|
-
@Get()
|
|
11
|
-
async getMenu(@Request() req) {
|
|
12
|
-
const userId = req.user.userId;
|
|
13
|
-
return this.menuService.getUserMenu(userId);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
import { Controller, Get, Request, UseGuards } from '@nestjs/common';
|
|
2
|
+
import { MenuService } from '../service/menu.service';
|
|
3
|
+
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
4
|
+
|
|
5
|
+
@Controller('menu')
|
|
6
|
+
export class MenuController {
|
|
7
|
+
constructor(private readonly menuService: MenuService) {}
|
|
8
|
+
|
|
9
|
+
@UseGuards(JwtAuthGuard)
|
|
10
|
+
@Get()
|
|
11
|
+
async getMenu(@Request() req) {
|
|
12
|
+
const userId = req.user.userId;
|
|
13
|
+
return this.menuService.getUserMenu(userId);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
|
|
1
|
+
import { Body, Controller, Get, Param, Post, Query, UseGuards } from '@nestjs/common';
|
|
2
2
|
import { ModuleAccessService } from '../service/module-access.service';
|
|
3
3
|
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
4
4
|
|
|
@@ -7,7 +7,6 @@ import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
|
7
7
|
export class ModuleAccessController {
|
|
8
8
|
constructor(private readonly moduleAccessService: ModuleAccessService) {}
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
@Get('roles')
|
|
12
11
|
async getRoles() {
|
|
13
12
|
return this.moduleAccessService.getRoles();
|
|
@@ -36,14 +35,31 @@ export class ModuleAccessController {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
@Post('create-role')
|
|
39
|
-
async createRole(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
38
|
+
async createRole(
|
|
39
|
+
@Body()
|
|
40
|
+
body: {
|
|
41
|
+
name: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
status?: 'ACTIVE' | 'INACTIVE';
|
|
44
|
+
copyFromRoleId?: number;
|
|
45
|
+
},
|
|
46
|
+
) {
|
|
47
|
+
return this.moduleAccessService.createRole(body);
|
|
48
|
+
}
|
|
47
49
|
|
|
50
|
+
@Post('update-role/:id')
|
|
51
|
+
async updateRole(
|
|
52
|
+
@Param('id') id: number,
|
|
53
|
+
@Body()
|
|
54
|
+
body: {
|
|
55
|
+
name?: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
status?: 'ACTIVE' | 'INACTIVE';
|
|
58
|
+
copyFromRoleId?: number; // <-- ADD THIS
|
|
59
|
+
},
|
|
60
|
+
) {
|
|
61
|
+
return this.moduleAccessService.updateRole(id, body);
|
|
62
|
+
}
|
|
63
|
+
|
|
48
64
|
|
|
49
65
|
}
|