From 6973595cc302a7fec0fccae13e7ba83dd0edbbab Mon Sep 17 00:00:00 2001 From: Mukesh Kumar Chaudhary Date: Thu, 11 Jan 2024 13:52:55 +0545 Subject: [PATCH] feat: remove domain --- domain/hello/controller.go | 19 ------------------- domain/hello/model.go | 5 ----- domain/hello/module.go | 16 ---------------- domain/hello/repository.go | 12 ------------ domain/hello/route.go | 23 ----------------------- domain/hello/service.go | 19 ------------------- domain/middlewares/module.go | 5 ----- domain/module.go | 13 ------------- domain/user/controller.go | 19 ------------------- domain/user/model.go | 5 ----- domain/user/module.go | 16 ---------------- domain/user/repository.go | 12 ------------ domain/user/route.go | 23 ----------------------- domain/user/service.go | 19 ------------------- 14 files changed, 206 deletions(-) delete mode 100644 domain/hello/controller.go delete mode 100644 domain/hello/model.go delete mode 100644 domain/hello/module.go delete mode 100644 domain/hello/repository.go delete mode 100644 domain/hello/route.go delete mode 100644 domain/hello/service.go delete mode 100644 domain/middlewares/module.go delete mode 100644 domain/module.go delete mode 100644 domain/user/controller.go delete mode 100644 domain/user/model.go delete mode 100644 domain/user/module.go delete mode 100644 domain/user/repository.go delete mode 100644 domain/user/route.go delete mode 100644 domain/user/service.go diff --git a/domain/hello/controller.go b/domain/hello/controller.go deleted file mode 100644 index 9230897..0000000 --- a/domain/hello/controller.go +++ /dev/null @@ -1,19 +0,0 @@ -package hello - -import ( - "net/http" - "github.com/gin-gonic/gin" -) - -type HelloController struct { - service *HelloService -} - -func NewHelloController(service *HelloService) *HelloController { - return &HelloController{service: service} -} - -func (ctrl *HelloController) HandleRoot(c *gin.Context) { - message := ctrl.service.GetMessage() - c.JSON(http.StatusOK, gin.H{"message": message.Message}) -} diff --git a/domain/hello/model.go b/domain/hello/model.go deleted file mode 100644 index 75aed10..0000000 --- a/domain/hello/model.go +++ /dev/null @@ -1,5 +0,0 @@ -package hello - -type HelloModel struct { - Message string -} diff --git a/domain/hello/module.go b/domain/hello/module.go deleted file mode 100644 index 266b0c1..0000000 --- a/domain/hello/module.go +++ /dev/null @@ -1,16 +0,0 @@ -package hello - -import ( - "go.uber.org/fx" -) - -var Module = fx.Module("hello", - fx.Options( - fx.Provide( - NewHelloService, - NewHelloController, - NewHelloRepository, - ), - fx.Invoke(NewHelloRoute), - ), -) diff --git a/domain/hello/repository.go b/domain/hello/repository.go deleted file mode 100644 index 3e4238a..0000000 --- a/domain/hello/repository.go +++ /dev/null @@ -1,12 +0,0 @@ -package hello - -type HelloRepository struct { -} - -func NewHelloRepository() *HelloRepository { - return &HelloRepository{} -} - -func (s *HelloRepository) GetMessage() HelloModel { - return HelloModel{Message: "Hello World"} -} diff --git a/domain/hello/route.go b/domain/hello/route.go deleted file mode 100644 index e50db30..0000000 --- a/domain/hello/route.go +++ /dev/null @@ -1,23 +0,0 @@ -package hello - -import ( - "github.com/gin-gonic/gin" - "test/pkg/infrastructure" -) - -type HelloRoute struct { - router *infrastructure.Router - controller *HelloController - groupRouter *gin.RouterGroup -} - -func NewHelloRoute(router *infrastructure.Router, controller *HelloController) *HelloRoute { - route := HelloRoute{router: router, controller: controller} - route.groupRouter = route.router.Group("api/hello") - route.RegisterHelloRoutes() - return &route -} - -func (r *HelloRoute) RegisterHelloRoutes() { - r.groupRouter.GET("", r.controller.HandleRoot) -} diff --git a/domain/hello/service.go b/domain/hello/service.go deleted file mode 100644 index ca6edfa..0000000 --- a/domain/hello/service.go +++ /dev/null @@ -1,19 +0,0 @@ -package hello - -// HelloService handles the business logic of the Hello module -type HelloService struct { - // Add any dependencies here - repo *HelloRepository -} - -// NewHelloService creates a new instance of TestService -func NewHelloService(repo *HelloRepository) *HelloService { - return &HelloService{ - repo: repo, - } -} - -// GetMessage returns a greeting message -func (s *HelloService) GetMessage() HelloModel { - return s.repo.GetMessage() -} diff --git a/domain/middlewares/module.go b/domain/middlewares/module.go deleted file mode 100644 index 7d8f1c4..0000000 --- a/domain/middlewares/module.go +++ /dev/null @@ -1,5 +0,0 @@ -package middlewares - -import "go.uber.org/fx" - -var Module = fx.Module("domain-middlewares", fx.Options()) diff --git a/domain/module.go b/domain/module.go deleted file mode 100644 index 5e6609a..0000000 --- a/domain/module.go +++ /dev/null @@ -1,13 +0,0 @@ -package domain - -import ( - "test/domain/hello" - "test/domain/middlewares" - - "go.uber.org/fx" -) - -var Module = fx.Options( - middlewares.Module, - hello.Module, -) diff --git a/domain/user/controller.go b/domain/user/controller.go deleted file mode 100644 index 254f093..0000000 --- a/domain/user/controller.go +++ /dev/null @@ -1,19 +0,0 @@ -package user - -import ( - "net/http" - "github.com/gin-gonic/gin" -) - -type UserController struct { - service *UserService -} - -func NewUserController(service *UserService) *UserController { - return &UserController{service: service} -} - -func (ctrl *UserController) HandleRoot(c *gin.Context) { - message := ctrl.service.GetMessage() - c.JSON(http.StatusOK, gin.H{"message": message.Message}) -} diff --git a/domain/user/model.go b/domain/user/model.go deleted file mode 100644 index daf1fe2..0000000 --- a/domain/user/model.go +++ /dev/null @@ -1,5 +0,0 @@ -package user - -type UserModel struct { - Message string -} diff --git a/domain/user/module.go b/domain/user/module.go deleted file mode 100644 index ace3214..0000000 --- a/domain/user/module.go +++ /dev/null @@ -1,16 +0,0 @@ -package user - -import ( - "go.uber.org/fx" -) - -var Module = fx.Module("user", - fx.Options( - fx.Provide( - NewUserService, - NewUserController, - NewUserRepository, - ), - fx.Invoke(NewUserRoute), - ), -) diff --git a/domain/user/repository.go b/domain/user/repository.go deleted file mode 100644 index 8209728..0000000 --- a/domain/user/repository.go +++ /dev/null @@ -1,12 +0,0 @@ -package user - -type UserRepository struct { -} - -func NewUserRepository() *UserRepository { - return &UserRepository{} -} - -func (s *UserRepository) GetMessage() UserModel { - return UserModel{Message: "Hello World"} -} diff --git a/domain/user/route.go b/domain/user/route.go deleted file mode 100644 index 30e5e1d..0000000 --- a/domain/user/route.go +++ /dev/null @@ -1,23 +0,0 @@ -package user - -import ( - "github.com/gin-gonic/gin" - "github.com/mukezhz/geng/pkg/infrastructure" -) - -type UserRoute struct { - router *infrastructure.Router - controller *UserController - groupRouter *gin.RouterGroup -} - -func NewUserRoute(router *infrastructure.Router, controller *UserController) *UserRoute { - route := UserRoute{router: router, controller: controller} - route.groupRouter = router.Group("api/user") - route.RegisterHelloRoutes() - return &route -} - -func (r *UserRoute) RegisterHelloRoutes() { - r.groupRouter.GET("", r.controller.HandleRoot) -} diff --git a/domain/user/service.go b/domain/user/service.go deleted file mode 100644 index b2df7f0..0000000 --- a/domain/user/service.go +++ /dev/null @@ -1,19 +0,0 @@ -package user - -// UserService handles the business logic of the User module -type UserService struct { - // Add any dependencies here - repo *UserRepository -} - -// NewUserService creates a new instance of TestService -func NewUserService(repo *UserRepository) *UserService { - return &UserService{ - repo: repo, - } -} - -// GetMessage returns a greeting message -func (s *UserService) GetMessage() UserModel { - return s.repo.GetMessage() -}