delete quick entry and some stats
This commit is contained in:
@@ -19,6 +19,8 @@ func RegisterFilesController(router *gin.RouterGroup) {
|
||||
router.GET("/me/quickEntries", getMyQuickEntries)
|
||||
router.GET("/quickEntries/:id", getQuickEntryById)
|
||||
router.POST("/quickEntries/:id/process", setQuickEntryAsProcessed)
|
||||
router.DELETE("/quickEntries/:id", deleteQuickEntryById)
|
||||
|
||||
router.GET("/attachments/:id/file", getAttachmentFile)
|
||||
}
|
||||
|
||||
@@ -76,6 +78,21 @@ func getQuickEntryById(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
|
||||
}
|
||||
}
|
||||
|
||||
func deleteQuickEntryById(c *gin.Context) {
|
||||
var searchByIdQuery models.SearchByIdQuery
|
||||
|
||||
if c.ShouldBindUri(&searchByIdQuery) == nil {
|
||||
err := service.DeleteQuickEntryById(searchByIdQuery.Id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusUnprocessableEntity, common.NewError("deleteQuickEntryById", err))
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusNoContent, gin.H{})
|
||||
} else {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
|
||||
}
|
||||
}
|
||||
func setQuickEntryAsProcessed(c *gin.Context) {
|
||||
var searchByIdQuery models.SearchByIdQuery
|
||||
|
||||
|
||||
37
server/controllers/reports.go
Normal file
37
server/controllers/reports.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/akhilrex/hammond/common"
|
||||
"github.com/akhilrex/hammond/models"
|
||||
"github.com/akhilrex/hammond/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func RegisterReportsController(router *gin.RouterGroup) {
|
||||
router.GET("/vehicles/:id/mileage", getMileageForVehicle)
|
||||
}
|
||||
|
||||
func getMileageForVehicle(c *gin.Context) {
|
||||
|
||||
var searchByIdQuery models.SearchByIdQuery
|
||||
|
||||
if err := c.ShouldBindUri(&searchByIdQuery); err == nil {
|
||||
var model models.MileageQueryModel
|
||||
err := c.BindQuery(&model)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusUnprocessableEntity, common.NewError("getMileageForVehicle", err))
|
||||
return
|
||||
}
|
||||
|
||||
fillups, err := service.GetMileageByVehicleId(searchByIdQuery.Id, model.Since)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusUnprocessableEntity, common.NewError("getMileageForVehicle", err))
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, fillups)
|
||||
} else {
|
||||
c.JSON(http.StatusUnprocessableEntity, common.NewValidatorError(err))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user