VILLASweb-backend-go/endpoints/simulationEndpoints.go
Sonja Happ 5409c61939 Major changes:
- continue revision of folder structure
- work on model endpoints
- add skeletons for clone endpoints
2019-05-21 14:37:45 +02:00

66 lines
No EOL
1.3 KiB
Go

package endpoints
import (
"fmt"
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/queries"
"git.rwth-aachen.de/acs/public/villas/villasweb-backend-go/serializers"
"github.com/gin-gonic/gin"
"net/http"
"strconv"
)
func simulationReadAllEp(c *gin.Context) {
allSimulations, _, _ := queries.FindAllSimulations()
serializer := serializers.SimulationsSerializerNoAssoc{c, allSimulations}
c.JSON(http.StatusOK, gin.H{
"simulations": serializer.Response(),
})
}
func simulationRegistrationEp(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "NOT implemented",
})
}
func simulationCloneEp(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "NOT implemented",
})
}
func simulationUpdateEp(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "NOT implemented",
})
}
func simulationReadEp(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "NOT implemented",
})
}
func simulationDeleteEp(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "NOT implemented",
})
}
func GetSimulationID(c *gin.Context) (int, error) {
simID, err := strconv.Atoi(c.Param("SimulationID"))
if err != nil {
errormsg := fmt.Sprintf("Bad request. No or incorrect format of simulation ID")
c.JSON(http.StatusBadRequest, gin.H{
"error": errormsg,
})
return -1, err
} else {
return simID, err
}
}