package tenancy import ( "net/http" "hfb_sys/backend/pkg/response" "github.com/gin-gonic/gin" ) type SiteContextDTO struct { Mode string `json:"mode"` TenantID uint64 `json:"tenant_id"` TenantCode string `json:"tenant_code"` TenantName string `json:"tenant_name"` Host string `json:"host"` DomainType string `json:"domain_type"` Status string `json:"status"` Profile map[string]any `json:"profile"` Features map[string]any `json:"features"` } type Handler struct{} func NewHandler() *Handler { return &Handler{} } func (h *Handler) SiteContext(c *gin.Context) { scope, ok := FromContext(c.Request.Context()) if !ok { response.Error(c, http.StatusNotFound, "site_not_found", "当前域名未配置站点") return } response.OK(c, SiteContextDTO{ Mode: "tenant", TenantID: scope.TenantID, TenantCode: scope.TenantCode, TenantName: scope.TenantName, Host: scope.Host, DomainType: scope.DomainType, Status: scope.TenantStatus, Profile: scope.Profile(), Features: scope.Features(), }) }