feat: get all plans and improvement
This commit is contained in:
@@ -45,7 +45,7 @@ func CreateSubscribePlan(
|
||||
return
|
||||
}
|
||||
|
||||
if err := subsSvc.CreatePlan(spec.Code); err != nil {
|
||||
if err := subsSvc.CreatePlan(spec); err != nil {
|
||||
response.ResponseWithErrorCode(
|
||||
ctx,
|
||||
w,
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package subscribeplanhttp
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
subscribeplansvc "github.com/ardeman/project-legalgo-go/internal/services/subscribe_plan"
|
||||
"github.com/ardeman/project-legalgo-go/internal/utilities/response"
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
func GetAllPlan(
|
||||
router chi.Router,
|
||||
subsPlanSvc subscribeplansvc.SubsPlanIntf,
|
||||
) {
|
||||
router.Get("/get-plans", func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
subsPlan, err := subsPlanSvc.GetAllPlan()
|
||||
if err != nil {
|
||||
response.ResponseWithErrorCode(
|
||||
ctx,
|
||||
w,
|
||||
err,
|
||||
response.ErrBadRequest.Code,
|
||||
response.ErrBadRequest.HttpCode,
|
||||
response.ErrBadRequest.Message,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
response.RespondJsonSuccess(ctx, w, subsPlan)
|
||||
})
|
||||
}
|
||||
@@ -5,5 +5,6 @@ import "go.uber.org/fx"
|
||||
var Module = fx.Module("subscribe-plan",
|
||||
fx.Invoke(
|
||||
CreateSubscribePlan,
|
||||
GetAllPlan,
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user