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
|
|
@ -0,0 +1,42 @@
|
|||
package site
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
domainsite "codeberg.org/mapleopentech/monorepo/cloud/maplepress-backend/internal/domain/site"
|
||||
)
|
||||
|
||||
// UpdateSiteAPIKeyUseCase updates a site entity with new API key details
|
||||
type UpdateSiteAPIKeyUseCase struct {
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
// ProvideUpdateSiteAPIKeyUseCase creates a new UpdateSiteAPIKeyUseCase
|
||||
func ProvideUpdateSiteAPIKeyUseCase(logger *zap.Logger) *UpdateSiteAPIKeyUseCase {
|
||||
return &UpdateSiteAPIKeyUseCase{
|
||||
logger: logger,
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateSiteAPIKeyInput contains the new API key details
|
||||
type UpdateSiteAPIKeyInput struct {
|
||||
Site *domainsite.Site
|
||||
NewAPIKeyHash string
|
||||
NewKeyPrefix string
|
||||
NewKeyLastFour string
|
||||
}
|
||||
|
||||
// Execute updates the site entity with new API key details
|
||||
func (uc *UpdateSiteAPIKeyUseCase) Execute(input *UpdateSiteAPIKeyInput) {
|
||||
input.Site.APIKeyHash = input.NewAPIKeyHash
|
||||
input.Site.APIKeyPrefix = input.NewKeyPrefix
|
||||
input.Site.APIKeyLastFour = input.NewKeyLastFour
|
||||
input.Site.UpdatedAt = time.Now()
|
||||
|
||||
uc.logger.Debug("site entity updated with new API key",
|
||||
zap.String("site_id", input.Site.ID.String()),
|
||||
zap.String("new_prefix", input.NewKeyPrefix),
|
||||
zap.String("new_last_four", input.NewKeyLastFour))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue