feat: [CODE-2573]: Allow ID to be sent in userGroupInfo object (#2923)

* feat: [CODE-2573]: Scan UserGroup ID to be returned after creation
* feat: [CODE-2573]: Allow ID to be sent in userGroupInfo object
pull/3586/head
Akhilesh Pandey 2024-11-05 16:02:19 +00:00 committed by Harness
parent 975cec7f53
commit 2f45f99f8b
2 changed files with 3 additions and 1 deletions

View File

@ -198,7 +198,7 @@ func (s *UserGroupStore) Create(
return database.ProcessSQLErrorf(ctx, err, "Failed to bind usergroup object")
}
if _, err = db.ExecContext(ctx, query, arg...); err != nil {
if err = db.QueryRowContext(ctx, query, arg...).Scan(&userGroup.ID); err != nil {
return database.ProcessSQLErrorf(ctx, err, "Failed to insert usergroup")
}

View File

@ -27,6 +27,7 @@ type UserGroup struct {
}
type UserGroupInfo struct {
ID int64 `json:"id"`
Identifier string `json:"identifier"`
Name string `json:"name"`
Description string `json:"description"`
@ -34,6 +35,7 @@ type UserGroupInfo struct {
func (u *UserGroup) ToUserGroupInfo() *UserGroupInfo {
return &UserGroupInfo{
ID: u.ID,
Identifier: u.Identifier,
Name: u.Name,
Description: u.Description,