Add functions for parsing drivvo CSVs.
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
func RegisteImportController(router *gin.RouterGroup) {
|
||||
router.POST("/import/fuelly", fuellyImport)
|
||||
router.POST("/import/drivvo", drivvoImport)
|
||||
}
|
||||
|
||||
func fuellyImport(c *gin.Context) {
|
||||
@@ -24,3 +25,17 @@ func fuellyImport(c *gin.Context) {
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{})
|
||||
}
|
||||
|
||||
func drivvoImport(c *gin.Context) {
|
||||
bytes, err := getFileBytes(c, "file")
|
||||
if err != nil {
|
||||
c.JSON(http.StatusUnprocessableEntity, err)
|
||||
return
|
||||
}
|
||||
errors := service.DrivvoImport(bytes, c.MustGet("userId").(string))
|
||||
if len(errors) > 0 {
|
||||
c.JSON(http.StatusUnprocessableEntity, gin.H{"errors": errors})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user