dt-common-device 11.1.9 → 11.1.10
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.
|
@@ -6,7 +6,7 @@ export declare class AdminRepository {
|
|
|
6
6
|
constructor();
|
|
7
7
|
getZonesByAccessGroupIds(accessGroupIds: string[]): Promise<any[]>;
|
|
8
8
|
getZonesByAccessGroups(accessGroupIds: string[]): Promise<any[]>;
|
|
9
|
-
getAccessGroup(accessGroupId: string): Promise<IAccessGroup | null>;
|
|
9
|
+
getAccessGroup(accessGroupId: string, propertyId?: string): Promise<IAccessGroup | null>;
|
|
10
10
|
getZoneAccessGroupByZoneId(zoneId: string): Promise<IZoneAccessGroup[] | null>;
|
|
11
11
|
getZone(zoneId: string, propertyId?: string): Promise<IZone | null>;
|
|
12
12
|
getUser(userId: string): Promise<IUser | null>;
|
|
@@ -245,11 +245,20 @@ let AdminRepository = (() => {
|
|
|
245
245
|
]);
|
|
246
246
|
return zonesResult.rows.map((e) => e.id);
|
|
247
247
|
}
|
|
248
|
-
async getAccessGroup(accessGroupId) {
|
|
249
|
-
|
|
248
|
+
async getAccessGroup(accessGroupId, propertyId) {
|
|
249
|
+
let query;
|
|
250
|
+
if (propertyId) {
|
|
251
|
+
query = `
|
|
252
|
+
SELECT * FROM dt_collections
|
|
253
|
+
WHERE "id" = $1 AND "propertyId" = $2
|
|
254
|
+
`;
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
query = `
|
|
250
258
|
SELECT * FROM dt_collections
|
|
251
259
|
WHERE "id" = $1
|
|
252
|
-
|
|
260
|
+
`;
|
|
261
|
+
}
|
|
253
262
|
const result = await this.postgres.query(query, [accessGroupId]);
|
|
254
263
|
if (result.rows.length > 0) {
|
|
255
264
|
return result.rows[0];
|
|
@@ -5,7 +5,7 @@ export declare class AdminService {
|
|
|
5
5
|
constructor();
|
|
6
6
|
getZonesByAccessGroupIds(accessGroupIds: string[]): Promise<any[] | undefined>;
|
|
7
7
|
getZonesByAccessGroups(accessGroupIds: string[]): Promise<any[] | undefined>;
|
|
8
|
-
getAccessGroup(accessGroupId: string): Promise<IAccessGroup | null>;
|
|
8
|
+
getAccessGroup(accessGroupId: string, propertyId?: string): Promise<IAccessGroup | null>;
|
|
9
9
|
getAccessGroupByZoneId(zoneId: string): Promise<IAccessGroup[] | []>;
|
|
10
10
|
getZone(zoneId: string, propertyId?: string): Promise<IZone | null>;
|
|
11
11
|
getUser(userId: string): Promise<IUser | null>;
|
|
@@ -101,13 +101,20 @@ let AdminService = (() => {
|
|
|
101
101
|
console.log(error);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
async getAccessGroup(accessGroupId) {
|
|
104
|
+
async getAccessGroup(accessGroupId, propertyId) {
|
|
105
105
|
if (!accessGroupId) {
|
|
106
106
|
throw new Error("Access Group ID is required");
|
|
107
107
|
}
|
|
108
|
-
|
|
108
|
+
let accessGroup;
|
|
109
|
+
const redisKey = `collection:${accessGroupId}`;
|
|
110
|
+
accessGroup = await this.redisUtils.hget(redisKey, accessGroupId);
|
|
111
|
+
if (accessGroup)
|
|
112
|
+
return accessGroup;
|
|
113
|
+
accessGroup = await this.adminRepository.getAccessGroup(accessGroupId, propertyId);
|
|
109
114
|
if (!accessGroup)
|
|
110
115
|
return null;
|
|
116
|
+
await this.redisUtils.hsetWithTTL(redisKey, accessGroup?.id, JSON.stringify(accessGroup), 86400);
|
|
117
|
+
await this.redisUtils.sadd(`property_collections:${accessGroup?.propertyId}`, accessGroup?.id);
|
|
111
118
|
return accessGroup;
|
|
112
119
|
}
|
|
113
120
|
async getAccessGroupByZoneId(zoneId) {
|