eh-commons 0.0.2-testing.78 → 0.0.2-testing.80
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/modules/session/services/session-v2.service.d.ts +3 -1
- package/dist/modules/session/services/session-v2.service.js +42 -0
- package/dist/modules/session/services/session-v2.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/modules/session/services/session-v2.service.ts +49 -0
package/package.json
CHANGED
|
@@ -109,5 +109,54 @@ export class SessionV2Service {
|
|
|
109
109
|
}
|
|
110
110
|
return userSessionToken;
|
|
111
111
|
}
|
|
112
|
+
|
|
113
|
+
public async readUserClient(userId: string, clientId: string): Promise<ISessionClientData> {
|
|
114
|
+
const key = generateUserClientPermissionKeyword(userId, clientId);
|
|
115
|
+
const response = await this._redisService.get(key);
|
|
116
|
+
if (!response) {
|
|
117
|
+
throw new RESTError('user_client_not_found', clientId, 400);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const result: any = JSON.parse(response);
|
|
121
|
+
if (!result || !result.client) {
|
|
122
|
+
throw new RESTError('user_client_not_found', 'json parse', 400);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
clientId: result.client._id,
|
|
127
|
+
type: result.client.type,
|
|
128
|
+
name: result.client.name,
|
|
129
|
+
address: result.client.address,
|
|
130
|
+
highland: result.client.highland,
|
|
131
|
+
code: result.client.code,
|
|
132
|
+
contacts: result.client.contacts,
|
|
133
|
+
region: result.client.region,
|
|
134
|
+
district: result.client.district,
|
|
135
|
+
languageSectors: result.client.languageSectors,
|
|
136
|
+
levels: result.client.levels,
|
|
137
|
+
subjects: result.client.subjects,
|
|
138
|
+
permissions: result.permissions
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
public async readUserClients(userId: string, clientId: string): Promise<ISessionClientData[]> {
|
|
143
|
+
const key = generateUserClientsKeyword(userId);
|
|
144
|
+
const response = await this._redisService.get(key);
|
|
145
|
+
if (!response) {
|
|
146
|
+
throw new RESTError('user_clients_not_found', clientId, 400);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const result: any = JSON.parse(response);
|
|
150
|
+
if (!result) {
|
|
151
|
+
throw new RESTError('user_clients_not_found', 'json parse', 400);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const clients: ISessionClientData[] = [];
|
|
155
|
+
for (const key in result) {
|
|
156
|
+
clients.push(result[key]);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return clients;
|
|
160
|
+
}
|
|
112
161
|
//#endregion
|
|
113
162
|
}
|