-
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
8225e77
commit 98d36b0
Showing
8 changed files
with
90 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package designs | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/zeiss/fiber-htmx/components/toasts" | ||
"github.com/zeiss/service-lens/internal/models" | ||
"github.com/zeiss/service-lens/internal/ports" | ||
|
||
"github.com/google/uuid" | ||
htmx "github.com/zeiss/fiber-htmx" | ||
seed "github.com/zeiss/gorm-seed" | ||
) | ||
|
||
// CommentsControllerImpl ... | ||
type CommentsControllerImpl struct { | ||
store seed.Database[ports.ReadTx, ports.ReadWriteTx] | ||
htmx.DefaultController | ||
} | ||
|
||
// NewCommentsController ... | ||
func NewCommentsController(store seed.Database[ports.ReadTx, ports.ReadWriteTx]) *CommentsControllerImpl { | ||
return &CommentsControllerImpl{store: store} | ||
} | ||
|
||
// Error ... | ||
func (l *CommentsControllerImpl) Error(err error) error { | ||
return toasts.RenderToasts( | ||
l.Ctx(), | ||
toasts.Toasts( | ||
toasts.ToastsProps{}, | ||
toasts.ToastAlertError( | ||
toasts.ToastProps{}, | ||
htmx.Text(err.Error()), | ||
), | ||
), | ||
) | ||
} | ||
|
||
// Delete ... | ||
func (l *CommentsControllerImpl) Delete() error { | ||
var params struct { | ||
DesignID uuid.UUID `json:"design_id" params:"id"` | ||
CommentID uuid.UUID `json:"Comment_id" params:"Comment_id"` | ||
} | ||
|
||
err := l.BindParams(¶ms) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return l.store.ReadWriteTx(l.Context(), func(ctx context.Context, tx ports.ReadWriteTx) error { | ||
return tx.DeleteDesignComment(ctx, &models.DesignComment{ID: params.CommentID, DesignID: params.DesignID}) | ||
}) | ||
} |
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