Add depot, attendant, jetfire, optimus, ota services with kustomize overlays
This commit is contained in:
41
services/ota_update_go/handlers/carupdate_delete.go
Normal file
41
services/ota_update_go/handlers/carupdate_delete.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"otaupdate/services"
|
||||
|
||||
"github.com/fiskerinc/cloud-services/pkg/common"
|
||||
"github.com/fiskerinc/cloud-services/pkg/utils"
|
||||
"github.com/fiskerinc/cloud-services/pkg/utils/urlhelper"
|
||||
"github.com/fiskerinc/cloud-services/pkg/loggerdataresp"
|
||||
)
|
||||
|
||||
// HandleCarUpdateDelete godoc
|
||||
// @Summary Delete car update
|
||||
// @Description Delete car update. Requires delete permissions
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Authorization header string false "Bearer <ID token>"
|
||||
// @Param Api-Key header string false "<API token>"
|
||||
// @Param id query int true "Car update id"
|
||||
// @Success 200 {object} common.JSONMessage
|
||||
// @Failure 400 {object} common.JSONError "Bad request"
|
||||
// @Failure 401 {object} common.JSONError "Unauthorized"
|
||||
// @Failure 503 {object} common.JSONError "Service unavailable"
|
||||
// @Router /carupdate [delete]
|
||||
func HandleCarUpdateDelete(w http.ResponseWriter, r *http.Request) {
|
||||
qs := r.URL.Query()
|
||||
carupdate := common.CarUpdate{
|
||||
ID: urlhelper.GetQueryInt64(qs, "id"),
|
||||
}
|
||||
|
||||
_, err := services.GetDB().GetCarUpdates().Delete(&carupdate)
|
||||
if loggerdataresp.BadDataErrorResp(w, err, http.StatusServiceUnavailable, loggerdataresp.PostgresNoRowsErrorCheck) {
|
||||
return
|
||||
}
|
||||
|
||||
utils.RespJSON(w, http.StatusOK, common.JSONMessage{
|
||||
Message: "Deleted",
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user