oc-scheduler change
This commit is contained in:
parent
fc75eb1216
commit
88e4476c3b
@ -1,12 +1,10 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
oclib "cloud.o-forge.io/core/oc-lib"
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
dbs "cloud.o-forge.io/core/oc-lib/dbs"
|
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"
|
beego "github.com/beego/beego/v2/server/web"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"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.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), id)
|
||||||
o.ServeJSON()
|
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()
|
|
||||||
}
|
|
||||||
|
BIN
oc-scheduler
BIN
oc-scheduler
Binary file not shown.
@ -34,15 +34,6 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: 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.GlobalControllerRouter["oc-scheduler/controllers:WorkflowExecutionController"] = append(beego.GlobalControllerRouter["oc-scheduler/controllers:WorkflowExecutionController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "Search",
|
Method: "Search",
|
||||||
|
@ -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}": {
|
"/workflow_execution/search/{start_date}/{end_date}": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@ -130,12 +97,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
|
||||||
"models.object": {
|
|
||||||
"title": "object",
|
|
||||||
"type": "object"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": [
|
"tags": [
|
||||||
{
|
{
|
||||||
"name": "workflow_execution",
|
"name": "workflow_execution",
|
||||||
|
@ -51,30 +51,6 @@ paths:
|
|||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: '{workflow} models.workflow'
|
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}:
|
/workflow_execution/search/{start_date}/{end_date}:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@ -97,10 +73,6 @@ paths:
|
|||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: '{workspace} models.workspace'
|
description: '{workspace} models.workspace'
|
||||||
definitions:
|
|
||||||
models.object:
|
|
||||||
title: object
|
|
||||||
type: object
|
|
||||||
tags:
|
tags:
|
||||||
- name: workflow_execution
|
- name: workflow_execution
|
||||||
description: |
|
description: |
|
||||||
|
Loading…
Reference in New Issue
Block a user