rez_core 1.0.37 → 1.0.39
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/.idea/250218_nodejs_core.iml +12 -0
- package/.idea/codeStyles/Project.xml +59 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/dataSources.xml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/dist/constant/global.constant.d.ts +1 -0
- package/dist/constant/global.constant.js +2 -1
- package/dist/constant/global.constant.js.map +1 -1
- package/dist/module/auth/guards/role.guard.js +3 -3
- package/dist/module/enterprise/enterprise.module.js +2 -1
- package/dist/module/enterprise/enterprise.module.js.map +1 -1
- package/dist/module/meta/controller/media.controller.d.ts +12 -0
- package/dist/module/meta/controller/media.controller.js +49 -0
- package/dist/module/meta/controller/media.controller.js.map +1 -0
- package/dist/module/meta/entity.module.js +2 -1
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/service/media-data.service.d.ts +18 -3
- package/dist/module/meta/service/media-data.service.js +57 -2
- package/dist/module/meta/service/media-data.service.js.map +1 -1
- package/dist/module/user/service/user.service.js +1 -1
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -1
- package/src/constant/global.constant.ts +1 -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/auth.service.ts +29 -29
- 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/enterprise.module.ts +2 -1
- package/src/module/enterprise/entity/enterprise.entity.ts +37 -37
- package/src/module/enterprise/entity/organization.entity.ts +80 -80
- package/src/module/master/controller/master.controller.ts +22 -22
- package/src/module/meta/controller/media.controller.ts +45 -0
- package/src/module/meta/dto/entity-list-data.dto.ts +6 -6
- package/src/module/meta/entity/attribute-master.entity.ts +67 -67
- package/src/module/meta/entity/preference.entity.ts +65 -65
- package/src/module/meta/entity.module.ts +2 -1
- package/src/module/meta/repository/attribute-master.repository.ts +28 -28
- package/src/module/meta/repository/preference.repository.ts +20 -20
- package/src/module/meta/service/media-data.service.ts +75 -1
- package/src/module/module/controller/menu.controller.ts +15 -15
- 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/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/entity/user.entity.ts +35 -35
- package/src/module/user/repository/role.repository.ts +16 -16
- package/src/module/user/repository/userSession.repository.ts +33 -33
- package/src/module/user/service/user.service.ts +1 -1
- package/src/resources/dev.properties.yaml +9 -3
- 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
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
Controller,
|
|
4
|
+
HttpStatus,
|
|
5
|
+
Post,
|
|
6
|
+
Res,
|
|
7
|
+
UseGuards,
|
|
8
|
+
} from '@nestjs/common';
|
|
9
|
+
import { MediaDataService } from '../service/media-data.service';
|
|
10
|
+
import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
|
|
11
|
+
import { Response } from 'express';
|
|
12
|
+
|
|
13
|
+
@Controller('media')
|
|
14
|
+
// @UseGuards(JwtAuthGuard)
|
|
15
|
+
export class MediaController {
|
|
16
|
+
constructor(private readonly mediaDataService: MediaDataService) {}
|
|
17
|
+
|
|
18
|
+
@Post('initiate-upload')
|
|
19
|
+
async initiateUpload(
|
|
20
|
+
@Body()
|
|
21
|
+
body: {
|
|
22
|
+
file_name: string;
|
|
23
|
+
attribute_key: string;
|
|
24
|
+
mapped_entity_type?: string;
|
|
25
|
+
mapped_entity_id?: number;
|
|
26
|
+
},
|
|
27
|
+
@Res() res: Response,
|
|
28
|
+
) {
|
|
29
|
+
let result = await this.mediaDataService.generateMediaUploadDetails(
|
|
30
|
+
body.file_name,
|
|
31
|
+
body.attribute_key,
|
|
32
|
+
body.mapped_entity_type,
|
|
33
|
+
body.mapped_entity_id,
|
|
34
|
+
);
|
|
35
|
+
if (result) {
|
|
36
|
+
res.status(HttpStatus.OK).json({
|
|
37
|
+
message: 'Upload initiated successfully',
|
|
38
|
+
success: true,
|
|
39
|
+
data: result,
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
throw new Error('Something went wrong!');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -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,67 +1,67 @@
|
|
|
1
|
-
import { BaseEntity } from './base-entity.entity';
|
|
2
|
-
import { Column, Entity } from 'typeorm';
|
|
3
|
-
|
|
4
|
-
@Entity({ name: 'cr_attribute_master' })
|
|
5
|
-
export class AttributeMaster extends BaseEntity {
|
|
6
|
-
@Column({ name: 'mapped_entity_type', type: 'varchar', nullable: true })
|
|
7
|
-
mapped_entity_type: string;
|
|
8
|
-
|
|
9
|
-
@Column({ name: 'mapped_entity_id' })
|
|
10
|
-
mapped_entity_id: number;
|
|
11
|
-
|
|
12
|
-
@Column({ name: 'element_type', type: 'varchar', nullable: true, length: 50 })
|
|
13
|
-
element_type: string;
|
|
14
|
-
|
|
15
|
-
@Column({
|
|
16
|
-
name: 'data_source_type',
|
|
17
|
-
type: 'varchar',
|
|
18
|
-
nullable: true,
|
|
19
|
-
length: 50,
|
|
20
|
-
})
|
|
21
|
-
data_source_type: string;
|
|
22
|
-
|
|
23
|
-
@Column({ name: 'datasource_list', type: 'varchar', nullable: true })
|
|
24
|
-
datasource_list: string;
|
|
25
|
-
|
|
26
|
-
@Column({
|
|
27
|
-
name: 'custom_values',
|
|
28
|
-
type: 'varchar',
|
|
29
|
-
length: 2000,
|
|
30
|
-
nullable: true,
|
|
31
|
-
})
|
|
32
|
-
custom_values: string;
|
|
33
|
-
|
|
34
|
-
@Column({ name: 'max_length', nullable: true })
|
|
35
|
-
max_length: number;
|
|
36
|
-
|
|
37
|
-
@Column({ name: 'required', nullable: true })
|
|
38
|
-
required: number;
|
|
39
|
-
|
|
40
|
-
@Column({
|
|
41
|
-
name: 'description',
|
|
42
|
-
type: 'varchar',
|
|
43
|
-
length: 2000,
|
|
44
|
-
nullable: true,
|
|
45
|
-
})
|
|
46
|
-
description: string;
|
|
47
|
-
|
|
48
|
-
@Column({
|
|
49
|
-
name: 'attribute_key',
|
|
50
|
-
type: 'varchar',
|
|
51
|
-
nullable: true,
|
|
52
|
-
length: 50,
|
|
53
|
-
})
|
|
54
|
-
attribute_key: string;
|
|
55
|
-
|
|
56
|
-
@Column({ name: 'db_datatype', type: 'varchar', nullable: true, length: 50 })
|
|
57
|
-
db_datatype: string;
|
|
58
|
-
|
|
59
|
-
@Column({ name: 'category', type: 'varchar', nullable: true, length: 50 })
|
|
60
|
-
category: string;
|
|
61
|
-
|
|
62
|
-
@Column({ name: 'is_unique', nullable: true })
|
|
63
|
-
is_unique: number;
|
|
64
|
-
|
|
65
|
-
@Column({ name: 'can_export', nullable: true })
|
|
66
|
-
can_export: number;
|
|
67
|
-
}
|
|
1
|
+
import { BaseEntity } from './base-entity.entity';
|
|
2
|
+
import { Column, Entity } from 'typeorm';
|
|
3
|
+
|
|
4
|
+
@Entity({ name: 'cr_attribute_master' })
|
|
5
|
+
export class AttributeMaster extends BaseEntity {
|
|
6
|
+
@Column({ name: 'mapped_entity_type', type: 'varchar', nullable: true })
|
|
7
|
+
mapped_entity_type: string;
|
|
8
|
+
|
|
9
|
+
@Column({ name: 'mapped_entity_id' })
|
|
10
|
+
mapped_entity_id: number;
|
|
11
|
+
|
|
12
|
+
@Column({ name: 'element_type', type: 'varchar', nullable: true, length: 50 })
|
|
13
|
+
element_type: string;
|
|
14
|
+
|
|
15
|
+
@Column({
|
|
16
|
+
name: 'data_source_type',
|
|
17
|
+
type: 'varchar',
|
|
18
|
+
nullable: true,
|
|
19
|
+
length: 50,
|
|
20
|
+
})
|
|
21
|
+
data_source_type: string;
|
|
22
|
+
|
|
23
|
+
@Column({ name: 'datasource_list', type: 'varchar', nullable: true })
|
|
24
|
+
datasource_list: string;
|
|
25
|
+
|
|
26
|
+
@Column({
|
|
27
|
+
name: 'custom_values',
|
|
28
|
+
type: 'varchar',
|
|
29
|
+
length: 2000,
|
|
30
|
+
nullable: true,
|
|
31
|
+
})
|
|
32
|
+
custom_values: string;
|
|
33
|
+
|
|
34
|
+
@Column({ name: 'max_length', nullable: true })
|
|
35
|
+
max_length: number;
|
|
36
|
+
|
|
37
|
+
@Column({ name: 'required', nullable: true })
|
|
38
|
+
required: number;
|
|
39
|
+
|
|
40
|
+
@Column({
|
|
41
|
+
name: 'description',
|
|
42
|
+
type: 'varchar',
|
|
43
|
+
length: 2000,
|
|
44
|
+
nullable: true,
|
|
45
|
+
})
|
|
46
|
+
description: string;
|
|
47
|
+
|
|
48
|
+
@Column({
|
|
49
|
+
name: 'attribute_key',
|
|
50
|
+
type: 'varchar',
|
|
51
|
+
nullable: true,
|
|
52
|
+
length: 50,
|
|
53
|
+
})
|
|
54
|
+
attribute_key: string;
|
|
55
|
+
|
|
56
|
+
@Column({ name: 'db_datatype', type: 'varchar', nullable: true, length: 50 })
|
|
57
|
+
db_datatype: string;
|
|
58
|
+
|
|
59
|
+
@Column({ name: 'category', type: 'varchar', nullable: true, length: 50 })
|
|
60
|
+
category: string;
|
|
61
|
+
|
|
62
|
+
@Column({ name: 'is_unique', nullable: true })
|
|
63
|
+
is_unique: number;
|
|
64
|
+
|
|
65
|
+
@Column({ name: 'can_export', nullable: true })
|
|
66
|
+
can_export: number;
|
|
67
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -22,6 +22,7 @@ import { EntityListService } from './service/entity-list.service';
|
|
|
22
22
|
import { MediaData } from './entity/media-data.entity';
|
|
23
23
|
import { MediaDataService } from './service/media-data.service';
|
|
24
24
|
import { MediaDataRepository } from './repository/media-data.repository';
|
|
25
|
+
import { MediaController } from './controller/media.controller';
|
|
25
26
|
|
|
26
27
|
@Module({
|
|
27
28
|
imports: [
|
|
@@ -59,6 +60,6 @@ import { MediaDataRepository } from './repository/media-data.repository';
|
|
|
59
60
|
EntityTableColumnService,
|
|
60
61
|
MediaDataService,
|
|
61
62
|
],
|
|
62
|
-
controllers: [EntityController, MasterController],
|
|
63
|
+
controllers: [EntityController, MasterController, MediaController],
|
|
63
64
|
})
|
|
64
65
|
export class EntityModule {}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
-
import { AttributeMaster } from '../entity/attribute-master.entity';
|
|
4
|
-
import { Repository } from 'typeorm';
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class AttributeMasterRepository {
|
|
8
|
-
constructor(
|
|
9
|
-
@InjectRepository(AttributeMaster)
|
|
10
|
-
private readonly attributeMasterRepository: Repository<AttributeMaster>,
|
|
11
|
-
) {}
|
|
12
|
-
|
|
13
|
-
async findByMappedEntityIdAndMappedEntityTypeAndAttributeKeyAndOrganizationId(
|
|
14
|
-
mappedEntityId: number,
|
|
15
|
-
mappedEntityType: string,
|
|
16
|
-
attributeKey: string,
|
|
17
|
-
organizationId: number,
|
|
18
|
-
): Promise<AttributeMaster | null> {
|
|
19
|
-
return await this.attributeMasterRepository.findOne({
|
|
20
|
-
where: {
|
|
21
|
-
mapped_entity_id: mappedEntityId,
|
|
22
|
-
mapped_entity_type: mappedEntityType,
|
|
23
|
-
attribute_key: attributeKey,
|
|
24
|
-
organization_id: organizationId,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
+
import { AttributeMaster } from '../entity/attribute-master.entity';
|
|
4
|
+
import { Repository } from 'typeorm';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class AttributeMasterRepository {
|
|
8
|
+
constructor(
|
|
9
|
+
@InjectRepository(AttributeMaster)
|
|
10
|
+
private readonly attributeMasterRepository: Repository<AttributeMaster>,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
async findByMappedEntityIdAndMappedEntityTypeAndAttributeKeyAndOrganizationId(
|
|
14
|
+
mappedEntityId: number,
|
|
15
|
+
mappedEntityType: string,
|
|
16
|
+
attributeKey: string,
|
|
17
|
+
organizationId: number,
|
|
18
|
+
): Promise<AttributeMaster | null> {
|
|
19
|
+
return await this.attributeMasterRepository.findOne({
|
|
20
|
+
where: {
|
|
21
|
+
mapped_entity_id: mappedEntityId,
|
|
22
|
+
mapped_entity_type: mappedEntityType,
|
|
23
|
+
attribute_key: attributeKey,
|
|
24
|
+
organization_id: organizationId,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -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,12 +1,76 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { EntityServiceImpl } from './entity-service-impl.service';
|
|
3
3
|
import { MediaDataRepository } from '../repository/media-data.repository';
|
|
4
|
+
import { ConfigService } from '@nestjs/config';
|
|
5
|
+
import { S3 } from 'aws-sdk';
|
|
6
|
+
import { MediaData } from '../entity/media-data.entity';
|
|
7
|
+
import { STATUS_PENDING } from '../../../constant/global.constant';
|
|
8
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
4
9
|
|
|
5
10
|
@Injectable()
|
|
6
11
|
export class MediaDataService extends EntityServiceImpl {
|
|
7
|
-
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly configService: ConfigService,
|
|
16
|
+
private readonly mediaRepository: MediaDataRepository,
|
|
17
|
+
) {
|
|
8
18
|
super();
|
|
9
19
|
}
|
|
20
|
+
|
|
21
|
+
s3AccessKeyID=this.configService.get('AWS.S3.AWS_ACCESS_KEY_ID')
|
|
22
|
+
s3AccessKeySecret=this.configService.get('AWS.S3.AWS_SECRET_KEY')
|
|
23
|
+
s3Region=this.configService.get('AWS.S3.AWS_REGION')
|
|
24
|
+
bucketName = this.configService.get<string>('AWS.S3.BUCKET_NAME');
|
|
25
|
+
|
|
26
|
+
s3 = new S3({
|
|
27
|
+
accessKeyId: this.s3AccessKeyID,
|
|
28
|
+
secretAccessKey: this.s3AccessKeySecret,
|
|
29
|
+
region: this.s3Region,
|
|
30
|
+
signatureVersion: 'v4',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
async generateMediaUploadDetails(
|
|
35
|
+
fileName: string,
|
|
36
|
+
mappedAttributeKey: string,
|
|
37
|
+
mappedEntityType?: string,
|
|
38
|
+
mappedEntityId?: number,
|
|
39
|
+
) {
|
|
40
|
+
|
|
41
|
+
if (!fileName || !mappedAttributeKey) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const ext = fileName.split('.').pop()?.toLowerCase() ?? '';
|
|
45
|
+
|
|
46
|
+
const id = uuidv4();
|
|
47
|
+
const s3Key = `uploads/${mappedAttributeKey}/${id}.${ext}`;
|
|
48
|
+
console.log(s3Key)
|
|
49
|
+
|
|
50
|
+
const uploadUrl = await this.s3.getSignedUrlPromise('putObject', {
|
|
51
|
+
Bucket: this.bucketName,
|
|
52
|
+
Key: s3Key,
|
|
53
|
+
Expires: 60 * 5, // URL valid for 5 mins
|
|
54
|
+
ContentType: this.getContentType(ext),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
let mediaData = new MediaData();
|
|
58
|
+
mediaData.mapped_attribute_key = mappedAttributeKey;
|
|
59
|
+
mediaData.status = STATUS_PENDING;
|
|
60
|
+
if (mappedEntityType) {
|
|
61
|
+
mediaData.mapped_entity_type = mappedEntityType;
|
|
62
|
+
}
|
|
63
|
+
if (mappedEntityId) {
|
|
64
|
+
mediaData.mapped_entity_id = mappedEntityId;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let savedEntity = await super.createEntity(mediaData, null);
|
|
68
|
+
|
|
69
|
+
if (savedEntity) {
|
|
70
|
+
return { id: savedEntity.id, path: s3Key, uploadUrl };
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
10
74
|
|
|
11
75
|
async findByAttributeKeyAndMappedEntityIdAndMappedEntityType(
|
|
12
76
|
attributeKey: string,
|
|
@@ -41,4 +105,14 @@ export class MediaDataService extends EntityServiceImpl {
|
|
|
41
105
|
mappedEntityType,
|
|
42
106
|
);
|
|
43
107
|
}
|
|
108
|
+
|
|
109
|
+
private getContentType(ext: string): string {
|
|
110
|
+
const map = {
|
|
111
|
+
pdf: 'application/pdf',
|
|
112
|
+
jpg: 'image/jpeg',
|
|
113
|
+
jpeg: 'image/jpeg',
|
|
114
|
+
png: 'image/png',
|
|
115
|
+
};
|
|
116
|
+
return map[ext] || 'application/octet-stream';
|
|
117
|
+
}
|
|
44
118
|
}
|
|
@@ -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,19 +1,19 @@
|
|
|
1
|
-
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
-
|
|
3
|
-
@Entity({ name: 'module_action' })
|
|
4
|
-
export class ModuleAction {
|
|
5
|
-
@PrimaryGeneratedColumn()
|
|
6
|
-
id: number;
|
|
7
|
-
|
|
8
|
-
@Column({type: 'int', nullable: true})
|
|
9
|
-
module_id: number;
|
|
10
|
-
|
|
11
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
12
|
-
module_code: string;
|
|
13
|
-
|
|
14
|
-
@Column({type: 'varchar', length: 100, nullable: true })
|
|
15
|
-
action_name:string
|
|
16
|
-
|
|
17
|
-
@Column({type: 'varchar', length: 50, nullable: true })
|
|
18
|
-
action_type: string;
|
|
19
|
-
}
|
|
1
|
+
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
@Entity({ name: 'module_action' })
|
|
4
|
+
export class ModuleAction {
|
|
5
|
+
@PrimaryGeneratedColumn()
|
|
6
|
+
id: number;
|
|
7
|
+
|
|
8
|
+
@Column({type: 'int', nullable: true})
|
|
9
|
+
module_id: number;
|
|
10
|
+
|
|
11
|
+
@Column({type: 'varchar', length: 100, nullable: true })
|
|
12
|
+
module_code: string;
|
|
13
|
+
|
|
14
|
+
@Column({type: 'varchar', length: 100, nullable: true })
|
|
15
|
+
action_name:string
|
|
16
|
+
|
|
17
|
+
@Column({type: 'varchar', length: 50, nullable: true })
|
|
18
|
+
action_type: string;
|
|
19
|
+
}
|