-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd08992
commit 9f05a98
Showing
11 changed files
with
652 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package db | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/google/uuid" | ||
"github.com/zeiss/typhoon/internal/api/models" | ||
) | ||
|
||
// CreateTeam creates a new team. | ||
func (db *DB) CreateTeam(ctx context.Context, team models.Team) (models.Team, error) { | ||
if err := db.conn.WithContext(ctx).Create(&team).Error; err != nil { | ||
return models.Team{}, err | ||
} | ||
|
||
return team, nil | ||
} | ||
|
||
// GetTeam retrieves a team by its ID. | ||
func (db *DB) GetTeam(ctx context.Context, id uuid.UUID) (models.Team, error) { | ||
team := models.Team{} | ||
if err := db.conn.WithContext(ctx).Where("id = ?", id).First(&team).Error; err != nil { | ||
return models.Team{}, err | ||
} | ||
|
||
return team, nil | ||
} | ||
|
||
// DeleteTeam deletes a team by its ID. | ||
func (db *DB) DeleteTeam(ctx context.Context, id uuid.UUID) error { | ||
return db.conn.WithContext(ctx).Where("id = ?", id).Delete(&models.Team{}).Error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
package ports | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/google/uuid" | ||
"github.com/zeiss/typhoon/internal/api/models" | ||
) | ||
|
||
// Teams is the interface that wraps the methods to access data. | ||
type Teams interface{} | ||
type Teams interface { | ||
// CreateTeam creates a new team. | ||
CreateTeam(ctx context.Context, team models.Team) (models.Team, error) | ||
// GetTeam returns the team with the given id. | ||
GetTeam(ctx context.Context, id uuid.UUID) (models.Team, error) | ||
// DeleteTeam deletes the team with the given id. | ||
DeleteTeam(ctx context.Context, id uuid.UUID) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.