dt-common-device 7.0.0 → 7.1.0
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/entities/admin/Admin.repository.d.ts +2 -1
- package/dist/entities/admin/Admin.repository.js +11 -0
- package/dist/entities/admin/Admin.service.d.ts +1 -0
- package/dist/entities/admin/Admin.service.js +12 -0
- package/dist/entities/admin/IAdmin.d.ts +5 -0
- package/dist/entities/pms/pms.repository.d.ts +1 -0
- package/dist/entities/pms/pms.repository.js +8 -0
- package/dist/entities/pms/pms.service.d.ts +1 -0
- package/dist/entities/pms/pms.service.js +9 -0
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { IAccessGroup, IUser, IZone } from "./IAdmin";
|
|
1
|
+
import { IAccessGroup, IUser, IZone, IZoneAccessGroup } from "./IAdmin";
|
|
2
2
|
export declare class AdminRepository {
|
|
3
3
|
private readonly deviceRepository;
|
|
4
4
|
private readonly postgres;
|
|
5
5
|
constructor();
|
|
6
6
|
getZonesByAccessGroupIds(accessGroupIds: string[]): Promise<any[]>;
|
|
7
7
|
getAccessGroup(accessGroupId: string): Promise<IAccessGroup | null>;
|
|
8
|
+
getZoneAccessGroupByZoneId(zoneId: string): Promise<IZoneAccessGroup | null>;
|
|
8
9
|
getZone(zoneId: string): Promise<IZone | null>;
|
|
9
10
|
getUser(userId: string): Promise<IUser | null>;
|
|
10
11
|
}
|
|
@@ -176,6 +176,17 @@ let AdminRepository = (() => {
|
|
|
176
176
|
}
|
|
177
177
|
return null;
|
|
178
178
|
}
|
|
179
|
+
async getZoneAccessGroupByZoneId(zoneId) {
|
|
180
|
+
const query = `
|
|
181
|
+
SELECT * FROM dt_zones_collection_map
|
|
182
|
+
WHERE "zoneId" = $1
|
|
183
|
+
`;
|
|
184
|
+
const result = await this.postgres.query(query, [zoneId]);
|
|
185
|
+
if (result.rows.length > 0) {
|
|
186
|
+
return result.rows[0];
|
|
187
|
+
}
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
179
190
|
async getZone(zoneId) {
|
|
180
191
|
try {
|
|
181
192
|
const zone = await this.postgres.query(`SELECT * FROM dt_zones WHERE "id" = $1`, [zoneId]);
|
|
@@ -4,6 +4,7 @@ export declare class AdminService {
|
|
|
4
4
|
constructor();
|
|
5
5
|
getZonesByAccessGroupIds(accessGroupIds: string[]): Promise<any[] | undefined>;
|
|
6
6
|
getAccessGroup(accessGroupId: string): Promise<IAccessGroup | null>;
|
|
7
|
+
getAccessGroupByZoneId(zoneId: string): Promise<IAccessGroup | null>;
|
|
7
8
|
getZone(zoneId: string): Promise<IZone | null>;
|
|
8
9
|
getUser(userId: string): Promise<IUser | null>;
|
|
9
10
|
}
|
|
@@ -100,6 +100,18 @@ let AdminService = (() => {
|
|
|
100
100
|
return null;
|
|
101
101
|
return accessGroup;
|
|
102
102
|
}
|
|
103
|
+
async getAccessGroupByZoneId(zoneId) {
|
|
104
|
+
if (!zoneId) {
|
|
105
|
+
throw new Error("Zone ID is required");
|
|
106
|
+
}
|
|
107
|
+
const zoneAccessGroup = await this.adminRepository.getZoneAccessGroupByZoneId(zoneId);
|
|
108
|
+
if (!zoneAccessGroup)
|
|
109
|
+
return null;
|
|
110
|
+
const accessGroup = await this.adminRepository.getAccessGroup(zoneAccessGroup.collectionId);
|
|
111
|
+
if (!accessGroup)
|
|
112
|
+
return null;
|
|
113
|
+
return accessGroup;
|
|
114
|
+
}
|
|
103
115
|
async getZone(zoneId) {
|
|
104
116
|
if (!zoneId) {
|
|
105
117
|
throw new Error("Zone ID is required");
|
|
@@ -3,6 +3,7 @@ export declare class PmsRepository {
|
|
|
3
3
|
private readonly pmsPostgres;
|
|
4
4
|
constructor();
|
|
5
5
|
getSchedule(scheduleId: string): Promise<IPmsSchedule | null>;
|
|
6
|
+
getScheduleIdByAccessGroupId(accessGroupId: string, status: string): Promise<string | null>;
|
|
6
7
|
getGuest(guestId: string): Promise<IGuest | null>;
|
|
7
8
|
getGuestId(scheduleId: string): Promise<string | null>;
|
|
8
9
|
}
|
|
@@ -63,6 +63,14 @@ let PmsRepository = (() => {
|
|
|
63
63
|
throw new Error("Failed to get schedule");
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
async getScheduleIdByAccessGroupId(accessGroupId, status) {
|
|
67
|
+
const scheduleId = await this.pmsPostgres.query(`SELECT "scheduleId" FROM dt_schedule_accessgroup_map WHERE "accessGroupId" = $1 AND "status" = $2`, [accessGroupId, status]);
|
|
68
|
+
//TODO: Need to Check if only one Schedule is there for the given Access Group in checked-in state!
|
|
69
|
+
if (scheduleId.rows.length > 0) {
|
|
70
|
+
return scheduleId.rows[0].scheduleId;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
66
74
|
async getGuest(guestId) {
|
|
67
75
|
try {
|
|
68
76
|
const guest = await this.pmsPostgres.query(`SELECT * FROM dt_guest WHERE "id" = $1`, [guestId]);
|
|
@@ -3,6 +3,7 @@ export declare class PmsService {
|
|
|
3
3
|
private readonly pmsRepository;
|
|
4
4
|
constructor();
|
|
5
5
|
getSchedule(scheduleId: string): Promise<IPmsSchedule | null>;
|
|
6
|
+
getScheduleIdByAccessGroupId(accessGroupId: string, status: string): Promise<string | null>;
|
|
6
7
|
getGuest(guestId: string): Promise<IGuest | null>;
|
|
7
8
|
getGuestId(scheduleId: string): Promise<string | null>;
|
|
8
9
|
}
|
|
@@ -92,6 +92,15 @@ let PmsService = (() => {
|
|
|
92
92
|
return null;
|
|
93
93
|
return schedule;
|
|
94
94
|
}
|
|
95
|
+
async getScheduleIdByAccessGroupId(accessGroupId, status) {
|
|
96
|
+
if (!accessGroupId) {
|
|
97
|
+
throw new Error("Access Group ID is required");
|
|
98
|
+
}
|
|
99
|
+
const scheduleId = await this.pmsRepository.getScheduleIdByAccessGroupId(accessGroupId, status);
|
|
100
|
+
if (!scheduleId)
|
|
101
|
+
return null;
|
|
102
|
+
return scheduleId;
|
|
103
|
+
}
|
|
95
104
|
async getGuest(guestId) {
|
|
96
105
|
if (!guestId) {
|
|
97
106
|
throw new Error("Guest ID is required");
|