rez_core 1.0.64 → 1.0.65
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/auth/guards/role.guard.js +3 -3
- package/dist/module/master/controller/master.controller.d.ts +11 -1
- package/dist/module/master/controller/master.controller.js +42 -4
- package/dist/module/master/controller/master.controller.js.map +1 -1
- package/dist/module/master/service/master.service.d.ts +13 -4
- package/dist/module/master/service/master.service.js +97 -23
- package/dist/module/master/service/master.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/app.controller.ts +12 -12
- package/src/app.service.ts +8 -8
- 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/organization.entity.ts +80 -80
- package/src/module/master/controller/master.controller.ts +35 -11
- package/src/module/master/service/master.service.ts +144 -47
- package/src/module/meta/dto/entity-list-data.dto.ts +6 -6
- package/src/module/meta/entity/preference.entity.ts +65 -65
- package/src/module/meta/repository/preference.repository.ts +20 -20
- package/src/module/module/controller/menu.controller.ts +15 -15
- package/src/module/module/entity/module-access.entity.ts +22 -22
- 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-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
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { EntityManager
|
|
2
|
+
import { EntityManager } 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';
|
|
6
5
|
import { AttributeMasterService } from 'src/module/meta/service/attribute-master.service';
|
|
7
6
|
import { EntityMaster } from 'src/module/meta/entity/entity-master.entity';
|
|
8
7
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
9
|
-
|
|
10
|
-
interface ParentEntity {
|
|
11
|
-
id: number;
|
|
12
|
-
code: string;
|
|
13
|
-
}
|
|
8
|
+
import { ReflectionHelper } from 'src/utils/service/reflection-helper.service';
|
|
14
9
|
|
|
15
10
|
@Injectable()
|
|
16
11
|
export class MasterService {
|
|
@@ -19,6 +14,8 @@ export class MasterService {
|
|
|
19
14
|
private readonly entityMasterService: EntityMasterService,
|
|
20
15
|
private readonly attributeMasterService: AttributeMasterService,
|
|
21
16
|
private readonly excelUtil: ExcelUtil,
|
|
17
|
+
private reflectionHelper: ReflectionHelper,
|
|
18
|
+
|
|
22
19
|
private readonly entityServiceImpl: EntityServiceImpl,
|
|
23
20
|
) {}
|
|
24
21
|
|
|
@@ -46,7 +43,6 @@ export class MasterService {
|
|
|
46
43
|
unique_fields: ['listtype', 'code'],
|
|
47
44
|
},
|
|
48
45
|
];
|
|
49
|
-
|
|
50
46
|
private readonly dataSequence = [
|
|
51
47
|
{
|
|
52
48
|
table: 'cr_user',
|
|
@@ -70,43 +66,7 @@ export class MasterService {
|
|
|
70
66
|
},
|
|
71
67
|
];
|
|
72
68
|
|
|
73
|
-
|
|
74
|
-
return this.metaSheets.includes(sheetName.toLowerCase());
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private async resolveParent(row: any): Promise<void> {
|
|
78
|
-
const parentType = row.parent_type; // (Future use maybe)
|
|
79
|
-
const code = row.parent_id;
|
|
80
|
-
|
|
81
|
-
if (!code) {
|
|
82
|
-
throw new Error('Parent code is missing in the row');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const parentEntity: EntityMaster | null =
|
|
86
|
-
await this.entityMasterService.findByMappedEntityType(parentType);
|
|
87
|
-
|
|
88
|
-
const tableName: any = parentEntity?.db_table_name;
|
|
89
|
-
if (!tableName) {
|
|
90
|
-
throw new Error(`Table name not found for parent type ${parentType}`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Using RAW SQL Query
|
|
94
|
-
const entityData = await this.entityManager.query(
|
|
95
|
-
`SELECT * FROM ${tableName} WHERE code = ? LIMIT 1`,
|
|
96
|
-
[code],
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
if (!entityData || entityData.length === 0) {
|
|
100
|
-
throw new Error(
|
|
101
|
-
`Parent entity with code ${code} not found in table ${tableName}`,
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// entityData is an array when using .query()
|
|
106
|
-
row.parent_id = entityData[0].id;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async uploadMasterData(file) {
|
|
69
|
+
async uploadMeta(file) {
|
|
110
70
|
const data = ExcelUtil.readExcel(file.buffer);
|
|
111
71
|
|
|
112
72
|
for (let i = 0; i < this.sequence.length; i++) {
|
|
@@ -122,6 +82,14 @@ export class MasterService {
|
|
|
122
82
|
await this.upsertData(table, unique_fields, sheetData);
|
|
123
83
|
}
|
|
124
84
|
}
|
|
85
|
+
return {
|
|
86
|
+
message: 'Data uploaded successfully',
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async uploadData(file) {
|
|
91
|
+
const data = ExcelUtil.readExcel(file.buffer);
|
|
92
|
+
|
|
125
93
|
for (let i = 0; i < this.dataSequence.length; i++) {
|
|
126
94
|
const { table, unique_fields } = this.dataSequence[i];
|
|
127
95
|
const sheetData = data[table];
|
|
@@ -139,7 +107,6 @@ export class MasterService {
|
|
|
139
107
|
entityMasterData?.mapped_entity_type,
|
|
140
108
|
);
|
|
141
109
|
|
|
142
|
-
console.log(attributes,"((((((((((((((((((((((((((")
|
|
143
110
|
for (const row of sheetData) {
|
|
144
111
|
if (row.parent_type !== undefined && row.parent_id !== undefined) {
|
|
145
112
|
this.resolveParent(row);
|
|
@@ -147,7 +114,7 @@ export class MasterService {
|
|
|
147
114
|
|
|
148
115
|
for (const attribute of attributes) {
|
|
149
116
|
if (attribute.data_source_type === 'entity') {
|
|
150
|
-
console.log(attribute.data_source_type)
|
|
117
|
+
console.log(attribute.data_source_type);
|
|
151
118
|
let entityMaster = await this.entityMasterService.getEntityData(
|
|
152
119
|
attribute.datasource_list,
|
|
153
120
|
);
|
|
@@ -168,6 +135,95 @@ export class MasterService {
|
|
|
168
135
|
};
|
|
169
136
|
}
|
|
170
137
|
|
|
138
|
+
async uploadEntityData(file, entityType, loggedInUser) {
|
|
139
|
+
const data = ExcelUtil.readExcel(file.buffer);
|
|
140
|
+
const entityMaster = await this.entityMasterService.findByMappedEntityType(entityType);
|
|
141
|
+
if (!entityMaster) {
|
|
142
|
+
throw new Error(`Entity master not found for entityType: ${entityType}`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const tableName = entityMaster.db_table_name;
|
|
146
|
+
const sheetData = data[tableName];
|
|
147
|
+
|
|
148
|
+
if (!sheetData) {
|
|
149
|
+
throw new Error(`Sheet for ${tableName} not found in uploaded file`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const attributes = await this.attributeMasterService.findAttributesByMappedEntityType(entityType);
|
|
153
|
+
|
|
154
|
+
const uniqueFields = attributes
|
|
155
|
+
.filter(attr => attr.is_unique)
|
|
156
|
+
.map(attr => attr.attribute_key);
|
|
157
|
+
|
|
158
|
+
if (uniqueFields.length === 0) {
|
|
159
|
+
throw new Error(`No unique fields found for entityType: ${entityType}`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Transform reference fields
|
|
163
|
+
for (const row of sheetData) {
|
|
164
|
+
if (row.parent_type && row.parent_id) {
|
|
165
|
+
await this.resolveParent(row);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
for (const attr of attributes) {
|
|
169
|
+
if (attr.data_source_type === 'entity' && row[attr.attribute_key]) {
|
|
170
|
+
const refEntity = await this.entityMasterService.getEntityData(attr.datasource_list);
|
|
171
|
+
const refData = await this.entityManager.query(
|
|
172
|
+
`SELECT * FROM ${refEntity.db_table_name} WHERE code = ? LIMIT 1`,
|
|
173
|
+
[row[attr.attribute_key]],
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
if (!refData.length) {
|
|
177
|
+
throw new Error(`Reference entity not found for code: ${row[attr.attribute_key]}`);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
row[attr.attribute_key] = refData[0].id;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
await this.upsertViaService(entityType, sheetData, attributes, uniqueFields, loggedInUser);
|
|
186
|
+
|
|
187
|
+
return { message: 'Entity data uploaded successfully' };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
private isMetaSheet(sheetName: string): boolean {
|
|
192
|
+
return this.metaSheets.includes(sheetName.toLowerCase());
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private async resolveParent(row: any): Promise<void> {
|
|
196
|
+
const parentType = row.parent_type; // (Future use maybe)
|
|
197
|
+
const code = row.parent_id;
|
|
198
|
+
|
|
199
|
+
if (!code) {
|
|
200
|
+
throw new Error('Parent code is missing in the row');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const parentEntity: EntityMaster | null =
|
|
204
|
+
await this.entityMasterService.findByMappedEntityType(parentType);
|
|
205
|
+
|
|
206
|
+
const tableName: any = parentEntity?.db_table_name;
|
|
207
|
+
if (!tableName) {
|
|
208
|
+
throw new Error(`Table name not found for parent type ${parentType}`);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Using RAW SQL Query
|
|
212
|
+
const entityData = await this.entityManager.query(
|
|
213
|
+
`SELECT * FROM ${tableName} WHERE code = ? LIMIT 1`,
|
|
214
|
+
[code],
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
if (!entityData || entityData.length === 0) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Parent entity with code ${code} not found in table ${tableName}`,
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// entityData is an array when using .query()
|
|
224
|
+
row.parent_id = entityData[0].id;
|
|
225
|
+
}
|
|
226
|
+
|
|
171
227
|
async upsertData(
|
|
172
228
|
tableName: string,
|
|
173
229
|
uniqueFields: string[],
|
|
@@ -210,4 +266,45 @@ export class MasterService {
|
|
|
210
266
|
}
|
|
211
267
|
}
|
|
212
268
|
}
|
|
269
|
+
|
|
270
|
+
async upsertViaService(
|
|
271
|
+
entityType: string,
|
|
272
|
+
data: any[],
|
|
273
|
+
attributes: any[],
|
|
274
|
+
uniqueFields: string[],
|
|
275
|
+
loggedInUser: any,
|
|
276
|
+
): Promise<void> {
|
|
277
|
+
const entityMaster = await this.entityMasterService.findByMappedEntityType(entityType);
|
|
278
|
+
if (!entityMaster) throw new Error(`Entity master not found for ${entityType}`);
|
|
279
|
+
|
|
280
|
+
const serviceName = entityMaster.entity_service;
|
|
281
|
+
const entityService = await this.reflectionHelper.getBean<EntityServiceImpl>(serviceName);
|
|
282
|
+
|
|
283
|
+
if (!entityService) throw new Error(`Entity service not found for ${entityType}`);
|
|
284
|
+
|
|
285
|
+
for (const row of data) {
|
|
286
|
+
const whereClause = uniqueFields.reduce((acc, field) => {
|
|
287
|
+
acc[field] = row[field];
|
|
288
|
+
return acc;
|
|
289
|
+
}, {});
|
|
290
|
+
|
|
291
|
+
const existing = await this.entityManager
|
|
292
|
+
.createQueryBuilder()
|
|
293
|
+
.select('*')
|
|
294
|
+
.from(entityMaster.db_table_name, entityMaster.db_table_name)
|
|
295
|
+
.where(whereClause)
|
|
296
|
+
.limit(1)
|
|
297
|
+
.getRawOne();
|
|
298
|
+
|
|
299
|
+
row.entity_type = entityType;
|
|
300
|
+
if (existing) {
|
|
301
|
+
row.id = existing.id;
|
|
302
|
+
await entityService.updateEntity(row, loggedInUser);
|
|
303
|
+
} else {
|
|
304
|
+
await entityService.createEntity(row, loggedInUser);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
|
|
213
310
|
}
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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,22 +1,22 @@
|
|
|
1
|
-
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
-
|
|
3
|
-
@Entity({ name: 'cr_module_access' })
|
|
4
|
-
export class ModuleAccess {
|
|
5
|
-
@PrimaryGeneratedColumn()
|
|
6
|
-
id: number;
|
|
7
|
-
|
|
8
|
-
@Column({type: 'varchar', length: 100, nullable: true})
|
|
9
|
-
module_code: string;
|
|
10
|
-
|
|
11
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
12
|
-
role_code: string;
|
|
13
|
-
|
|
14
|
-
@Column({type: 'int', nullable: true })
|
|
15
|
-
access_flag: number;
|
|
16
|
-
|
|
17
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
18
|
-
action_type: string;
|
|
19
|
-
|
|
20
|
-
@Column({type: 'varchar', length: 100, nullable: true})
|
|
21
|
-
app_code: string;
|
|
22
|
-
}
|
|
1
|
+
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
@Entity({ name: 'cr_module_access' })
|
|
4
|
+
export class ModuleAccess {
|
|
5
|
+
@PrimaryGeneratedColumn()
|
|
6
|
+
id: number;
|
|
7
|
+
|
|
8
|
+
@Column({type: 'varchar', length: 100, nullable: true})
|
|
9
|
+
module_code: string;
|
|
10
|
+
|
|
11
|
+
@Column({type: 'varchar', length: 100, nullable: true })
|
|
12
|
+
role_code: string;
|
|
13
|
+
|
|
14
|
+
@Column({type: 'int', nullable: true })
|
|
15
|
+
access_flag: number;
|
|
16
|
+
|
|
17
|
+
@Column({type: 'varchar', length: 100, nullable: true })
|
|
18
|
+
action_type: string;
|
|
19
|
+
|
|
20
|
+
@Column({type: 'varchar', length: 100, nullable: true})
|
|
21
|
+
app_code: string;
|
|
22
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Body,
|
|
3
|
-
Controller,
|
|
4
|
-
HttpStatus,
|
|
5
|
-
Inject,
|
|
6
|
-
Post,
|
|
7
|
-
Res,
|
|
8
|
-
ValidationPipe,
|
|
9
|
-
} from '@nestjs/common';
|
|
10
|
-
import { UserService } from '../service/user.service';
|
|
11
|
-
import { CreateUserDto } from '../dto/create-user.dto';
|
|
12
|
-
import { Response } from 'express';
|
|
13
|
-
|
|
14
|
-
@Controller('user')
|
|
15
|
-
export class UserController {
|
|
16
|
-
constructor(
|
|
17
|
-
@Inject('UserService') private readonly userService: UserService,
|
|
18
|
-
) {}
|
|
19
|
-
|
|
20
|
-
@Post('signup')
|
|
21
|
-
async signup(
|
|
22
|
-
@Body(new ValidationPipe()) createUserDto: CreateUserDto,
|
|
23
|
-
@Res() res: Response,
|
|
24
|
-
) {
|
|
25
|
-
const result = await this.userService.createEntity(createUserDto, null);
|
|
26
|
-
res.status(HttpStatus.OK).json(result);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
Controller,
|
|
4
|
+
HttpStatus,
|
|
5
|
+
Inject,
|
|
6
|
+
Post,
|
|
7
|
+
Res,
|
|
8
|
+
ValidationPipe,
|
|
9
|
+
} from '@nestjs/common';
|
|
10
|
+
import { UserService } from '../service/user.service';
|
|
11
|
+
import { CreateUserDto } from '../dto/create-user.dto';
|
|
12
|
+
import { Response } from 'express';
|
|
13
|
+
|
|
14
|
+
@Controller('user')
|
|
15
|
+
export class UserController {
|
|
16
|
+
constructor(
|
|
17
|
+
@Inject('UserService') private readonly userService: UserService,
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
@Post('signup')
|
|
21
|
+
async signup(
|
|
22
|
+
@Body(new ValidationPipe()) createUserDto: CreateUserDto,
|
|
23
|
+
@Res() res: Response,
|
|
24
|
+
) {
|
|
25
|
+
const result = await this.userService.createEntity(createUserDto, null);
|
|
26
|
+
res.status(HttpStatus.OK).json(result);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PartialType } from '@nestjs/mapped-types';
|
|
2
|
-
import { CreateUserDto } from './create-user.dto';
|
|
3
|
-
|
|
4
|
-
export class UpdateUserDto extends PartialType(CreateUserDto) {}
|
|
1
|
+
import { PartialType } from '@nestjs/mapped-types';
|
|
2
|
+
import { CreateUserDto } from './create-user.dto';
|
|
3
|
+
|
|
4
|
+
export class UpdateUserDto extends PartialType(CreateUserDto) {}
|