2025-03-01 21:20:51 +08:00
|
|
|
package categoryhttp
|
2025-03-01 20:00:54 +08:00
|
|
|
|
|
|
|
|
import (
|
2025-03-01 21:20:51 +08:00
|
|
|
categorysvc "legalgo-BE-go/internal/services/category"
|
2025-03-01 20:00:54 +08:00
|
|
|
"legalgo-BE-go/internal/utilities/response"
|
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
|
)
|
|
|
|
|
|
2025-03-01 21:20:51 +08:00
|
|
|
func GetAll(
|
2025-03-01 20:00:54 +08:00
|
|
|
router chi.Router,
|
2025-03-01 21:20:51 +08:00
|
|
|
categorySvc categorysvc.Category,
|
2025-03-01 20:00:54 +08:00
|
|
|
) {
|
2025-03-01 21:20:51 +08:00
|
|
|
router.Get("/category", func(w http.ResponseWriter, r *http.Request) {
|
2025-03-01 20:00:54 +08:00
|
|
|
ctx := r.Context()
|
2025-03-02 04:36:17 +08:00
|
|
|
subsPlan, err := categorySvc.GetAllModel()
|
|
|
|
|
// subsPlan, err := categorySvc.GetAll()
|
2025-03-01 20:00:54 +08:00
|
|
|
if err != nil {
|
|
|
|
|
response.ResponseWithErrorCode(
|
|
|
|
|
ctx,
|
|
|
|
|
w,
|
|
|
|
|
err,
|
|
|
|
|
response.ErrBadRequest.Code,
|
|
|
|
|
response.ErrBadRequest.HttpCode,
|
|
|
|
|
err.Error(),
|
|
|
|
|
)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
response.RespondJsonSuccess(ctx, w, subsPlan)
|
|
|
|
|
})
|
|
|
|
|
}
|