git commit
This commit is contained in:
parent
ff54f69127
commit
ce4646b060
@ -1,6 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
@ -65,41 +66,31 @@ func (o *WorkflowExecutionController) Get() {
|
||||
func (o *WorkflowExecutionController) Check() {
|
||||
// store and return Id or post with UUID
|
||||
date, err := time.Parse("2006-01-02T15:04:05", o.Ctx.Input.Param(":start_date"))
|
||||
if err != nil {
|
||||
date2, err2 := time.Parse("2006-01-02T15:04:05", o.Ctx.Input.Param(":end_date"))
|
||||
if err != nil || err2 != nil {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": map[string]interface{}{
|
||||
"is_available": false,
|
||||
},
|
||||
"code": 400,
|
||||
"error": err,
|
||||
"error": errors.New("invalid date format"),
|
||||
}
|
||||
} else {
|
||||
date2, err := time.Parse("2006-01-02T15:04:05", o.Ctx.Input.Param(":end_date"))
|
||||
if err != nil {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": map[string]interface{}{
|
||||
"is_available": false,
|
||||
},
|
||||
"code": 400,
|
||||
"error": err,
|
||||
}
|
||||
} else {
|
||||
workflow := &w.Workflow{}
|
||||
workflow.Schedule = &w.WorkflowSchedule{Start: &date, End: &date2}
|
||||
isAvailable := workflow.CheckBooking()
|
||||
code := 200
|
||||
err := ""
|
||||
if !isAvailable {
|
||||
code = 409
|
||||
err = "booking not available"
|
||||
}
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": map[string]interface{}{
|
||||
"is_available": isAvailable,
|
||||
},
|
||||
"code": code,
|
||||
"error": err,
|
||||
}
|
||||
workflow := &w.Workflow{}
|
||||
workflow.Schedule = &w.WorkflowSchedule{Start: &date, End: &date2}
|
||||
isAvailable := workflow.CheckBooking()
|
||||
code := 200
|
||||
err := ""
|
||||
if !isAvailable {
|
||||
code = 409
|
||||
err = "booking not available"
|
||||
}
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": map[string]interface{}{
|
||||
"is_available": isAvailable,
|
||||
},
|
||||
"code": code,
|
||||
"error": err,
|
||||
}
|
||||
}
|
||||
o.ServeJSON()
|
||||
|
Loading…
Reference in New Issue
Block a user