This commit is contained in:
mm 2024-10-29 23:14:51 +05:00
parent 07feb21880
commit 458cc25ded
2 changed files with 5 additions and 4 deletions

View File

@ -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)
}
}

View File

@ -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