refactor structure

This commit is contained in:
Sas Andy
2024-05-08 15:26:14 +07:00
parent ac97487b9b
commit 9ae7e495c6
100 changed files with 2337 additions and 447 deletions

View File

@@ -1,4 +1,4 @@
package handlers
package dev_handlers
import (
"crypto/md5"
@@ -8,12 +8,14 @@ import (
"strings"
"time"
kelainanglobal "cpone/views/dev/mcu/kelainan_global"
mcupeserta "cpone/views/dev/mcu/peserta"
"cpone/views/dev/piechart"
"cpone/views/dev/xsample"
services "cpone/services/dev"
"github.com/a-h/templ"
"github.com/emarifer/go-templ-project-structure/services"
kelainanglobal "github.com/emarifer/go-templ-project-structure/views/mcu/kelainan_global"
mcupeserta "github.com/emarifer/go-templ-project-structure/views/mcu/peserta"
"github.com/emarifer/go-templ-project-structure/views/piechart"
"github.com/emarifer/go-templ-project-structure/views/xsample"
"github.com/labstack/echo/v4"
)

View File

@@ -1,11 +1,13 @@
package handlers
package dev_handlers
import (
"fmt"
"cpone/views/dev/employee"
services "cpone/services/dev"
"github.com/a-h/templ"
"github.com/emarifer/go-templ-project-structure/services"
"github.com/emarifer/go-templ-project-structure/views/employee"
"github.com/labstack/echo/v4"
)

View File

@@ -1,11 +1,13 @@
package handlers
package dev_handlers
import (
"fmt"
landingpage "cpone/views/dev/landingpage"
"github.com/a-h/templ"
"github.com/emarifer/go-templ-project-structure/services"
landingpage "github.com/emarifer/go-templ-project-structure/views/landingpage"
services "cpone/services/dev"
"github.com/labstack/echo/v4"
)

View File

@@ -1,9 +1,11 @@
package handlers
package dev_handlers
import (
"cpone/views/dev/login"
"github.com/a-h/templ"
"github.com/emarifer/go-templ-project-structure/services"
"github.com/emarifer/go-templ-project-structure/views/login"
services "cpone/services/dev"
"github.com/labstack/echo/v4"
)

View File

@@ -1,17 +1,19 @@
package handlers
package dev_handlers
import (
"fmt"
"net/url"
"strconv"
"cpone/component/customtextfieldautocomplete"
"cpone/component/pagination"
tablecomponent "cpone/component/table"
"cpone/models"
mastermenuusergroup "cpone/views/dev/mastermenuusergroup"
services "cpone/services/dev"
"github.com/a-h/templ"
"github.com/emarifer/go-templ-project-structure/models"
"github.com/emarifer/go-templ-project-structure/services"
"github.com/emarifer/go-templ-project-structure/views/component/customtextfieldautocomplete"
"github.com/emarifer/go-templ-project-structure/views/component/pagination"
tablecomponent "github.com/emarifer/go-templ-project-structure/views/component/table"
mastermenuusergroup "github.com/emarifer/go-templ-project-structure/views/mastermenuusergroup"
"github.com/labstack/echo/v4"
)

View File

@@ -1,14 +1,14 @@
package handlers
package dev_handlers
import (
services "cpone/services/dev"
"cpone/views/dev/user"
"fmt"
"net/http"
"strconv"
"strings"
"github.com/a-h/templ"
"github.com/emarifer/go-templ-project-structure/services"
"github.com/emarifer/go-templ-project-structure/views/user"
"github.com/labstack/echo/v4"
"golang.org/x/text/cases"

View File

@@ -1,13 +1,14 @@
package handlers
package dev_handlers
import (
"fmt"
"strconv"
services "cpone/services/dev"
"cpone/utils"
"cpone/views/dev/xsample"
"github.com/a-h/templ"
"github.com/emarifer/go-templ-project-structure/services"
"github.com/emarifer/go-templ-project-structure/utils"
"github.com/emarifer/go-templ-project-structure/views/xsample"
"github.com/labstack/echo/v4"
)

View File

@@ -0,0 +1,64 @@
package public_handlers
import (
public_services "cpone/services/public"
public_landingpage "cpone/views/public/landingpage"
"fmt"
"github.com/a-h/templ"
"github.com/labstack/echo/v4"
)
type LandingPageService interface {
GetClientService() ([]public_services.ClientService, error)
GetClientAdvantage() ([]public_services.AdvantageClient, error)
GetPromotionList() ([]public_services.Promotion, error)
GetFooterNavList() ([]public_services.FooterNav, error)
}
func NewLandingPageHandler(us LandingPageService) *LandingPageHandler {
return &LandingPageHandler{
LandingPageService: us,
}
}
type LandingPageHandler struct {
LandingPageService LandingPageService
}
func (uh *LandingPageHandler) ShowLandingPage(c echo.Context) error {
udata, err := uh.LandingPageService.GetClientService()
if err != nil {
// fmt.Println(err)
return err
}
adData, err := uh.LandingPageService.GetClientAdvantage()
if err != nil {
// fmt.Println(err)
return err
}
lpData, err := uh.LandingPageService.GetPromotionList()
if err != nil {
// fmt.Println(err)
return err
}
ftNav, err := uh.LandingPageService.GetFooterNavList()
if err != nil {
return err
}
fmt.Printf("%+v\n", udata)
helo := public_landingpage.ShowLandingPage("Hello World",
public_landingpage.MainLandingPage(public_landingpage.ListMedicalService(udata),
public_landingpage.ListAdvantage(adData), public_landingpage.ListPromotion(lpData),
public_landingpage.FooterSection(ftNav)),
public_landingpage.CssLandingPage(),
public_landingpage.JsLandingPage())
return uh.View(c, helo)
}
func (uh *LandingPageHandler) View(c echo.Context, cmp templ.Component) error {
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
return cmp.Render(c.Request().Context(), c.Response().Writer)
}

View File

@@ -1,8 +1,16 @@
package handlers
import "github.com/labstack/echo/v4"
import (
dev_handlers "cpone/handlers/dev"
public_handlers "cpone/handlers/public"
public_services "cpone/services/public"
func SetupRoutes(app *echo.Echo, h *UserHandler) {
"cpone/db"
"github.com/labstack/echo/v4"
)
func SetupRoutes(app *echo.Echo, h *dev_handlers.UserHandler) {
group := app.Group("/user")
group.GET("", h.HandlerShowUsers)
@@ -10,19 +18,19 @@ func SetupRoutes(app *echo.Echo, h *UserHandler) {
}
//PLAYGROUND TESTING
func SetupRoutesLogin(app *echo.Echo, h *LoginHandler) {
// PLAYGROUND TESTING
func SetupRoutesLogin(app *echo.Echo, h *dev_handlers.LoginHandler) {
l := app.Group("/login")
l.GET("/", h.HandlerShowLogin)
}
func SetupRoutesXsample(app *echo.Echo, h *XsampleHandler) {
func SetupRoutesXsample(app *echo.Echo, h *dev_handlers.XsampleHandler) {
xSample := app.Group("/xsample")
xSample.GET("/xsample01", h.Hello)
xSample.GET("/coba", h.ShowCoba)
xSample.GET("/counter", h.ShowCounter)
xSample.GET("/counterchange", h.ChangeCounter)
}
func SetupRoutesLandingPage(app *echo.Echo, h *LandingPageHandler, mastermenuusergroupHandler *MasterMenuUserGroupHandler) {
func SetupRoutesLandingPage(app *echo.Echo, h *dev_handlers.LandingPageHandler, mastermenuusergroupHandler *dev_handlers.MasterMenuUserGroupHandler) {
Lp := app.Group("/landing_page")
Lp.GET("/", h.ShowLandingPage)
clientgroup := app.Group("/client")
@@ -37,16 +45,22 @@ func SetupRoutesLandingPage(app *echo.Echo, h *LandingPageHandler, mastermenuuse
clientgroup.GET("/usergroup/pagination", mastermenuusergroupHandler.HandleChangePage)
}
func SetupRoutesPieChart(app *echo.Echo, h *PiechartHandler) {
func SetupRoutesPieChart(app *echo.Echo, h *dev_handlers.PiechartHandler) {
Lp := app.Group("/pie_chart")
Lp.GET("/", h.ShowPieChart)
Lp.GET("/peserta", h.ShowMcuPeserta)
Lp.GET("/bar", h.ShowBarChart)
}
func SetupRoutesEmployee(app *echo.Echo, e *EmployeeHandler) {
func SetupRoutesEmployee(app *echo.Echo, e *dev_handlers.EmployeeHandler) {
employee := app.Group("/employee")
employee.GET("/", e.ShowEmployee)
}
func SetupRoutesProject(app *echo.Echo) {
}
func SetupRoutesPublic(app *echo.Echo, appStore db.AppStore) {
public := app.Group("/")
l := public_services.NewServicesLandingPage(public_services.LandingPage{}, appStore)
lh := public_handlers.NewLandingPageHandler(l)
public.GET("landingpage", lh.ShowLandingPage)
}