diff --git a/controllers/workflow.go b/controllers/workflow.go
index a36b541..9b26193 100644
--- a/controllers/workflow.go
+++ b/controllers/workflow.go
@@ -6,39 +6,13 @@ import (
"time"
oclib "cloud.o-forge.io/core/oc-lib"
+ "cloud.o-forge.io/core/oc-lib/models/utils"
w "cloud.o-forge.io/core/oc-lib/models/workflow"
tools "cloud.o-forge.io/core/oc-lib/tools"
beego "github.com/beego/beego/v2/server/web"
"github.com/nats-io/nats.go"
)
-var paths = map[string]map[tools.METHOD]string{
- oclib.LibDataEnum(oclib.BOOKING).String(): {
- tools.GET: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/:id",
- tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/:id",
- tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/",
- tools.PUT: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/",
- },
- oclib.LibDataEnum(oclib.SHARED_WORKSPACE).String(): {
- tools.GET: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
- tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
- tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
- tools.PUT: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
- },
- oclib.LibDataEnum(oclib.WORKSPACE).String(): {
- tools.GET: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
- tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
- tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
- tools.PUT: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
- },
- oclib.LibDataEnum(oclib.WORKFLOW).String(): {
- tools.GET: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
- tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
- tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
- tools.PUT: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
- },
-}
-
// Operations about workflow
type WorkflowController struct {
beego.Controller
@@ -63,6 +37,23 @@ func (o *WorkflowController) Search() {
// @Success 200 {object} models.workflow
// @router /:id [put]
func (o *WorkflowController) Put() {
+ var paths = map[string]map[tools.METHOD]string{
+ utils.BOOKING.String(): {
+ tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/",
+ },
+ utils.SHARED_WORKSPACE.String(): {
+ tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
+ tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
+ },
+ utils.WORKSPACE.String(): {
+ tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
+ tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
+ },
+ utils.WORKFLOW.String(): {
+ tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
+ tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
+ },
+ }
// store and return Id or post with UUID
var res map[string]interface{}
id := o.Ctx.Input.Param(":id")
@@ -112,6 +103,23 @@ func (o *WorkflowController) SetNATSPub(res map[string]interface{}, data oclib.L
// @Success 200 {object} models.workflow
// @router / [post]
func (o *WorkflowController) Post() {
+ var paths = map[string]map[tools.METHOD]string{
+ utils.BOOKING.String(): {
+ tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/",
+ },
+ utils.SHARED_WORKSPACE.String(): {
+ tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/:id",
+ tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE)) + "/oc/shared/workspace/",
+ },
+ utils.WORKSPACE.String(): {
+ tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/:id",
+ tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)) + "/oc/workspace/",
+ },
+ utils.WORKFLOW.String(): {
+ tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/:id",
+ tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)) + "/oc/workflow/",
+ },
+ }
var res map[string]interface{}
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
caller := tools.NewHTTPCaller(paths)
diff --git a/main.go b/main.go
index e3b3b57..ddea474 100644
--- a/main.go
+++ b/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "fmt"
_ "oc-workflow/routers"
oclib "cloud.o-forge.io/core/oc-lib"
@@ -38,6 +39,7 @@ func main() {
)
oclib.Init("oc-workflow")
oclib.AddPath(oclib.LibDataEnum(oclib.BOOKING), o.GetStringDefault("BOOKING_URL", ":8092"))
+ fmt.Println(oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)))
oclib.AddPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), o.GetStringDefault("SHARED_WORKSPACE_URL", ":8091"))
oclib.AddPath(oclib.LibDataEnum(oclib.WORKSPACE), o.GetStringDefault("WORKSPACE_URL", ":8089"))
oclib.AddPath(oclib.LibDataEnum(oclib.WORKFLOW), o.GetStringDefault("WORKFLOW_URL", ":8088"))
diff --git a/oc-workflow b/oc-workflow
deleted file mode 100755
index e217de2..0000000
Binary files a/oc-workflow and /dev/null differ
diff --git a/routers/commentsRouter.go b/routers/commentsRouter.go
index da7005f..f967c92 100644
--- a/routers/commentsRouter.go
+++ b/routers/commentsRouter.go
@@ -61,6 +61,15 @@ func init() {
Filters: nil,
Params: nil})
+ beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowController"],
+ beego.ControllerComments{
+ Method: "Check",
+ Router: `/check/:start_date/:end_date`,
+ AllowHTTPMethods: []string{"get"},
+ MethodParams: param.Make(),
+ Filters: nil,
+ Params: nil})
+
beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowController"],
beego.ControllerComments{
Method: "Publish",
@@ -79,58 +88,4 @@ func init() {
Filters: nil,
Params: nil})
- beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowResourceController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowResourceController"],
- beego.ControllerComments{
- Method: "GetAll",
- Router: `/`,
- AllowHTTPMethods: []string{"get"},
- MethodParams: param.Make(),
- Filters: nil,
- Params: nil})
-
- beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowResourceController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowResourceController"],
- beego.ControllerComments{
- Method: "Post",
- Router: `/`,
- AllowHTTPMethods: []string{"post"},
- MethodParams: param.Make(),
- Filters: nil,
- Params: nil})
-
- beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowResourceController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowResourceController"],
- beego.ControllerComments{
- Method: "Put",
- Router: `/:id`,
- AllowHTTPMethods: []string{"put"},
- MethodParams: param.Make(),
- Filters: nil,
- Params: nil})
-
- beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowResourceController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowResourceController"],
- beego.ControllerComments{
- Method: "Get",
- Router: `/:id`,
- AllowHTTPMethods: []string{"get"},
- MethodParams: param.Make(),
- Filters: nil,
- Params: nil})
-
- beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowResourceController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowResourceController"],
- beego.ControllerComments{
- Method: "Delete",
- Router: `/:id`,
- AllowHTTPMethods: []string{"delete"},
- MethodParams: param.Make(),
- Filters: nil,
- Params: nil})
-
- beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowResourceController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowResourceController"],
- beego.ControllerComments{
- Method: "Search",
- Router: `/search/:search`,
- AllowHTTPMethods: []string{"get"},
- MethodParams: param.Make(),
- Filters: nil,
- Params: nil})
-
}
diff --git a/swagger/swagger.json b/swagger/swagger.json
index ff31928..2b799f6 100644
--- a/swagger/swagger.json
+++ b/swagger/swagger.json
@@ -69,6 +69,39 @@
}
}
},
+ "/workflow/check/{start_date}/{end_date}": {
+ "get": {
+ "tags": [
+ "workflow"
+ ],
+ "description": "check booking\n\u003cbr\u003e",
+ "operationId": "WorkflowController.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/publish/{id}": {
"post": {
"tags": [
@@ -95,146 +128,6 @@
}
}
},
- "/workflow/resource/": {
- "get": {
- "tags": [
- "workflow/resource"
- ],
- "description": "find workflow by workflowid\n\u003cbr\u003e",
- "operationId": "WorkflowResourceController.GetAll",
- "responses": {
- "200": {
- "description": "{workflow} models.workflow"
- }
- }
- },
- "post": {
- "tags": [
- "workflow/resource"
- ],
- "description": "create workflows\n\u003cbr\u003e",
- "operationId": "WorkflowResourceController.Create",
- "parameters": [
- {
- "in": "body",
- "name": "data",
- "description": "body for data content (Json format)",
- "required": true,
- "schema": {
- "$ref": "#/definitions/json"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/models.workflow"
- }
- }
- }
- }
- },
- "/workflow/resource/search/{search}": {
- "get": {
- "tags": [
- "workflow/resource"
- ],
- "description": "search workspace\n\u003cbr\u003e",
- "operationId": "WorkflowResourceController.Search",
- "parameters": [
- {
- "in": "path",
- "name": "search",
- "description": "the word search you want to get",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "{workspace} models.workspace"
- }
- }
- }
- },
- "/workflow/resource/{id}": {
- "get": {
- "tags": [
- "workflow/resource"
- ],
- "description": "find workflows\n\u003cbr\u003e",
- "operationId": "WorkflowResourceController.Get",
- "parameters": [
- {
- "in": "path",
- "name": "id",
- "description": "the workflowid you want to get",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "{workflow} models.workflow"
- }
- }
- },
- "put": {
- "tags": [
- "workflow/resource"
- ],
- "description": "create workflows\n\u003cbr\u003e",
- "operationId": "WorkflowResourceController.Update",
- "parameters": [
- {
- "in": "path",
- "name": "id",
- "description": "the workflowid you want to get",
- "required": true,
- "type": "string"
- },
- {
- "in": "body",
- "name": "body",
- "description": "The workflow content",
- "required": true,
- "schema": {
- "$ref": "#/definitions/models.workflow"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/models.workflow"
- }
- }
- }
- },
- "delete": {
- "tags": [
- "workflow/resource"
- ],
- "description": "delete the workflow\n\u003cbr\u003e",
- "operationId": "WorkflowResourceController.Delete",
- "parameters": [
- {
- "in": "path",
- "name": "id",
- "description": "The workflowId you want to delete",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "{string} delete success!"
- }
- }
- }
- },
"/workflow/search/{search}": {
"get": {
"tags": [
@@ -341,6 +234,10 @@
"title": "json",
"type": "object"
},
+ "models.object": {
+ "title": "object",
+ "type": "object"
+ },
"models.workflow": {
"title": "workflow",
"type": "object"
@@ -351,10 +248,6 @@
"name": "workflow",
"description": "Operations about workflow\n"
},
- {
- "name": "workflow/resource",
- "description": "Operations about workflow\n"
- },
{
"name": "version",
"description": "VersionController operations for Version\n"
diff --git a/swagger/swagger.yml b/swagger/swagger.yml
index 8fc3899..a2942d5 100644
--- a/swagger/swagger.yml
+++ b/swagger/swagger.yml
@@ -110,6 +110,30 @@ paths:
responses:
"200":
description: '{string} delete success!'
+ /workflow/check/{start_date}/{end_date}:
+ get:
+ tags:
+ - workflow
+ description: |-
+ check booking
+
+ operationId: WorkflowController.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/publish/{id}:
post:
tags:
@@ -129,110 +153,6 @@ paths:
description: ""
schema:
$ref: '#/definitions/models.workflow'
- /workflow/resource/:
- get:
- tags:
- - workflow/resource
- description: |-
- find workflow by workflowid
-
- operationId: WorkflowResourceController.GetAll
- responses:
- "200":
- description: '{workflow} models.workflow'
- post:
- tags:
- - workflow/resource
- description: |-
- create workflows
-
- operationId: WorkflowResourceController.Create
- parameters:
- - in: body
- name: data
- description: body for data content (Json format)
- required: true
- schema:
- $ref: '#/definitions/json'
- responses:
- "200":
- description: ""
- schema:
- $ref: '#/definitions/models.workflow'
- /workflow/resource/{id}:
- get:
- tags:
- - workflow/resource
- description: |-
- find workflows
-
- operationId: WorkflowResourceController.Get
- parameters:
- - in: path
- name: id
- description: the workflowid you want to get
- required: true
- type: string
- responses:
- "200":
- description: '{workflow} models.workflow'
- put:
- tags:
- - workflow/resource
- description: |-
- create workflows
-
- operationId: WorkflowResourceController.Update
- parameters:
- - in: path
- name: id
- description: the workflowid you want to get
- required: true
- type: string
- - in: body
- name: body
- description: The workflow content
- required: true
- schema:
- $ref: '#/definitions/models.workflow'
- responses:
- "200":
- description: ""
- schema:
- $ref: '#/definitions/models.workflow'
- delete:
- tags:
- - workflow/resource
- description: |-
- delete the workflow
-
- operationId: WorkflowResourceController.Delete
- parameters:
- - in: path
- name: id
- description: The workflowId you want to delete
- required: true
- type: string
- responses:
- "200":
- description: '{string} delete success!'
- /workflow/resource/search/{search}:
- get:
- tags:
- - workflow/resource
- description: |-
- search workspace
-
- operationId: WorkflowResourceController.Search
- parameters:
- - in: path
- name: search
- description: the word search you want to get
- required: true
- type: string
- responses:
- "200":
- description: '{workspace} models.workspace'
/workflow/search/{search}:
get:
tags:
@@ -254,6 +174,9 @@ definitions:
json:
title: json
type: object
+ models.object:
+ title: object
+ type: object
models.workflow:
title: workflow
type: object
@@ -261,9 +184,6 @@ tags:
- name: workflow
description: |
Operations about workflow
-- name: workflow/resource
- description: |
- Operations about workflow
- name: version
description: |
VersionController operations for Version