rez_core 2.1.55 → 2.1.56
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 +2 -1
- package/dist/module/listmaster/controller/list-master.controller.js +16 -4
- package/dist/module/listmaster/controller/list-master.controller.js.map +1 -1
- package/dist/module/listmaster/repository/list-master-items.repository.d.ts +1 -1
- package/dist/module/listmaster/repository/list-master-items.repository.js +9 -5
- package/dist/module/listmaster/repository/list-master-items.repository.js.map +1 -1
- package/dist/module/listmaster/repository/list-master.repository.d.ts +1 -0
- package/dist/module/listmaster/repository/list-master.repository.js +9 -0
- package/dist/module/listmaster/repository/list-master.repository.js.map +1 -1
- package/dist/module/listmaster/service/list-master-item.service.d.ts +1 -1
- package/dist/module/listmaster/service/list-master-item.service.js +2 -8
- package/dist/module/listmaster/service/list-master-item.service.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.d.ts +1 -0
- package/dist/module/listmaster/service/list-master.service.js +4 -0
- package/dist/module/listmaster/service/list-master.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 +18 -3
- package/src/module/listmaster/repository/list-master-items.repository.ts +15 -5
- package/src/module/listmaster/repository/list-master.repository.ts +15 -0
- package/src/module/listmaster/service/list-master-item.service.ts +2 -12
- package/src/module/listmaster/service/list-master.service.ts +5 -1
package/package.json
CHANGED
|
@@ -53,10 +53,25 @@ export class ListMasterController {
|
|
|
53
53
|
@Get('/getListMasterItems/:type')
|
|
54
54
|
@UseGuards(JwtAuthGuard)
|
|
55
55
|
@HttpCode(HttpStatus.OK)
|
|
56
|
-
async getListMasterItems(
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
async getListMasterItems(
|
|
57
|
+
@Param('type') type: string,
|
|
58
|
+
@Query('search') search?: string,
|
|
59
|
+
) {
|
|
60
|
+
return await this.listMasterItemService.getListMasterItemsByType(
|
|
61
|
+
type,
|
|
62
|
+
search,
|
|
63
|
+
);
|
|
59
64
|
}
|
|
65
|
+
|
|
66
|
+
@Get('')
|
|
67
|
+
@UseGuards(JwtAuthGuard)
|
|
68
|
+
@HttpCode(HttpStatus.OK)
|
|
69
|
+
async getAllListMasterItems(
|
|
70
|
+
@Query('search') search?: string,
|
|
71
|
+
): Promise<any[]> {
|
|
72
|
+
return await this.service.getAllListMasterItems(search);
|
|
73
|
+
}
|
|
74
|
+
|
|
60
75
|
@Post('/upsertListMasterItem/:type')
|
|
61
76
|
@UseGuards(JwtAuthGuard)
|
|
62
77
|
@HttpCode(HttpStatus.OK)
|
|
@@ -28,11 +28,21 @@ export class ListMasterItemsRepository {
|
|
|
28
28
|
return items.map((i) => ({ label: i.name, value: i.value }));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
async findAllItemsByListType(type: string, sortBy: string) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
async findAllItemsByListType(type: string, sortBy: string, search?: string) {
|
|
32
|
+
const qb = this.repo
|
|
33
|
+
.createQueryBuilder('item')
|
|
34
|
+
.where('item.listtype = :type', { type });
|
|
35
|
+
|
|
36
|
+
if (search?.trim()) {
|
|
37
|
+
qb.andWhere(
|
|
38
|
+
'(LOWER(item.name) LIKE :search OR LOWER(item.code) LIKE :search)',
|
|
39
|
+
{ search: `%${search.toLowerCase()}%` },
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
qb.orderBy('item.sortindex', sortBy === 'asc' ? 'ASC' : 'DESC');
|
|
44
|
+
|
|
45
|
+
return await qb.getMany();
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
async findOneByCodeAndType(code: string, type: string) {
|
|
@@ -17,4 +17,19 @@ export class ListMasterRepository {
|
|
|
17
17
|
findByName(name: string) {
|
|
18
18
|
return this.repo.findOne({ where: { name } });
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
async findAllItems(search?: string) {
|
|
22
|
+
const qb = this.repo
|
|
23
|
+
.createQueryBuilder('item')
|
|
24
|
+
.where('item.source = :source', { source: 'master' });
|
|
25
|
+
|
|
26
|
+
if (search?.trim()) {
|
|
27
|
+
qb.andWhere(
|
|
28
|
+
'(LOWER(item.name) LIKE :search OR LOWER(item.code) LIKE :search)',
|
|
29
|
+
{ search: `%${search.toLowerCase()}%` },
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return await qb.getMany();
|
|
34
|
+
}
|
|
20
35
|
}
|
|
@@ -17,8 +17,8 @@ export class ListMasterItemService {
|
|
|
17
17
|
private readonly entityServiceImpl: EntityServiceImpl,
|
|
18
18
|
) {}
|
|
19
19
|
|
|
20
|
-
async getListMasterItemsByType(listType: string) {
|
|
21
|
-
return
|
|
20
|
+
async getListMasterItemsByType(listType: string, search?: string) {
|
|
21
|
+
return this.listItemsRepo.findAllItemsByListType(listType, 'asc', search);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
async createEntity(entityData: any, loggedInUser: UserData): Promise<any> {
|
|
@@ -34,26 +34,17 @@ export class ListMasterItemService {
|
|
|
34
34
|
items: any[],
|
|
35
35
|
loggedInUser,
|
|
36
36
|
): Promise<any> {
|
|
37
|
-
console.log('Upserting list master items for type:', listType);
|
|
38
|
-
|
|
39
37
|
for (const item of items) {
|
|
40
|
-
console.log('Processing item:', item);
|
|
41
|
-
|
|
42
38
|
let existingItem;
|
|
43
39
|
|
|
44
40
|
// If code is provided, use it for lookup
|
|
45
41
|
if (item.code) {
|
|
46
|
-
console.log('Code provided:', item.code);
|
|
47
42
|
existingItem = await this.listItemsRepo.findOneByCodeAndType(
|
|
48
43
|
item.code,
|
|
49
44
|
listType,
|
|
50
45
|
);
|
|
51
|
-
|
|
52
|
-
console.log('Existing item found by code:', existingItem);
|
|
53
46
|
}
|
|
54
47
|
|
|
55
|
-
console.log('Existing item found:', existingItem);
|
|
56
|
-
|
|
57
48
|
if (existingItem) {
|
|
58
49
|
await this.updateEntity(
|
|
59
50
|
{
|
|
@@ -74,7 +65,6 @@ export class ListMasterItemService {
|
|
|
74
65
|
);
|
|
75
66
|
|
|
76
67
|
// now update the value of the item to its code
|
|
77
|
-
console.log('Created item, updating value to code:', createdItem.code);
|
|
78
68
|
|
|
79
69
|
await this.listItemsRepo.update(createdItem.id, {
|
|
80
70
|
value: createdItem.code,
|
|
@@ -13,7 +13,6 @@ import { HttpService } from '@nestjs/axios';
|
|
|
13
13
|
import { EntityManager } from 'typeorm';
|
|
14
14
|
import { EntityMasterService } from 'src/module/meta/service/entity-master.service';
|
|
15
15
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
16
|
-
import { log } from 'console';
|
|
17
16
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
18
17
|
|
|
19
18
|
@Injectable()
|
|
@@ -243,6 +242,7 @@ export class ListMasterService {
|
|
|
243
242
|
entityData.source = entityData.source || 'master';
|
|
244
243
|
entityData.status = entityData.status || 'ACTIVE';
|
|
245
244
|
entityData.type = entityData.type || 'LIST_MASTER';
|
|
245
|
+
entityData.sort_by = entityData.sort_by || 'asc';
|
|
246
246
|
|
|
247
247
|
// check if a list master with the same type already exists
|
|
248
248
|
const existingListMaster = await this.listMasterRepo.findByName(
|
|
@@ -279,4 +279,8 @@ export class ListMasterService {
|
|
|
279
279
|
async getEntityData(entity_type: string, id: number): Promise<any> {
|
|
280
280
|
return await this.entityServiceImpl.getEntityData(entity_type, id);
|
|
281
281
|
}
|
|
282
|
+
|
|
283
|
+
async getAllListMasterItems(search?: string): Promise<any[]> {
|
|
284
|
+
return await this.listMasterRepo.findAllItems(search);
|
|
285
|
+
}
|
|
282
286
|
}
|