de30497f59
- Implemented tenant and user management features including: - Tenant creation and management with associated migrations. - User creation and management with associated migrations. - Tenant membership management with associated migrations. - Platform user roles management with associated migrations. - Quota management with associated migrations. - Article and template management with associated migrations. - Added HTTP handlers for templates and workspaces. - Created tests for protected and public routes. - Introduced a script to check tenant scope in SQL queries. - Documented task plan for backend completion and frontend foundation.
60 lines
1.3 KiB
Go
60 lines
1.3 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.NewTemplateRepository(a.DB),
|
|
),
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|