implement new json_data model
This commit is contained in:
25
dbm/db.go
Normal file
25
dbm/db.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package dbm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
func (d *DBMHandler) SaveData(c *gin.Context) {
|
||||
s := time.Now()
|
||||
if err := d.SaveDb(); err != nil {
|
||||
r := json_dataModels.NewResponse()
|
||||
r.SendError(err.Error())
|
||||
c.JSON(http.StatusBadRequest, r)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
r := json_dataModels.NewResponse()
|
||||
r.SendMessage(fmt.Sprintf("DBM %ddatapints saved in: %v", d.GetNumbersOfDatapoints(), time.Since(s)))
|
||||
c.JSON(http.StatusOK, r)
|
||||
}
|
Reference in New Issue
Block a user