Files
story/internal/httpapi/content_quality_handlers.go
T

30 lines
862 B
Go
Raw Normal View History

2026-08-29 21:56:51 +08:00
package httpapi
import (
"net/http"
"strings"
"data-terminal-cloud/internal/opsconfig"
)
func GetOpsContentQualityHandler(service *opsconfig.Service) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
principal, ok := webPrincipal(w, r)
if !ok {
return
}
tenantID := strings.TrimSpace(r.Header.Get("X-Tenant-Id"))
if !validUUID(tenantID) {
writeValidation(w, r, "内容质量查询参数不正确", FieldError{Field: "X-Tenant-Id", Message: "必须是有效UUID"})
return
}
items, err := service.ContentQuality(r.Context(), principal, tenantID, r.URL.Query().Get("model_ref"), r.URL.Query().Get("prompt_version"))
if err != nil {
writeOpsConfigError(w, r, err)
return
}
w.Header().Set("Cache-Control", "no-store")
WriteJSON(w, r, http.StatusOK, map[string]any{"items": items})
})
}