paths debug

This commit is contained in:
mr 2024-08-13 11:36:53 +02:00
parent 08f1aced8c
commit 02d76f0066
6 changed files with 110 additions and 332 deletions

View File

@ -6,39 +6,13 @@ import (
"time" "time"
oclib "cloud.o-forge.io/core/oc-lib" 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" w "cloud.o-forge.io/core/oc-lib/models/workflow"
tools "cloud.o-forge.io/core/oc-lib/tools" tools "cloud.o-forge.io/core/oc-lib/tools"
beego "github.com/beego/beego/v2/server/web" beego "github.com/beego/beego/v2/server/web"
"github.com/nats-io/nats.go" "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 // Operations about workflow
type WorkflowController struct { type WorkflowController struct {
beego.Controller beego.Controller
@ -63,6 +37,23 @@ func (o *WorkflowController) Search() {
// @Success 200 {object} models.workflow // @Success 200 {object} models.workflow
// @router /:id [put] // @router /:id [put]
func (o *WorkflowController) 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 // store and return Id or post with UUID
var res map[string]interface{} var res map[string]interface{}
id := o.Ctx.Input.Param(":id") 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 // @Success 200 {object} models.workflow
// @router / [post] // @router / [post]
func (o *WorkflowController) 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{} var res map[string]interface{}
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res) json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
caller := tools.NewHTTPCaller(paths) caller := tools.NewHTTPCaller(paths)

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"fmt"
_ "oc-workflow/routers" _ "oc-workflow/routers"
oclib "cloud.o-forge.io/core/oc-lib" oclib "cloud.o-forge.io/core/oc-lib"
@ -38,6 +39,7 @@ func main() {
) )
oclib.Init("oc-workflow") oclib.Init("oc-workflow")
oclib.AddPath(oclib.LibDataEnum(oclib.BOOKING), o.GetStringDefault("BOOKING_URL", ":8092")) 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.SHARED_WORKSPACE), o.GetStringDefault("SHARED_WORKSPACE_URL", ":8091"))
oclib.AddPath(oclib.LibDataEnum(oclib.WORKSPACE), o.GetStringDefault("WORKSPACE_URL", ":8089")) oclib.AddPath(oclib.LibDataEnum(oclib.WORKSPACE), o.GetStringDefault("WORKSPACE_URL", ":8089"))
oclib.AddPath(oclib.LibDataEnum(oclib.WORKFLOW), o.GetStringDefault("WORKFLOW_URL", ":8088")) oclib.AddPath(oclib.LibDataEnum(oclib.WORKFLOW), o.GetStringDefault("WORKFLOW_URL", ":8088"))

Binary file not shown.

View File

@ -61,6 +61,15 @@ func init() {
Filters: nil, Filters: nil,
Params: 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.GlobalControllerRouter["oc-workflow/controllers:WorkflowController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowController"],
beego.ControllerComments{ beego.ControllerComments{
Method: "Publish", Method: "Publish",
@ -79,58 +88,4 @@ func init() {
Filters: nil, Filters: nil,
Params: 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})
} }

View File

@ -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}": { "/workflow/publish/{id}": {
"post": { "post": {
"tags": [ "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}": { "/workflow/search/{search}": {
"get": { "get": {
"tags": [ "tags": [
@ -341,6 +234,10 @@
"title": "json", "title": "json",
"type": "object" "type": "object"
}, },
"models.object": {
"title": "object",
"type": "object"
},
"models.workflow": { "models.workflow": {
"title": "workflow", "title": "workflow",
"type": "object" "type": "object"
@ -351,10 +248,6 @@
"name": "workflow", "name": "workflow",
"description": "Operations about workflow\n" "description": "Operations about workflow\n"
}, },
{
"name": "workflow/resource",
"description": "Operations about workflow\n"
},
{ {
"name": "version", "name": "version",
"description": "VersionController operations for Version\n" "description": "VersionController operations for Version\n"

View File

@ -110,6 +110,30 @@ paths:
responses: responses:
"200": "200":
description: '{string} delete success!' description: '{string} delete success!'
/workflow/check/{start_date}/{end_date}:
get:
tags:
- workflow
description: |-
check booking
<br>
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}: /workflow/publish/{id}:
post: post:
tags: tags:
@ -129,110 +153,6 @@ paths:
description: "" description: ""
schema: schema:
$ref: '#/definitions/models.workflow' $ref: '#/definitions/models.workflow'
/workflow/resource/:
get:
tags:
- workflow/resource
description: |-
find workflow by workflowid
<br>
operationId: WorkflowResourceController.GetAll
responses:
"200":
description: '{workflow} models.workflow'
post:
tags:
- workflow/resource
description: |-
create workflows
<br>
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
<br>
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
<br>
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
<br>
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
<br>
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}: /workflow/search/{search}:
get: get:
tags: tags:
@ -254,6 +174,9 @@ definitions:
json: json:
title: json title: json
type: object type: object
models.object:
title: object
type: object
models.workflow: models.workflow:
title: workflow title: workflow
type: object type: object
@ -261,9 +184,6 @@ tags:
- name: workflow - name: workflow
description: | description: |
Operations about workflow Operations about workflow
- name: workflow/resource
description: |
Operations about workflow
- name: version - name: version
description: | description: |
VersionController operations for Version VersionController operations for Version