rez_core 2.1.53 → 2.1.54
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/listmaster/controller/list-master.controller.d.ts +9 -1
- package/dist/module/listmaster/controller/list-master.controller.js +45 -2
- package/dist/module/listmaster/controller/list-master.controller.js.map +1 -1
- package/dist/module/listmaster/entity/list-master.entity.d.ts +1 -0
- package/dist/module/listmaster/entity/list-master.entity.js +4 -0
- package/dist/module/listmaster/entity/list-master.entity.js.map +1 -1
- package/dist/module/listmaster/listmaster.module.js +14 -3
- package/dist/module/listmaster/listmaster.module.js.map +1 -1
- package/dist/module/listmaster/repository/list-master-items.repository.d.ts +4 -0
- package/dist/module/listmaster/repository/list-master-items.repository.js +17 -1
- package/dist/module/listmaster/repository/list-master-items.repository.js.map +1 -1
- package/dist/module/listmaster/service/list-master-item.service.d.ts +12 -0
- package/dist/module/listmaster/service/list-master-item.service.js +57 -0
- package/dist/module/listmaster/service/list-master-item.service.js.map +1 -0
- package/dist/module/listmaster/service/list-master.service.d.ts +6 -1
- package/dist/module/listmaster/service/list-master.service.js +28 -1
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/meta/controller/entity.controller.js +1 -1
- package/dist/module/meta/controller/entity.controller.js.map +1 -1
- package/dist/module/meta/service/entity-table.service.js +2 -1
- package/dist/module/meta/service/entity-table.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/listmaster/controller/list-master.controller.ts +36 -1
- package/src/module/listmaster/entity/list-master.entity.ts +3 -0
- package/src/module/listmaster/listmaster.module.ts +14 -3
- package/src/module/listmaster/repository/list-master-items.repository.ts +32 -13
- package/src/module/listmaster/service/list-master-item.service.ts +55 -0
- package/src/module/listmaster/service/list-master.service.ts +41 -1
- package/src/module/meta/controller/entity.controller.ts +1 -1
- package/src/module/meta/service/entity-table.service.ts +3 -1
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Body,
|
|
3
3
|
Controller,
|
|
4
|
+
Delete,
|
|
5
|
+
Get,
|
|
4
6
|
HttpCode,
|
|
5
7
|
HttpStatus,
|
|
8
|
+
Inject,
|
|
6
9
|
Param,
|
|
7
10
|
Post,
|
|
8
11
|
Query,
|
|
@@ -11,10 +14,15 @@ import {
|
|
|
11
14
|
} from '@nestjs/common';
|
|
12
15
|
import { ListMasterService } from '../service/list-master.service';
|
|
13
16
|
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
17
|
+
import { ListMasterItemService } from '../service/list-master-item.service';
|
|
14
18
|
|
|
15
19
|
@Controller('list-master')
|
|
16
20
|
export class ListMasterController {
|
|
17
|
-
constructor(
|
|
21
|
+
constructor(
|
|
22
|
+
@Inject('ListMasterService')
|
|
23
|
+
private readonly service: ListMasterService,
|
|
24
|
+
private readonly listMasterItemService: ListMasterItemService,
|
|
25
|
+
) {}
|
|
18
26
|
|
|
19
27
|
@Post('/getDropdownData/:type')
|
|
20
28
|
@UseGuards(JwtAuthGuard)
|
|
@@ -39,4 +47,31 @@ export class ListMasterController {
|
|
|
39
47
|
loggedInUser,
|
|
40
48
|
);
|
|
41
49
|
}
|
|
50
|
+
|
|
51
|
+
@Get('/getListMasterItems/:type')
|
|
52
|
+
@UseGuards(JwtAuthGuard)
|
|
53
|
+
@HttpCode(HttpStatus.OK)
|
|
54
|
+
async getListMasterItems(@Param('type') type: string) {
|
|
55
|
+
console.log('Fetching list master items for type:', type);
|
|
56
|
+
return await this.listMasterItemService.getListMasterItemsByType(type);
|
|
57
|
+
}
|
|
58
|
+
@Post('/upsertListMasterItem/:type')
|
|
59
|
+
@UseGuards(JwtAuthGuard)
|
|
60
|
+
@HttpCode(HttpStatus.OK)
|
|
61
|
+
async upsertListMasterItem(@Param('type') type: string, @Body() item: any) {
|
|
62
|
+
return await this.listMasterItemService.upsertListMasterItem(
|
|
63
|
+
type,
|
|
64
|
+
item.items,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Delete('/deleteListMasterItem/:type/:name')
|
|
69
|
+
@UseGuards(JwtAuthGuard)
|
|
70
|
+
@HttpCode(HttpStatus.OK)
|
|
71
|
+
async deleteListMasterItem(
|
|
72
|
+
@Param('type') type: string,
|
|
73
|
+
@Param('name') name: string,
|
|
74
|
+
): Promise<string> {
|
|
75
|
+
return await this.listMasterItemService.deleteListMasterItem(type, name);
|
|
76
|
+
}
|
|
42
77
|
}
|
|
@@ -9,11 +9,22 @@ import { EntityModule } from '../meta/entity.module';
|
|
|
9
9
|
import { ListMasterController } from './controller/list-master.controller';
|
|
10
10
|
import { ThirdPartyModule } from '../third-party-module/third-party.module';
|
|
11
11
|
import { HttpModule } from '@nestjs/axios';
|
|
12
|
+
import { ListMasterItemService } from './service/list-master-item.service';
|
|
12
13
|
|
|
13
14
|
@Module({
|
|
14
|
-
imports: [
|
|
15
|
-
|
|
15
|
+
imports: [
|
|
16
|
+
TypeOrmModule.forFeature([ListMasterData, ListMasterItems]),
|
|
17
|
+
forwardRef(() => EntityModule),
|
|
18
|
+
ThirdPartyModule,
|
|
19
|
+
HttpModule,
|
|
20
|
+
],
|
|
21
|
+
providers: [
|
|
22
|
+
{ provide: 'ListMasterService', useClass: ListMasterService },
|
|
23
|
+
ListMasterItemService,
|
|
24
|
+
ListMasterRepository,
|
|
25
|
+
ListMasterItemsRepository,
|
|
26
|
+
],
|
|
16
27
|
controllers: [ListMasterController],
|
|
17
|
-
exports:[ListMasterService]
|
|
28
|
+
exports: ['ListMasterService'],
|
|
18
29
|
})
|
|
19
30
|
export class ListMasterModule {}
|
|
@@ -4,18 +4,37 @@ import { Repository } from 'typeorm';
|
|
|
4
4
|
import { ListMasterItems } from '../entity/list-master-items.entity';
|
|
5
5
|
|
|
6
6
|
@Injectable()
|
|
7
|
-
export class ListMasterItemsRepository{
|
|
7
|
+
export class ListMasterItemsRepository {
|
|
8
|
+
constructor(
|
|
9
|
+
@InjectRepository(ListMasterItems)
|
|
10
|
+
private repo: Repository<ListMasterItems>,
|
|
11
|
+
) {}
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
async findItemsByType(type: string) {
|
|
14
|
-
const items = await this.repo.find({
|
|
15
|
-
where: { listtype: type, status: 'active' },
|
|
16
|
-
order: { sortindex: 'ASC' },
|
|
17
|
-
});
|
|
18
|
-
return items.map(i => ({ label: i.name, value: i.value }));
|
|
19
|
-
}
|
|
13
|
+
async create(item: Partial<ListMasterItems>) {
|
|
14
|
+
const newItem = this.repo.create(item);
|
|
15
|
+
return this.repo.save(newItem);
|
|
16
|
+
}
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
async update(id: number, item: Partial<ListMasterItems>) {
|
|
19
|
+
await this.repo.update(id, item);
|
|
20
|
+
return this.repo.findOne({ where: { id } });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async findItemsByType(type: string) {
|
|
24
|
+
const items = await this.repo.find({
|
|
25
|
+
where: { listtype: type, status: 'active' },
|
|
26
|
+
order: { sortindex: 'ASC' },
|
|
27
|
+
});
|
|
28
|
+
return items.map((i) => ({ label: i.name, value: i.value }));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async findOneByNameAndType(name: string, type: string) {
|
|
32
|
+
return this.repo.findOne({
|
|
33
|
+
where: { name, listtype: type, status: 'active' },
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async delete(item: Partial<ListMasterItems>) {
|
|
38
|
+
return this.repo.delete(item);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
2
|
+
import { ListMasterItemsRepository } from '../repository/list-master-items.repository';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class ListMasterItemService {
|
|
6
|
+
constructor(
|
|
7
|
+
private readonly listItemsRepo: ListMasterItemsRepository,
|
|
8
|
+
private readonly listMasterRepo: ListMasterItemsRepository,
|
|
9
|
+
) {}
|
|
10
|
+
|
|
11
|
+
async getListMasterItemsByType(type: string) {
|
|
12
|
+
return await this.listItemsRepo.findItemsByType(type);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async upsertListMasterItem(type: string, item: any[]): Promise<any> {
|
|
16
|
+
// Check if list master item with type and name already exists then update it else create a new one
|
|
17
|
+
|
|
18
|
+
console.log('Upserting list master item for type:', type, item);
|
|
19
|
+
|
|
20
|
+
// will need to loop through the item array
|
|
21
|
+
for (const i of item) {
|
|
22
|
+
console.log('Processing item:', i);
|
|
23
|
+
const existingItem = await this.listItemsRepo.findOneByNameAndType(
|
|
24
|
+
i.name,
|
|
25
|
+
type,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
console.log('Existing item found:', existingItem);
|
|
29
|
+
|
|
30
|
+
if (existingItem) {
|
|
31
|
+
await this.listItemsRepo.update(existingItem.id, i);
|
|
32
|
+
} else {
|
|
33
|
+
await this.listItemsRepo.create(i);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const updatedItems = await this.listItemsRepo.findItemsByType(type);
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
type,
|
|
41
|
+
items: updatedItems,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async deleteListMasterItem(type: string, name: string): Promise<string> {
|
|
46
|
+
const item = await this.listItemsRepo.findOneByNameAndType(name, type);
|
|
47
|
+
if (!item) {
|
|
48
|
+
throw new NotFoundException(
|
|
49
|
+
`Item with name ${name} not found in type ${type}`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
await this.listItemsRepo.delete({ listtype: type, name: name });
|
|
53
|
+
return `Item with name ${name} deleted successfully from type ${type}`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EntityServiceImpl } from '../../meta/service/entity-service-impl.service';
|
|
2
1
|
import {
|
|
3
2
|
BadRequestException,
|
|
3
|
+
forwardRef,
|
|
4
|
+
Inject,
|
|
4
5
|
Injectable,
|
|
5
6
|
NotFoundException,
|
|
6
7
|
} from '@nestjs/common';
|
|
@@ -13,11 +14,14 @@ import { EntityManager } from 'typeorm';
|
|
|
13
14
|
import { EntityMasterService } from 'src/module/meta/service/entity-master.service';
|
|
14
15
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
15
16
|
import { log } from 'console';
|
|
17
|
+
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
16
18
|
|
|
17
19
|
@Injectable()
|
|
18
20
|
export class ListMasterService {
|
|
19
21
|
constructor(
|
|
20
22
|
private readonly entityManager: EntityManager,
|
|
23
|
+
@Inject(forwardRef(() => EntityServiceImpl))
|
|
24
|
+
private readonly entityServiceImpl: EntityServiceImpl,
|
|
21
25
|
private readonly entityMasterService: EntityMasterService,
|
|
22
26
|
private readonly listMasterRepo: ListMasterRepository,
|
|
23
27
|
private readonly listItemsRepo: ListMasterItemsRepository,
|
|
@@ -232,4 +236,40 @@ export class ListMasterService {
|
|
|
232
236
|
return acc[key];
|
|
233
237
|
}, obj);
|
|
234
238
|
}
|
|
239
|
+
|
|
240
|
+
// createEntity method
|
|
241
|
+
async createEntity(entityData: any, loggedInUser: UserData): Promise<any> {
|
|
242
|
+
entityData.is_factory = entityData.is_factory || 0;
|
|
243
|
+
entityData.source = entityData.source || 'master';
|
|
244
|
+
entityData.status = entityData.status || 'ACTIVE';
|
|
245
|
+
|
|
246
|
+
// check if a list master with the same type already exists
|
|
247
|
+
const existingListMaster = await this.listMasterRepo.findByType(
|
|
248
|
+
entityData.type,
|
|
249
|
+
);
|
|
250
|
+
if (existingListMaster) {
|
|
251
|
+
throw new BadRequestException(
|
|
252
|
+
'List master with the same type already exists.',
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const createdListMaster = await this.entityServiceImpl.createEntity(
|
|
257
|
+
entityData,
|
|
258
|
+
loggedInUser,
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
if (!createdListMaster) {
|
|
262
|
+
throw new BadRequestException('Failed to create entity');
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return createdListMaster;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
async updateEntity(entityData: any, loggedInUser: UserData): Promise<any> {
|
|
269
|
+
return await this.entityServiceImpl.updateEntity(entityData, loggedInUser);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
async getEntityData(entity_type: string, id: number): Promise<any> {
|
|
273
|
+
return await this.entityServiceImpl.getEntityData(entity_type, id);
|
|
274
|
+
}
|
|
235
275
|
}
|
|
@@ -12,7 +12,9 @@ export class EntityTableService {
|
|
|
12
12
|
constructor(
|
|
13
13
|
private entityTableRepository: EntityTableRepository,
|
|
14
14
|
private readonly entityTableColumnRepository: EntityTableColumnRepository,
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
@Inject(forwardRef(() => 'ListMasterService'))
|
|
17
|
+
@Inject('ListMasterService')
|
|
16
18
|
private readonly listMasterService: ListMasterService,
|
|
17
19
|
|
|
18
20
|
private readonly savedFilterRepoService: SavedFilterRepositoryService,
|