Add depot, attendant, jetfire, optimus, ota services with kustomize overlays
This commit is contained in:
42
services/ota_update_go/handlers/sub_package_add.go
Normal file
42
services/ota_update_go/handlers/sub_package_add.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"otaupdate/controllers"
|
||||
"otaupdate/services"
|
||||
|
||||
"github.com/fiskerinc/cloud-services/pkg/common"
|
||||
"github.com/go-pg/pg/v10/orm"
|
||||
)
|
||||
|
||||
// @deprecated
|
||||
// HandleSubscriptionPackageAdd godoc
|
||||
// @Summary Add subscription package
|
||||
// @Description Create subscription package
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Authorization header string false "Bearer <ID token>"
|
||||
// @Param Api-Key header string false "<API token>"
|
||||
// @Param package body SubPackagesAddRequest true "Subscription package data"
|
||||
// @Success 200 {object} common.SubscriptionPackage
|
||||
// @Failure 400 {object} common.JSONError "Bad request"
|
||||
// @Failure 401 {object} common.JSONError "Unauthorized"
|
||||
// @Failure 503 {object} common.JSONError "Service unavailable"
|
||||
// @Router /subscriptionpackage [post]
|
||||
func HandleSubscriptionPackageAdd(w http.ResponseWriter, r *http.Request) {
|
||||
subscriptionPackageAdd.Handle(w, r)
|
||||
}
|
||||
|
||||
var subscriptionPackageAdd = controllers.NewCreate(&subscriptionPackageCreateHelper{})
|
||||
|
||||
type subscriptionPackageCreateHelper struct {
|
||||
SubscriptionPackagesHelper
|
||||
}
|
||||
|
||||
func (h *subscriptionPackageCreateHelper) QueryInsert(model interface{}) (orm.Result, error) {
|
||||
return services.GetDB().GetSubPackages().Insert(model.(*common.SubscriptionPackage))
|
||||
}
|
||||
|
||||
type SubPackagesAddRequest struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
Reference in New Issue
Block a user