63667ed2d1
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.
73 lines
1.6 KiB
Go
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)
|
|
}
|