feat: get all ads
This commit is contained in:
@@ -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)
|
||||
})
|
||||
}
|
||||
@@ -4,4 +4,5 @@ import "go.uber.org/fx"
|
||||
|
||||
var Module = fx.Module("ads-http", fx.Invoke(
|
||||
Create,
|
||||
GetAll,
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user