@tomei/sso 0.59.2 → 0.60.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/sso",
3
- "version": "0.59.2",
3
+ "version": "0.60.0",
4
4
  "description": "Tomei SSO Package",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -2235,4 +2235,50 @@ export class Group extends TreeNodeBase<Group> {
2235
2235
  throw error;
2236
2236
  }
2237
2237
  }
2238
+
2239
+ public static async getGroupTree(
2240
+ groupCode: string | null,
2241
+ loginUser: LoginUser,
2242
+ dbTransaction: Transaction,
2243
+ ): Promise<Group[]> {
2244
+ try {
2245
+ const systemCode =
2246
+ ApplicationConfig.getComponentConfigValue('system-code');
2247
+ const isPrivileged = await loginUser.checkPrivileges(
2248
+ systemCode,
2249
+ 'GROUP_VIEW',
2250
+ );
2251
+
2252
+ if (!isPrivileged) {
2253
+ throw new ClassError(
2254
+ 'Group',
2255
+ 'GroupErrMsg04',
2256
+ 'User is not privileged to view group',
2257
+ );
2258
+ }
2259
+
2260
+ let groups: Group[] = [];
2261
+ if (groupCode != null) {
2262
+ let parentGroup = await Group.init(dbTransaction, groupCode);
2263
+ await parentGroup.loadChildren(dbTransaction);
2264
+ groups = parentGroup.children;
2265
+ } else {
2266
+ const data = await Group._Repo.findAll({
2267
+ where: {
2268
+ ParentGroupCode: null,
2269
+ },
2270
+ transaction: dbTransaction,
2271
+ });
2272
+
2273
+ for (const d of data) {
2274
+ const group = new Group(d.get({ plain: true }));
2275
+ groups.push(group);
2276
+ }
2277
+ }
2278
+
2279
+ return groups;
2280
+ } catch (error) {
2281
+ throw error;
2282
+ }
2283
+ }
2238
2284
  }