feat: get all ads

This commit is contained in:
ericprd
2025-03-09 00:55:40 +08:00
parent 213d370332
commit 1ae192ccef
7 changed files with 61 additions and 4 deletions
+32
View File
@@ -0,0 +1,32 @@
package adshttp
import (
adssvc "legalgo-BE-go/internal/services/ads"
"legalgo-BE-go/internal/utilities/response"
"net/http"
"github.com/go-chi/chi/v5"
)
func GetAll(
router chi.Router,
adsSvc adssvc.Ads,
) {
router.Get("/ads", func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
subsPlan, err := adsSvc.GetAll()
if err != nil {
response.ResponseWithErrorCode(
ctx,
w,
err,
response.ErrBadRequest.Code,
response.ErrBadRequest.HttpCode,
err.Error(),
)
return
}
response.RespondJsonSuccess(ctx, w, subsPlan)
})
}
+1
View File
@@ -4,4 +4,5 @@ import "go.uber.org/fx"
var Module = fx.Module("ads-http", fx.Invoke(
Create,
GetAll,
))