Implement SCUM direct data plane

This commit is contained in:
npc0-hue
2026-08-13 16:33:11 +08:00
parent b07a792784
commit 8b236d7c15
56 changed files with 1466 additions and 90 deletions
+33 -1
View File
@@ -1,6 +1,10 @@
package dto
import "browser.local/platform/domain"
import (
"time"
"browser.local/platform/domain"
)
type SCUMPlayerLiveStateListResponse struct {
Items []domain.SCUMPlayerLiveState `json:"items"`
@@ -32,6 +36,25 @@ type SCUMCurrentPositionListResponse struct {
Count int `json:"count"`
}
type SCUMDataRowResponse struct {
ID string `json:"id"`
ServerInstanceID string `json:"serverInstanceId"`
TargetTable string `json:"targetTable"`
UpsertKey string `json:"upsertKey"`
Fields map[string]any `json:"fields"`
Payload map[string]any `json:"payload"`
PluginID string `json:"pluginId"`
QueryKey string `json:"queryKey"`
Freshness domain.SCUMProjectionFreshnessState `json:"freshness"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type SCUMDataRowListResponse struct {
Items []SCUMDataRowResponse `json:"items"`
Count int `json:"count"`
}
func SCUMPlayerLiveStatesFromDomain(values []domain.SCUMPlayerLiveState) SCUMPlayerLiveStateListResponse {
out := make([]domain.SCUMPlayerLiveState, len(values))
for index, value := range values {
@@ -79,3 +102,12 @@ func SCUMCurrentPositionsFromDomain(values []domain.SCUMCurrentPosition) SCUMCur
}
return SCUMCurrentPositionListResponse{Items: out, Count: len(out)}
}
func SCUMDataRowsFromDomain(values []domain.SCUMDataRow) SCUMDataRowListResponse {
items := make([]SCUMDataRowResponse, len(values))
for index, value := range values {
value = domain.CopySCUMDataRow(value)
items[index] = SCUMDataRowResponse{ID: value.ID, ServerInstanceID: value.ServerInstanceID, TargetTable: string(value.TargetTable), UpsertKey: value.UpsertKey, Fields: value.Fields, Payload: value.Payload, PluginID: value.PluginID, QueryKey: value.QueryKey, Freshness: value.Freshness, CreatedAt: value.CreatedAt, UpdatedAt: value.UpdatedAt}
}
return SCUMDataRowListResponse{Items: items, Count: len(items)}
}