fuelly api complete

This commit is contained in:
Akhil Gupta
2021-06-26 09:48:29 +05:30
parent 2bd8481670
commit 5f96345828
6 changed files with 207 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package controllers
import (
"net/http"
"github.com/akhilrex/hammond/service"
"github.com/gin-gonic/gin"
)
func RegisteImportController(router *gin.RouterGroup) {
router.POST("/import/fuelly", fuellyImport)
}
func fuellyImport(c *gin.Context) {
bytes, err := getFileBytes(c, "file")
if err != nil {
c.JSON(http.StatusUnprocessableEntity, err)
return
}
err = service.FuellyImport(bytes, c.MustGet("userId").(string))
if err != nil {
c.JSON(http.StatusUnprocessableEntity, gin.H{"errors": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{})
}