-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a66122c
commit 7582b39
Showing
9 changed files
with
125 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
package core | ||
|
||
import ( | ||
"github.com/sivaosorg/gocell/internal/handlers" | ||
"github.com/sivaosorg/gocell/internal/middlewares" | ||
"github.com/sivaosorg/gocell/internal/repository" | ||
"github.com/sivaosorg/gocell/internal/service" | ||
syncconf "github.com/sivaosorg/gocell/internal/syncConf" | ||
) | ||
|
||
type coreHandler struct { | ||
middlewares *middlewares.MiddlewareManager | ||
} | ||
|
||
func NewCoreHandler() *coreHandler { | ||
return &coreHandler{} | ||
} | ||
|
||
func (c *coreHandler) setMiddlewares(value *middlewares.MiddlewareManager) *coreHandler { | ||
c.middlewares = value | ||
return c | ||
middlewares *middlewares.MiddlewareManager | ||
commonHandler *handlers.CommonHandler | ||
} | ||
|
||
func (c *CoreCommand) handler() { | ||
commonRepository := repository.NewCommonRepository(c.psql, c.psqlStatus) | ||
commonSvc := service.NewCommonService(commonRepository) | ||
commonHandler := handlers.NewCommonHandler(commonSvc) | ||
|
||
c.handlers = NewCoreHandler(). | ||
setMiddlewares(middlewares.NewMiddlewareManager(syncconf.Conf)) | ||
setMiddlewares(middlewares.NewMiddlewareManager(syncconf.Conf)). | ||
setCommonHandler(commonHandler) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package core | ||
|
||
import ( | ||
"github.com/sivaosorg/gocell/internal/handlers" | ||
"github.com/sivaosorg/gocell/internal/middlewares" | ||
) | ||
|
||
func NewCoreHandler() *coreHandler { | ||
return &coreHandler{} | ||
} | ||
|
||
func (c *coreHandler) setMiddlewares(value *middlewares.MiddlewareManager) *coreHandler { | ||
c.middlewares = value | ||
return c | ||
} | ||
|
||
func (c *coreHandler) setCommonHandler(value *handlers.CommonHandler) *coreHandler { | ||
c.commonHandler = value | ||
return c | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package handlers | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/sivaosorg/gocell/internal/service" | ||
"github.com/sivaosorg/govm/entity" | ||
) | ||
|
||
type CommonHandler struct { | ||
commonSvc service.CommonService | ||
} | ||
|
||
func NewCommonHandler(commonSvc service.CommonService) *CommonHandler { | ||
h := &CommonHandler{ | ||
commonSvc: commonSvc, | ||
} | ||
return h | ||
} | ||
|
||
func (h *CommonHandler) OnPsqlStatus(ctx *gin.Context) { | ||
response := entity.NewResponseEntity().SetStatusCode(http.StatusOK).SetData(h.commonSvc.GetPsqlStatus()) | ||
ctx.JSON(response.StatusCode, response) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package models | ||
|
||
type Common struct { | ||
} | ||
|
||
type CommonRequest struct { | ||
} | ||
|
||
type CommonResponse struct { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package repository | ||
|
||
import ( | ||
"github.com/sivaosorg/govm/dbx" | ||
"github.com/sivaosorg/postgresconn/postgresconn" | ||
) | ||
|
||
type CommonRepository interface { | ||
GetPsqlStatus() dbx.Dbx | ||
} | ||
|
||
type commonRepositoryImpl struct { | ||
psql *postgresconn.Postgres | ||
psqlStatus dbx.Dbx | ||
} | ||
|
||
func NewCommonRepository(psql *postgresconn.Postgres, psqlStatus dbx.Dbx) CommonRepository { | ||
return &commonRepositoryImpl{ | ||
psql: psql, | ||
psqlStatus: psqlStatus, | ||
} | ||
} | ||
|
||
func (repo *commonRepositoryImpl) GetPsqlStatus() dbx.Dbx { | ||
return repo.psqlStatus | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package service | ||
|
||
import ( | ||
"github.com/sivaosorg/gocell/internal/repository" | ||
"github.com/sivaosorg/govm/dbx" | ||
) | ||
|
||
type CommonService interface { | ||
GetPsqlStatus() dbx.Dbx | ||
} | ||
|
||
type commonServiceImpl struct { | ||
commonRepository repository.CommonRepository | ||
} | ||
|
||
func NewCommonService(commonRepository repository.CommonRepository) CommonService { | ||
return &commonServiceImpl{ | ||
commonRepository: commonRepository, | ||
} | ||
} | ||
|
||
func (s *commonServiceImpl) GetPsqlStatus() dbx.Dbx { | ||
return s.commonRepository.GetPsqlStatus() | ||
} |