Chore: Add methods from sqlstore to org service interface (#55635)

* Chore: Copy methods from sqlstore to org store

* Rename method, add test

* Add comments of tests

* Chore: Add methods from sqlstore to org service interface

* Avoiding import cycle

* Add and remove some methods
This commit is contained in:
idafurjes
2022-09-23 09:58:17 +02:00
committed by GitHub
parent c9b5acfefc
commit e8a60c1988
4 changed files with 95 additions and 0 deletions
+33
View File
@@ -211,3 +211,36 @@ func (s *Service) GetOrCreate(ctx context.Context, orgName string) (int64, error
}
return orga.ID, nil
}
// TODO: remove wrapper around sqlstore
func (s *Service) AddOrgUser(ctx context.Context, cmd *org.AddOrgUserCommand) error {
c := &models.AddOrgUserCommand{
LoginOrEmail: cmd.LoginOrEmail,
OrgId: cmd.OrgID,
UserId: cmd.UserID,
Role: cmd.Role,
AllowAddingServiceAccount: cmd.AllowAddingServiceAccount,
}
return s.sqlStore.AddOrgUser(ctx, c)
}
// TODO: remove wrapper around sqlstore
func (s *Service) UpdateOrgUser(ctx context.Context, cmd *org.UpdateOrgUserCommand) error {
c := &models.UpdateOrgUserCommand{
UserId: cmd.UserID,
OrgId: cmd.OrgID,
Role: cmd.Role,
}
return s.sqlStore.UpdateOrgUser(ctx, c)
}
// TODO: remove wrapper around sqlstore
func (s *Service) RemoveOrgUser(ctx context.Context, cmd *org.RemoveOrgUserCommand) error {
c := &models.RemoveOrgUserCommand{
UserId: cmd.UserID,
OrgId: cmd.OrgID,
ShouldDeleteOrphanedUser: cmd.ShouldDeleteOrphanedUser,
UserWasDeleted: cmd.UserWasDeleted,
}
return s.sqlStore.RemoveOrgUser(ctx, c)
}