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()
}

Binary file not shown.

View File

@ -34,15 +34,6 @@ func init() {
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowExecutionController"] = append(beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowExecutionController"],
beego.ControllerComments{
Method: "Check",
Router: `/check/:start_date/:end_date`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowExecutionController"] = append(beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowExecutionController"],
beego.ControllerComments{
Method: "Search",

View File

@ -43,39 +43,6 @@
}
}
},
"/workflow_execution/check/{start_date}/{end_date}": {
"get": {
"tags": [
"workflow_execution"
],
"description": "check booking\n\u003cbr\u003e",
"operationId": "WorkflowExecutionController.Check",
"parameters": [
{
"in": "path",
"name": "start_date",
"description": "2006-01-02T15:04:05",
"type": "string",
"default": "the booking start date"
},
{
"in": "path",
"name": "end_date",
"description": "2006-01-02T15:04:05",
"type": "string",
"default": "the booking end date"
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/models.object"
}
}
}
}
},
"/workflow_execution/search/{start_date}/{end_date}": {
"get": {
"tags": [
@ -130,12 +97,6 @@
}
}
},
"definitions": {
"models.object": {
"title": "object",
"type": "object"
}
},
"tags": [
{
"name": "workflow_execution",

View File

@ -51,30 +51,6 @@ paths:
responses:
"200":
description: '{workflow} models.workflow'
/workflow_execution/check/{start_date}/{end_date}:
get:
tags:
- workflow_execution
description: |-
check booking
<br>
operationId: WorkflowExecutionController.Check
parameters:
- in: path
name: start_date
description: 2006-01-02T15:04:05
type: string
default: the booking start date
- in: path
name: end_date
description: 2006-01-02T15:04:05
type: string
default: the booking end date
responses:
"200":
description: ""
schema:
$ref: '#/definitions/models.object'
/workflow_execution/search/{start_date}/{end_date}:
get:
tags:
@ -97,10 +73,6 @@ paths:
responses:
"200":
description: '{workspace} models.workspace'
definitions:
models.object:
title: object
type: object
tags:
- name: workflow_execution
description: |