Chore: Move updateorg out of sqlstore (#54111)

* Chore: move updateorg out of sqlstore

* fix api test
This commit is contained in:
ying-jeanne
2022-08-23 12:26:21 -05:00
committed by GitHub
parent 5f57edd08a
commit 4dbe0b4f02
13 changed files with 83 additions and 48 deletions
@@ -100,10 +100,6 @@ func (m *SQLStoreMock) CreateOrg(ctx context.Context, cmd *models.CreateOrgComma
return m.ExpectedError
}
func (m *SQLStoreMock) UpdateOrg(ctx context.Context, cmd *models.UpdateOrgCommand) error {
return m.ExpectedError
}
func (m *SQLStoreMock) UpdateOrgAddress(ctx context.Context, cmd *models.UpdateOrgAddressCommand) error {
return m.ExpectedError
}
-33
View File
@@ -159,39 +159,6 @@ func (ss *SQLStore) CreateOrg(ctx context.Context, cmd *models.CreateOrgCommand)
return nil
}
func (ss *SQLStore) UpdateOrg(ctx context.Context, cmd *models.UpdateOrgCommand) error {
return ss.WithTransactionalDbSession(ctx, func(sess *DBSession) error {
if isNameTaken, err := isOrgNameTaken(cmd.Name, cmd.OrgId, sess); err != nil {
return err
} else if isNameTaken {
return models.ErrOrgNameTaken
}
org := models.Org{
Name: cmd.Name,
Updated: time.Now(),
}
affectedRows, err := sess.ID(cmd.OrgId).Update(&org)
if err != nil {
return err
}
if affectedRows == 0 {
return models.ErrOrgNotFound
}
sess.publishAfterCommit(&events.OrgUpdated{
Timestamp: org.Updated,
Id: org.Id,
Name: org.Name,
})
return nil
})
}
func (ss *SQLStore) UpdateOrgAddress(ctx context.Context, cmd *models.UpdateOrgAddressCommand) error {
return ss.WithTransactionalDbSession(ctx, func(sess *DBSession) error {
org := models.Org{
-1
View File
@@ -22,7 +22,6 @@ type Store interface {
GetOrgByName(name string) (*models.Org, error)
CreateOrg(ctx context.Context, cmd *models.CreateOrgCommand) error
CreateOrgWithMember(name string, userID int64) (models.Org, error)
UpdateOrg(ctx context.Context, cmd *models.UpdateOrgCommand) error
UpdateOrgAddress(ctx context.Context, cmd *models.UpdateOrgAddressCommand) error
DeleteOrg(ctx context.Context, cmd *models.DeleteOrgCommand) error
GetOrgById(context.Context, *models.GetOrgByIdQuery) error