rez_core 3.1.99 → 3.1.101
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/package.json
CHANGED
|
@@ -5,14 +5,13 @@ import { MapperRepository } from '../repository/mapper.repository';
|
|
|
5
5
|
import { FieldMapperRepository } from '../repository/field-mapper.repository';
|
|
6
6
|
import { FieldLovsRepository } from '../repository/field-lovs.repository';
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
@Injectable()
|
|
10
9
|
export class MapperService extends EntityServiceImpl {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
constructor(
|
|
11
|
+
private readonly dataSource: DataSource,
|
|
12
|
+
private mapperRepository: MapperRepository,
|
|
13
|
+
private fieldMapperRepository: FieldMapperRepository,
|
|
14
|
+
private fieldLovsRepository: FieldLovsRepository,
|
|
16
15
|
) {
|
|
17
16
|
super();
|
|
18
17
|
}
|
|
@@ -21,24 +20,42 @@ export class MapperService extends EntityServiceImpl {
|
|
|
21
20
|
if (!mappedEntityType) return [];
|
|
22
21
|
|
|
23
22
|
const mappers = await this.dataSource.query(
|
|
24
|
-
`SELECT id, name, code
|
|
23
|
+
`SELECT id, name, code, status
|
|
25
24
|
FROM cr_mapper
|
|
26
25
|
WHERE mapped_entity_type = ?`,
|
|
27
26
|
[mappedEntityType],
|
|
28
27
|
);
|
|
29
28
|
|
|
29
|
+
const distinctStatuses = [
|
|
30
|
+
...new Set(mappers.map((m) => m.status).filter((s) => s !== null)),
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
// get all statuses in one query
|
|
34
|
+
const statusMap = new Map();
|
|
35
|
+
if (distinctStatuses.length > 0) {
|
|
36
|
+
const statuses = await this.dataSource.query(
|
|
37
|
+
`SELECT id, name FROM cr_list_master_items WHERE id IN (?)`,
|
|
38
|
+
[distinctStatuses],
|
|
39
|
+
);
|
|
40
|
+
statuses.forEach((status) => {
|
|
41
|
+
statusMap.set(status.id, status.name);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// map status names to mappers
|
|
46
|
+
|
|
30
47
|
return mappers.map((m) => ({
|
|
31
48
|
id: m.id,
|
|
32
49
|
label: m.name,
|
|
33
50
|
value: m.id,
|
|
34
51
|
code: m.code,
|
|
35
|
-
status: m.status,
|
|
52
|
+
status: statusMap.get(m.status) || null,
|
|
36
53
|
}));
|
|
37
54
|
}
|
|
38
55
|
|
|
39
56
|
async deleteEntity(entityType: string, entityId: number, loggedInUser) {
|
|
40
|
-
|
|
41
|
-
|
|
57
|
+
let fieldMappers =
|
|
58
|
+
await this.fieldMapperRepository.findByMapperId(entityId);
|
|
42
59
|
|
|
43
60
|
for (const fieldMapper of fieldMappers) {
|
|
44
61
|
await this.fieldLovsRepository.deleteByMapperFieldId(fieldMapper.id);
|
|
@@ -53,4 +70,4 @@ export class MapperService extends EntityServiceImpl {
|
|
|
53
70
|
message: `Mapper deleted successfully.`,
|
|
54
71
|
};
|
|
55
72
|
}
|
|
56
|
-
}
|
|
73
|
+
}
|