From 458cc25dedf5fa362401af58618ac6340ed76f46 Mon Sep 17 00:00:00 2001 From: mm Date: Tue, 29 Oct 2024 23:14:51 +0500 Subject: [PATCH] dev --- internal/api/http/handlers/target/target.go | 5 +++++ internal/repository/target/target.go | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/api/http/handlers/target/target.go b/internal/api/http/handlers/target/target.go index 64ad184..a788a4d 100644 --- a/internal/api/http/handlers/target/target.go +++ b/internal/api/http/handlers/target/target.go @@ -62,6 +62,11 @@ func GetAllTarget(targetService model.TargetService) echo.HandlerFunc { return request.JSON(http.StatusInternalServerError, err.Error()) } + if len(targets) == 0 { + slog.Error("target not found") + return request.JSON(http.StatusInternalServerError, "target not found") + } + return request.JSON(http.StatusOK, targets) } } diff --git a/internal/repository/target/target.go b/internal/repository/target/target.go index 2a35314..c0efd5c 100644 --- a/internal/repository/target/target.go +++ b/internal/repository/target/target.go @@ -4,7 +4,6 @@ import ( "context" "donat-widget/internal/model" "donat-widget/internal/model/sql" - "errors" "github.com/georgysavva/scany/v2/pgxscan" "github.com/jackc/pgx/v5" "log/slog" @@ -59,9 +58,6 @@ func (targetRepo *RepoTarget) GetAllTarget( slog.Error(err.Error()) return nil, err } - if len(targets) == 0 { - return nil, errors.New("donat not found") - } return targets, nil