new json_data model

This commit is contained in:
Adrian Zuercher
2025-05-04 22:21:12 +02:00
parent 7d6b09cf11
commit 5203fb8543
13 changed files with 79 additions and 45 deletions

View File

@@ -13,7 +13,8 @@ func (d *DBMHandler) Json_Data(c *gin.Context) {
payload, err := json_data.ParseRequest(c.Request.Body)
if err != nil {
r := json_data.NewResponse()
r.SendError(err.Error())
r.SetError()
r.SetMessage(err.Error())
c.JSON(http.StatusBadRequest, r)
return
}
@@ -44,14 +45,14 @@ func (d *DBMHandler) Json_Data(c *gin.Context) {
respond.Set, err = d.CreateDatapoints(payload.Set...)
if err != nil {
r := json_data.NewResponse()
r.SendError(err.Error())
r.SetError()
r.SetMessage(err.Error())
c.JSON(http.StatusBadRequest, r)
return
}
}
c.JSON(200, respond)
return
}
func (d *DBMHandler) Delete(c *gin.Context) {
@@ -59,7 +60,8 @@ func (d *DBMHandler) Delete(c *gin.Context) {
payload, err := json_data.ParseRequest(c.Request.Body)
if err != nil {
r := json_data.NewResponse()
r.SendError(err.Error())
r.SetError()
r.SetMessage(err.Error())
c.JSON(http.StatusBadRequest, r)
return
}
@@ -71,12 +73,12 @@ func (d *DBMHandler) Delete(c *gin.Context) {
response.Set, err = d.RemoveDatapoint(payload.Set...)
if err != nil {
r := json_data.NewResponse()
r.SendError(err.Error())
r.SetError()
r.SetMessage(err.Error())
c.JSON(http.StatusBadRequest, r)
return
}
}
c.JSON(200, response)
return
}