remove: tenantslug
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package orders
|
||||
|
||||
import (
|
||||
"backend/app/errorx"
|
||||
"backend/app/http/posts"
|
||||
"backend/app/http/tenants"
|
||||
"backend/app/http/users"
|
||||
@@ -62,27 +61,17 @@ func (c *OrderController) List(ctx fiber.Ctx, claim *jwt.Claims, pagination *req
|
||||
// @Router /api/v1/orders [post]
|
||||
// @Bind claim local
|
||||
// @Bind hash path
|
||||
// @Bind tenantSlug cookie key(tenant)
|
||||
func (c *OrderController) Create(ctx fiber.Ctx, claim *jwt.Claims, tenantSlug, hash string) (*UserOrder, error) {
|
||||
func (c *OrderController) Create(ctx fiber.Ctx, claim *jwt.Claims, hash string) (*UserOrder, error) {
|
||||
user, err := c.userSvc.GetUserByID(ctx.Context(), claim.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tenant, err := c.tenantSvc.GetTenantBySlug(ctx.Context(), tenantSlug)
|
||||
post, err := c.postSvc.GetPostByHash(ctx.Context(), *claim.TenantID, hash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
post, err := c.postSvc.GetPostByHash(ctx.Context(), tenant.ID, hash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if tenant.ID != post.TenantID {
|
||||
return nil, errorx.BadRequest
|
||||
}
|
||||
|
||||
order, err := c.svc.Create(ctx.Context(), user, post)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -38,10 +38,9 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
Query[UserOrderFilter]("filter"),
|
||||
))
|
||||
|
||||
router.Post("/api/v1/orders", DataFunc3(
|
||||
router.Post("/api/v1/orders", DataFunc2(
|
||||
r.orderController.Create,
|
||||
Local[*jwt.Claims]("claim"),
|
||||
CookieParam("tenant"),
|
||||
PathParam[string]("hash"),
|
||||
))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user