neo datacenter
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"fmt"
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||
"cloud.o-forge.io/core/oc-lib/models/booking"
|
||||
@@ -52,12 +52,14 @@ func (o *BookingController) Get() {
|
||||
|
||||
// @Title Check
|
||||
// @Description check booking
|
||||
// @Param id path string "id of the datacenter"
|
||||
// @Param start_date path string "the booking start date" format "2006-01-02T15:04:05"
|
||||
// @Param end_date path string "the booking end date" format "2006-01-02T15:04:05"
|
||||
// @Success 200 {object} models.object
|
||||
// @router /check/:start_date/:end_date [get]
|
||||
// @router /check/:id/:start_date/:end_date [get]
|
||||
func (o *BookingController) Check() {
|
||||
// store and return Id or post with UUID
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
date, err := time.Parse("2006-01-02T15:04:05", o.Ctx.Input.Param(":start_date"))
|
||||
date2, err2 := time.Parse("2006-01-02T15:04:05", o.Ctx.Input.Param(":end_date"))
|
||||
if err != nil || err2 != nil {
|
||||
@@ -70,7 +72,7 @@ func (o *BookingController) Check() {
|
||||
}
|
||||
} else {
|
||||
booking := &b.Booking{}
|
||||
isAvailable, err2 := booking.CheckBooking(date, &date2)
|
||||
isAvailable, err2 := booking.CheckBooking(id, date, &date2)
|
||||
code := 200
|
||||
err := ""
|
||||
if !isAvailable {
|
||||
@@ -120,7 +122,7 @@ func (o *BookingController) Post() {
|
||||
books := make([]interface{}, 0)
|
||||
errormsg := ""
|
||||
for _, exec := range resp.Executions {
|
||||
if ok, _ := (&booking.Booking{}).CheckBooking(*exec.ExecDate, exec.EndDate); !ok {
|
||||
if ok, _ := (&booking.Booking{}).CheckBooking(dc_id, *exec.ExecDate, exec.EndDate); !ok {
|
||||
res.Err += " -> the booking from " + exec.ExecDate.String() + " is already taken."
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": nil,
|
||||
|
||||
Reference in New Issue
Block a user