Initial commit: Open sourcing all of the Maple Open Technologies code.
This commit is contained in:
commit
755d54a99d
2010 changed files with 448675 additions and 0 deletions
33
native/desktop/maplefile/internal/usecase/session/create.go
Normal file
33
native/desktop/maplefile/internal/usecase/session/create.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/session"
|
||||
)
|
||||
|
||||
type CreateUseCase struct {
|
||||
sessionRepo session.Repository
|
||||
}
|
||||
|
||||
// ProvideCreateUseCase creates the use case for Wire
|
||||
func ProvideCreateUseCase(sessionRepo session.Repository) *CreateUseCase {
|
||||
return &CreateUseCase{sessionRepo: sessionRepo}
|
||||
}
|
||||
|
||||
// Execute creates and stores a new session
|
||||
func (uc *CreateUseCase) Execute(
|
||||
userID, email, accessToken, refreshToken string,
|
||||
expiresIn time.Duration,
|
||||
) error {
|
||||
sess := &session.Session{
|
||||
UserID: userID,
|
||||
Email: email,
|
||||
AccessToken: accessToken,
|
||||
RefreshToken: refreshToken,
|
||||
ExpiresAt: time.Now().Add(expiresIn),
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
return uc.sessionRepo.Save(sess)
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/session/delete.go
Normal file
19
native/desktop/maplefile/internal/usecase/session/delete.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/session"
|
||||
)
|
||||
|
||||
type DeleteUseCase struct {
|
||||
sessionRepo session.Repository
|
||||
}
|
||||
|
||||
// ProvideDeleteUseCase creates the use case for Wire
|
||||
func ProvideDeleteUseCase(sessionRepo session.Repository) *DeleteUseCase {
|
||||
return &DeleteUseCase{sessionRepo: sessionRepo}
|
||||
}
|
||||
|
||||
// Execute deletes the current session
|
||||
func (uc *DeleteUseCase) Execute() error {
|
||||
return uc.sessionRepo.Delete()
|
||||
}
|
||||
19
native/desktop/maplefile/internal/usecase/session/getbyid.go
Normal file
19
native/desktop/maplefile/internal/usecase/session/getbyid.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/session"
|
||||
)
|
||||
|
||||
type GetByIdUseCase struct {
|
||||
sessionRepo session.Repository
|
||||
}
|
||||
|
||||
// ProvideGetByIdUseCase creates the use case for Wire
|
||||
func ProvideGetByIdUseCase(sessionRepo session.Repository) *GetByIdUseCase {
|
||||
return &GetByIdUseCase{sessionRepo: sessionRepo}
|
||||
}
|
||||
|
||||
// Execute retrieves the current session
|
||||
func (uc *GetByIdUseCase) Execute() (*session.Session, error) {
|
||||
return uc.sessionRepo.Get()
|
||||
}
|
||||
22
native/desktop/maplefile/internal/usecase/session/save.go
Normal file
22
native/desktop/maplefile/internal/usecase/session/save.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/session"
|
||||
)
|
||||
|
||||
type SaveUseCase struct {
|
||||
sessionRepo session.Repository
|
||||
}
|
||||
|
||||
// ProvideSaveUseCase creates the use case for Wire
|
||||
func ProvideSaveUseCase(sessionRepo session.Repository) *SaveUseCase {
|
||||
return &SaveUseCase{sessionRepo: sessionRepo}
|
||||
}
|
||||
|
||||
// Execute saves an existing session (for updates)
|
||||
func (uc *SaveUseCase) Execute(sess *session.Session) error {
|
||||
if sess == nil {
|
||||
return nil
|
||||
}
|
||||
return uc.sessionRepo.Save(sess)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue