feat: tenant-scoped routing and portal navigation
This commit is contained in:
26
backend/app/http/v1/helpers.go
Normal file
26
backend/app/http/v1/helpers.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
func getUserID(ctx fiber.Ctx) int64 {
|
||||
if u := ctx.Locals(consts.CtxKeyUser); u != nil {
|
||||
if user, ok := u.(*models.User); ok {
|
||||
return user.ID
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func getTenantID(ctx fiber.Ctx) int64 {
|
||||
if t := ctx.Locals(consts.CtxKeyTenant); t != nil {
|
||||
if tenant, ok := t.(*models.Tenant); ok {
|
||||
return tenant.ID
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
Reference in New Issue
Block a user