new json_data model
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user