@tomei/sso 0.42.0 → 0.43.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/components/group-reporting-user/group-reporting-user.js +15 -1
- package/dist/src/components/group-reporting-user/group-reporting-user.js.map +1 -1
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/group-reporting-user/group-reporting-user.ts +25 -2
- package/src/components/index.ts +1 -0
package/package.json
CHANGED
@@ -90,7 +90,8 @@ export class GroupReportingUser extends ObjectBase {
|
|
90
90
|
userId: number, //The ID of the user to be added to the group.
|
91
91
|
rank: number, //The rank to be assigned to the user in the group.
|
92
92
|
status: 'Active' | 'Inactive', //The initial status of the user in the group.
|
93
|
-
): Promise<GroupReportingUser> {
|
93
|
+
): Promise<GroupReportingUser> {
|
94
|
+
// Returns a GroupReportingUser instance representing the newly created record.
|
94
95
|
try {
|
95
96
|
//Creates a new group reporting user entry in the sso_GroupReportingUser table.
|
96
97
|
|
@@ -114,7 +115,7 @@ export class GroupReportingUser extends ObjectBase {
|
|
114
115
|
throw new ClassError(
|
115
116
|
'GroupReportingUser',
|
116
117
|
'GroupReportingUserErrMsg02',
|
117
|
-
'
|
118
|
+
'Insufficient privileges to add a user to the group',
|
118
119
|
);
|
119
120
|
}
|
120
121
|
|
@@ -136,6 +137,24 @@ export class GroupReportingUser extends ObjectBase {
|
|
136
137
|
'createGroupReportingUser',
|
137
138
|
);
|
138
139
|
}
|
140
|
+
//Query the sso_GroupReportingUser table to see if the rank already exists in the specified groupCode.
|
141
|
+
//If the rank already exists in the group, throw an error indicating the rank is already in of the group.
|
142
|
+
const groupReportingUserRank = await GroupReportingUser._Repo.findOne({
|
143
|
+
where: {
|
144
|
+
GroupCode: groupCode,
|
145
|
+
Rank: rank,
|
146
|
+
},
|
147
|
+
transaction: dbTransaction,
|
148
|
+
});
|
149
|
+
if (groupReportingUserRank) {
|
150
|
+
throw new ClassError(
|
151
|
+
'GroupReportingUser',
|
152
|
+
'GroupReportingUserErrMsg04',
|
153
|
+
'Rank already exists in the group',
|
154
|
+
'createGroupReportingUser',
|
155
|
+
);
|
156
|
+
}
|
157
|
+
|
139
158
|
// Create GroupReportingUser Entry
|
140
159
|
// If validation and privilege checks pass, insert a new record in the sso_GroupReportingUser table with the provided groupCode, userId, rank, status, and loginUser.UserId.Automatically capture the current timestamp for CreatedAt.
|
141
160
|
this.GroupCode = groupCode;
|
@@ -144,6 +163,8 @@ export class GroupReportingUser extends ObjectBase {
|
|
144
163
|
this.Status = status;
|
145
164
|
this._CreatedById = loginUser.UserId;
|
146
165
|
this._CreatedAt = new Date();
|
166
|
+
this._UpdatedAt = new Date();
|
167
|
+
this._UpdatedById = loginUser.UserId;
|
147
168
|
|
148
169
|
const entityValueAfter: any = {
|
149
170
|
GroupCode: groupCode,
|
@@ -152,6 +173,8 @@ export class GroupReportingUser extends ObjectBase {
|
|
152
173
|
Status: status,
|
153
174
|
CreatedById: loginUser.UserId,
|
154
175
|
CreatedAt: this._CreatedAt,
|
176
|
+
UpdatedById: loginUser.UserId,
|
177
|
+
UpdatedAt: this._UpdatedAt,
|
155
178
|
};
|
156
179
|
|
157
180
|
const newGroupReportingUser = await GroupReportingUser._Repo.create(
|