oc-scheduler change

This commit is contained in:
mr
2024-08-12 16:34:58 +02:00
parent fc75eb1216
commit 88e4476c3b
5 changed files with 0 additions and 117 deletions

View File

@@ -1,12 +1,10 @@
package controllers
import (
"errors"
"time"
oclib "cloud.o-forge.io/core/oc-lib"
dbs "cloud.o-forge.io/core/oc-lib/dbs"
w "cloud.o-forge.io/core/oc-lib/models/workflow"
beego "github.com/beego/beego/v2/server/web"
"go.mongodb.org/mongo-driver/bson/primitive"
)
@@ -56,42 +54,3 @@ func (o *WorkflowExecutionController) Get() {
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), id)
o.ServeJSON()
}
// @Title Check
// @Description check booking
// @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]
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"))
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": errors.New("invalid date format"),
}
} 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,
}
}
o.ServeJSON()
}