Files
geo/server/internal/tenant/transport/workspace_handler.go
T
root 63667ed2d1 feat(membership): enforce tenant subscription plans with blocked UI
Add configurable membership plans (free/plus/pro) synced to DB on boot, a
subscription guard middleware that blocks tenant endpoints on expired or
missing plans, and a MembershipBlockedView that surfaces the reason so
the admin can contact the tenant owner. Quota and brand-library reads now
honor the active plan's policy JSON and expired subscriptions.
2026-04-18 20:56:05 +08:00

73 lines
1.6 KiB
Go

package transport
import (
"github.com/gin-gonic/gin"
"github.com/geo-platform/tenant-api/internal/bootstrap"
"github.com/geo-platform/tenant-api/internal/shared/response"
"github.com/geo-platform/tenant-api/internal/tenant/app"
"github.com/geo-platform/tenant-api/internal/tenant/repository"
)
type WorkspaceHandler struct {
svc *app.WorkspaceService
}
func NewWorkspaceHandler(a *bootstrap.App) *WorkspaceHandler {
return &WorkspaceHandler{
svc: app.NewWorkspaceService(
repository.NewWorkspaceRepository(a.DB),
repository.NewCachedTemplateRepository(
repository.NewTemplateRepository(a.DB),
a.Cache,
),
repository.NewQuotaRepository(a.DB),
).WithCache(a.Cache),
}
}
func (h *WorkspaceHandler) Overview(c *gin.Context) {
data, err := h.svc.Overview(c.Request.Context())
if err != nil {
response.Error(c, err)
return
}
response.Success(c, data)
}
func (h *WorkspaceHandler) RecentArticles(c *gin.Context) {
data, err := h.svc.RecentArticles(c.Request.Context())
if err != nil {
response.Error(c, err)
return
}
response.Success(c, data)
}
func (h *WorkspaceHandler) QuotaSummary(c *gin.Context) {
data, err := h.svc.QuotaSummary(c.Request.Context())
if err != nil {
response.Error(c, err)
return
}
response.Success(c, data)
}
func (h *WorkspaceHandler) TemplateCards(c *gin.Context) {
data, err := h.svc.TemplateCards(c.Request.Context())
if err != nil {
response.Error(c, err)
return
}
response.Success(c, data)
}
func (h *WorkspaceHandler) KolCards(c *gin.Context) {
data, err := h.svc.KolCards(c.Request.Context())
if err != nil {
response.Error(c, err)
return
}
response.Success(c, data)
}