mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-09 09:06:36 +08:00
refactor(zone): remove legacy route domain storage
第二阶段清理:删除 of_managed_domains 与 of_proxy_routes 冗余域名/证书列, 移除 ManagedDomain 模型与 API、路由侧 legacy 字段维护,以及前端 WebsiteService。 ImportLegacy 在旧列/旧表缺失时跳过对应源,保持幂等。
This commit is contained in:
@@ -5,7 +5,6 @@ package proxy_route
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -253,43 +252,12 @@ func buildProxyRoute(ctx context.Context, route *model.ProxyRoute, input Input)
|
||||
limitRate,
|
||||
upstreamType,
|
||||
)
|
||||
// Preserve legacy columns until the second-phase schema cleanup. They are
|
||||
// derived solely from ZoneDomain bindings and are not exposed by this API.
|
||||
populateLegacyZoneDomainFields(route, domains)
|
||||
if err := applyProxyRouteUpstreamType(ctx, route, upstreamType, input); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return route, domains, nil
|
||||
}
|
||||
|
||||
func mustMarshalProxyRouteLegacy(value any) string {
|
||||
encoded, err := json.Marshal(value)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return string(encoded)
|
||||
}
|
||||
|
||||
func populateLegacyZoneDomainFields(route *model.ProxyRoute, domains []model.ZoneDomain) {
|
||||
legacyDomains := make([]string, 0, len(domains))
|
||||
legacyCertIDs := make([]uint, 0, len(domains))
|
||||
for _, domain := range domains {
|
||||
legacyDomains = append(legacyDomains, domain.Domain)
|
||||
if domain.CertID != nil {
|
||||
legacyCertIDs = append(legacyCertIDs, *domain.CertID)
|
||||
}
|
||||
}
|
||||
route.Domain = legacyDomains[0]
|
||||
route.Domains = mustMarshalProxyRouteLegacy(legacyDomains)
|
||||
route.CertIDs = mustMarshalProxyRouteLegacy(legacyCertIDs)
|
||||
if len(legacyCertIDs) > 0 {
|
||||
route.CertID = &legacyCertIDs[0]
|
||||
} else {
|
||||
route.CertID = nil
|
||||
}
|
||||
route.DomainCertIDs = route.CertIDs
|
||||
}
|
||||
|
||||
func buildProxyRouteViews(ctx context.Context, routes []*model.ProxyRoute) ([]*View, error) {
|
||||
views := make([]*View, 0, len(routes))
|
||||
for _, route := range routes {
|
||||
|
||||
Reference in New Issue
Block a user