VILLASweb-backend-go/routes/simulation/simulationSerializer.go
Sonja Happ 2e7475a26b - add first draft of code for other routes (not complete!)
- some new endpoints
- some new DB queries
- some new serializers
2019-05-09 17:02:24 +02:00

43 lines
1.1 KiB
Go

package simulation
import (
"github.com/gin-gonic/gin"
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/common"
)
type SimulationsSerializerNoAssoc struct {
Ctx *gin.Context
Simulations []common.Simulation
}
func (self *SimulationsSerializerNoAssoc) Response() []SimulationResponseNoAssoc {
response := []SimulationResponseNoAssoc{}
for _, simulation := range self.Simulations {
serializer := SimulationSerializerNoAssoc{self.Ctx, simulation}
response = append(response, serializer.Response())
}
return response
}
type SimulationSerializerNoAssoc struct {
Ctx *gin.Context
common.Simulation
}
type SimulationResponseNoAssoc struct {
Name string `json:"Name"`
ID uint `json:"SimulationID"`
Running bool `json:"Running"`
//StartParams postgres.Jsonb `json:"Starting Parameters"`
}
func (self *SimulationSerializerNoAssoc) Response() SimulationResponseNoAssoc {
response := SimulationResponseNoAssoc{
Name: self.Name,
ID: self.ID,
Running: self.Running,
//StartParams: self.StartParameters,
}
return response
}