feat: add storages
This commit is contained in:
@@ -4,21 +4,27 @@ import (
|
||||
"database/sql"
|
||||
|
||||
"backend/app/http/tenants"
|
||||
"backend/app/http/users"
|
||||
|
||||
"git.ipao.vip/rogeecn/atom"
|
||||
"git.ipao.vip/rogeecn/atom/container"
|
||||
"git.ipao.vip/rogeecn/atom/contracts"
|
||||
"git.ipao.vip/rogeecn/atom/utils/opt"
|
||||
"github.com/speps/go-hashids/v2"
|
||||
)
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
if err := container.Container.Provide(func(
|
||||
hashIds *hashids.HashID,
|
||||
svc *Service,
|
||||
tenantSvc *tenants.Service,
|
||||
userSvc *users.Service,
|
||||
) (*Controller, error) {
|
||||
obj := &Controller{
|
||||
hashIds: hashIds,
|
||||
svc: svc,
|
||||
tenantSvc: tenantSvc,
|
||||
userSvc: userSvc,
|
||||
}
|
||||
if err := obj.Prepare(); err != nil {
|
||||
return nil, err
|
||||
@@ -44,9 +50,11 @@ func Provide(opts ...opt.Option) error {
|
||||
}
|
||||
if err := container.Container.Provide(func(
|
||||
db *sql.DB,
|
||||
hashIds *hashids.HashID,
|
||||
) (*Service, error) {
|
||||
obj := &Service{
|
||||
db: db,
|
||||
db: db,
|
||||
hashIds: hashIds,
|
||||
}
|
||||
if err := obj.Prepare(); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -53,4 +53,11 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
PathParam[string]("hash"),
|
||||
))
|
||||
|
||||
router.Post("/api/v1/posts", Func3(
|
||||
r.controller.Create,
|
||||
Local[*jwt.Claims]("claim"),
|
||||
CookieParam("tenant"),
|
||||
Body[PostBody]("body"),
|
||||
))
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user