-
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
54148fb
commit 90e5473
Showing
10 changed files
with
171 additions
and
488 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
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,62 @@ | ||
package teams | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/zeiss/service-lens/internal/models" | ||
"github.com/zeiss/service-lens/internal/ports" | ||
|
||
"github.com/go-playground/validator/v10" | ||
htmx "github.com/zeiss/fiber-htmx" | ||
) | ||
|
||
const ( | ||
listTeamURL = "/site/teams" | ||
) | ||
|
||
var validate *validator.Validate | ||
|
||
// CreateTeamControllerImpl ... | ||
type CreateTeamControllerImpl struct { | ||
team models.Team | ||
store ports.Datastore | ||
htmx.DefaultController | ||
} | ||
|
||
// NewCreateTeamController ... | ||
func NewCreateTeamController(store ports.Datastore) *CreateTeamControllerImpl { | ||
return &CreateTeamControllerImpl{ | ||
store: store, | ||
} | ||
} | ||
|
||
// Error ... | ||
func (l *CreateTeamControllerImpl) Error(err error) error { | ||
fmt.Println() | ||
return err | ||
} | ||
|
||
// Prepare ... | ||
func (l *CreateTeamControllerImpl) Prepare() error { | ||
validate = validator.New() | ||
|
||
err := l.BindBody(&l.team) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = validate.Struct(&l.team) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return l.store.ReadWriteTx(l.Context(), func(ctx context.Context, tx ports.ReadWriteTx) error { | ||
return tx.CreateTeam(ctx, &l.team) | ||
}) | ||
} | ||
|
||
// Post ... | ||
func (l *CreateTeamControllerImpl) Post() error { | ||
return l.Redirect(listTeamURL) | ||
} |
Oops, something went wrong.