initial
This commit is contained in:
parent
781d525d72
commit
8c38107ff2
5 changed files with 86 additions and 0 deletions
34
internal/merch/controller.go
Normal file
34
internal/merch/controller.go
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
package merch
|
||||||
|
|
||||||
|
import "github.com/gin-gonic/gin"
|
||||||
|
|
||||||
|
type controller struct {
|
||||||
|
service *service
|
||||||
|
}
|
||||||
|
|
||||||
|
func newController(s *service) *controller {
|
||||||
|
return &controller{
|
||||||
|
service: s,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) RegisterRoutes(r *gin.RouterGroup) {
|
||||||
|
merchGroup := r.Group("/merch")
|
||||||
|
|
||||||
|
merchGroup.POST("/create", h.controller.create)
|
||||||
|
merchGroup.GET("/:id", h.controller.getOne)
|
||||||
|
merchGroup.GET("/list", h.controller.getMany)
|
||||||
|
merchGroup.PUT("/update", h.controller.update)
|
||||||
|
merchGroup.DELETE("/delete", h.controller.delete)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (co *controller) create(c *gin.Context) {}
|
||||||
|
|
||||||
|
func (co *controller) getOne(c *gin.Context) {}
|
||||||
|
|
||||||
|
func (co *controller) getMany(c *gin.Context) {}
|
||||||
|
|
||||||
|
func (co *controller) update(c *gin.Context) {}
|
||||||
|
|
||||||
|
func (co *controller) delete(c *gin.Context) {}
|
||||||
25
internal/merch/handler.go
Normal file
25
internal/merch/handler.go
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
package merch
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Handler struct {
|
||||||
|
controller *controller
|
||||||
|
}
|
||||||
|
|
||||||
|
type Deps struct {
|
||||||
|
DB *sql.DB
|
||||||
|
Group *gin.RouterGroup
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(db *sql.DB) *Handler {
|
||||||
|
r := newRepo(db)
|
||||||
|
s := newService(r)
|
||||||
|
c := newController(s)
|
||||||
|
|
||||||
|
return &Handler{
|
||||||
|
controller: c,
|
||||||
|
}
|
||||||
|
}
|
||||||
1
internal/merch/model.go
Normal file
1
internal/merch/model.go
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
package merch
|
||||||
15
internal/merch/repository.go
Normal file
15
internal/merch/repository.go
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
package merch
|
||||||
|
|
||||||
|
import "database/sql"
|
||||||
|
|
||||||
|
type Repository interface{}
|
||||||
|
|
||||||
|
type repo struct {
|
||||||
|
db *sql.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func newRepo(db *sql.DB) Repository {
|
||||||
|
return repo{
|
||||||
|
db: db,
|
||||||
|
}
|
||||||
|
}
|
||||||
11
internal/merch/service.go
Normal file
11
internal/merch/service.go
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
package merch
|
||||||
|
|
||||||
|
type service struct {
|
||||||
|
repo Repository
|
||||||
|
}
|
||||||
|
|
||||||
|
func newService(repo Repository) *service {
|
||||||
|
return &service{
|
||||||
|
repo: repo,
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue