diff --git a/controllers/workflow.go b/controllers/workflow.go index 4539e27..8da2472 100644 --- a/controllers/workflow.go +++ b/controllers/workflow.go @@ -12,6 +12,18 @@ type WorkflowController struct { beego.Controller } +// @Title Search +// @Description search workspace +// @Param search path string true "the word search you want to get" +// @Success 200 {workspace} models.workspace +// @router /search/:search [get] +func (o *WorkflowController) Search() { + // store and return Id or post with UUID + search := o.Ctx.Input.Param(":search") + o.Data["json"] = oclib.Search(nil, search, oclib.LibDataEnum(oclib.WORKFLOW)) + o.ServeJSON() +} + // @Title Update // @Description create workflows // @Param id path string true "the workflowid you want to get" diff --git a/controllers/workflow_execution.go b/controllers/workflow_execution.go new file mode 100644 index 0000000..943cede --- /dev/null +++ b/controllers/workflow_execution.go @@ -0,0 +1,56 @@ +package controllers + +import ( + "time" + + oclib "cloud.o-forge.io/core/oc-lib" + dbs "cloud.o-forge.io/core/oc-lib/dbs" + beego "github.com/beego/beego/v2/server/web" + "go.mongodb.org/mongo-driver/bson/primitive" +) + +// Operations about workflow +type WorkflowExecutionController struct { + beego.Controller +} + +// @Title Search +// @Description search workspace +// @Param start_date path string true "the word search you want to get" +// @Param end_date path string true "the word search you want to get" +// @Success 200 {workspace} models.workspace +// @router /search/:start_date/:end_date [get] +func (o *WorkflowExecutionController) Search() { + // store and return Id or post with UUID + start_date, _ := time.Parse("2006-01-02", o.Ctx.Input.Param(":start_date")) + end_date, _ := time.Parse("2006-01-02", o.Ctx.Input.Param(":end_date")) + sd := primitive.NewDateTimeFromTime(start_date) + ed := primitive.NewDateTimeFromTime(end_date) + f := dbs.Filters{ + And: map[string][]dbs.Filter{ + "execution_date": {{Operator: "gte", Value: sd}, {Operator: "lte", Value: ed}}, + }, + } + o.Data["json"] = oclib.Search(&f, "", oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION)) + o.ServeJSON() +} + +// @Title GetAll +// @Description find workflow by workflowid +// @Success 200 {workflow} models.workflow +// @router / [get] +func (o *WorkflowExecutionController) GetAll() { + o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION)) + o.ServeJSON() +} + +// @Title Get +// @Description find workflow by workflowid +// @Param id path string true "the workflowid you want to get" +// @Success 200 {workflow} models.workflow +// @router /:id [get] +func (o *WorkflowExecutionController) Get() { + id := o.Ctx.Input.Param(":id") + o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), id) + o.ServeJSON() +} diff --git a/controllers/workflow_resource.go b/controllers/workflow_resource.go index 3a281f6..dfa49e9 100644 --- a/controllers/workflow_resource.go +++ b/controllers/workflow_resource.go @@ -12,12 +12,24 @@ type WorkflowResourceController struct { beego.Controller } +// @Title Search +// @Description search workspace +// @Param search path string true "the word search you want to get" +// @Success 200 {workspace} models.workspace +// @router /search/:search [get] +func (o *WorkflowResourceController) Search() { + // store and return Id or post with UUID + search := o.Ctx.Input.Param(":search") + o.Data["json"] = oclib.Search(nil, search, oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)) + o.ServeJSON() +} + // @Title GetAll // @Description find workflow by workflowid // @Success 200 {workflow} models.workflow // @router / [get] func (o *WorkflowResourceController) GetAll() { - o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.WORKFLOW)) + o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)) o.ServeJSON() } diff --git a/go.mod b/go.mod index 2afcd5c..1e06464 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( ) require ( - cloud.o-forge.io/core/oc-lib v0.0.0-20240730065931-4730d5b4d401 // indirect + cloud.o-forge.io/core/oc-lib v0.0.0-20240806064253-29fcd0e34a72 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/beego/bee/v2 v2.1.0 // indirect github.com/beorn7/perks v1.0.1 // indirect diff --git a/go.sum b/go.sum index 447d437..86660fb 100644 --- a/go.sum +++ b/go.sum @@ -98,6 +98,46 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20240730063928-0e96b5c01a4f h1:AQuTEgzKJCd05 cloud.o-forge.io/core/oc-lib v0.0.0-20240730063928-0e96b5c01a4f/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= cloud.o-forge.io/core/oc-lib v0.0.0-20240730065931-4730d5b4d401 h1:kp1sHyrRIoa4i9tjUuFvFMVRSfUC+093s9KcWLiURy8= cloud.o-forge.io/core/oc-lib v0.0.0-20240730065931-4730d5b4d401/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240731095057-63236362ca3d h1:uBn7AeWPFCmhN6hknTOUwtGZvlEcTTDUPpDNaBNEutM= +cloud.o-forge.io/core/oc-lib v0.0.0-20240731095057-63236362ca3d/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240801071310-924a688a9d3f h1:w4KMhEFwcJrVhinhuo4G/A/pJZOpHQSA8BB/1LV8aN4= +cloud.o-forge.io/core/oc-lib v0.0.0-20240801071310-924a688a9d3f/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802090418-ed4cb943a8ca h1:YehMjDX6vXnIMsQ0NBR8Lub5PZsw8xu4t6Smm/Ui02A= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802090418-ed4cb943a8ca/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802091704-9da3a7c3e671 h1:nnuPasO4CMmPMEj8svMm+N1IaDU8oIyOLdiCwWiaU2Q= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802091704-9da3a7c3e671/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802094359-d0e27782461b h1:e5uO3Qb0dbHLmk5RBfwTKeR0GUOe3D1e/ExWoL2Zm08= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802094359-d0e27782461b/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802111304-e23756eba601 h1:10dEpwkdyzd5yKYYs+qBpmaQEsNJVaL3nbBrHv7g9hY= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802111304-e23756eba601/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802120743-fa52c71e9341 h1:YCi0qadKOGcBVk0qaJGSLL9EL9Xzirunfuaq12jAyY0= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802120743-fa52c71e9341/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802130640-efa73d8a4533 h1:kpEACrSNMtypI1GZ+SSJ3hlhBuvbcMo96paDf2B8sck= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802130640-efa73d8a4533/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802133652-24a277333dee h1:w8VuhNwVlSgMVmjhyHNJmgAj5NTA1afayOawnrv/Wmc= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802133652-24a277333dee/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802134557-09b67b26b03c h1:gwymFdNSMHh298lMz8WzaeWmkK1aCm9S7lYycNgrsak= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802134557-09b67b26b03c/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802140917-89f14d99b81c h1:4CCeCOm/g5f32e5u8FHRWTNr+WyoJ6JHaSouMpDbAH4= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802140917-89f14d99b81c/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802144545-caf0c1afcb9d h1:N1T31eX6QeofEqprC+HjzeSfaEDwqV42dL/blXLAXsE= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802144545-caf0c1afcb9d/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802150029-e320efd70e22 h1:yqtiZ2bEJyBEfjLAaMqt7UWZB9gUH9YUf1hC0B1So1w= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802150029-e320efd70e22/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802153851-0b5df45a029f h1:eLrWMuEFtkL5Ruv1BEnLh7a6y21PvkVQ4HX4YDt5CCA= +cloud.o-forge.io/core/oc-lib v0.0.0-20240802153851-0b5df45a029f/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240805061543-1f09e48abfdf h1:TGKMHh1ZFLBOEumxE2TAvkw8fwxI75b8CcGdQDQ44Po= +cloud.o-forge.io/core/oc-lib v0.0.0-20240805061543-1f09e48abfdf/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240805062837-e390dfa8a91c h1:Wbcms8HPNQw/RREgPV8GFOjPhkspy5WBDS2dTRtfgoU= +cloud.o-forge.io/core/oc-lib v0.0.0-20240805062837-e390dfa8a91c/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240805065020-1e8cb980980b h1:fbQ94JU+jcQqMGy/y84h39lB6se2JiFqqdh+KsxG1KY= +cloud.o-forge.io/core/oc-lib v0.0.0-20240805065020-1e8cb980980b/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240805081058-dd5f8f5b2d40 h1:AQ3gGnnmJnF9ieMZ50wMx9UldY/zN4LOvOzfmAtwdzk= +cloud.o-forge.io/core/oc-lib v0.0.0-20240805081058-dd5f8f5b2d40/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240805134753-17f62b649523 h1:/gN4169dtvbyi3+oLfHTMe8RlfX+P4VrV+1nfAThS+k= +cloud.o-forge.io/core/oc-lib v0.0.0-20240805134753-17f62b649523/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20240806064253-29fcd0e34a72 h1:JWnarWFrCNWPrk3CAuQ66YM/fzTTmvgBcLMSNCoIZaA= +cloud.o-forge.io/core/oc-lib v0.0.0-20240806064253-29fcd0e34a72/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= diff --git a/main.go b/main.go index 05edc20..34e87bf 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "fmt" _ "oc-workflow/routers" oclib "cloud.o-forge.io/core/oc-lib" @@ -33,11 +32,9 @@ func main() { } else if l2 == nil { o = onion.New(l1, l3) } - fmt.Println("BSLDMqlkd", o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017"), - o.GetStringDefault("MONGO_DATABASE", "DC_myDC-demo_06042021")) oclib.SetConfig( o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017"), - o.GetStringDefault("MONGO_DATABASE", "DC_myDC-demo_06042021"), + o.GetStringDefault("MONGO_DATABASE", "DC_myDC"), ) oclib.Init("oc-workflow") // Normal beego init diff --git a/oc-workflow b/oc-workflow index 5a6f6c9..5961f23 100755 Binary files a/oc-workflow and b/oc-workflow differ diff --git a/routers/commentsRouter.go b/routers/commentsRouter.go index c2154ce..de71851 100644 --- a/routers/commentsRouter.go +++ b/routers/commentsRouter.go @@ -70,6 +70,42 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowController"], + beego.ControllerComments{ + Method: "Search", + Router: `/search/:search`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + + beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowExecutionController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowExecutionController"], + beego.ControllerComments{ + Method: "GetAll", + Router: `/`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + + beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowExecutionController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowExecutionController"], + beego.ControllerComments{ + Method: "Get", + Router: `/:id`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + + beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowExecutionController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowExecutionController"], + beego.ControllerComments{ + Method: "Search", + Router: `/search/:start_date/:end_date`, + 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: "GetAll", @@ -115,4 +151,13 @@ func init() { 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/routers/router.go b/routers/router.go index f6d0eed..aadbaa9 100644 --- a/routers/router.go +++ b/routers/router.go @@ -25,6 +25,11 @@ func init() { &controllers.WorkflowResourceController{}, ), ), + beego.NSNamespace("/workflow_execution", + beego.NSInclude( + &controllers.WorkflowExecutionController{}, + ), + ), beego.NSNamespace("/version", beego.NSInclude( &controllers.VersionController{}, diff --git a/swagger/swagger.json b/swagger/swagger.json index 0bdf3ff..0880ef2 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -135,6 +135,29 @@ } } }, + "/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": [ @@ -212,6 +235,29 @@ } } }, + "/workflow/search/{search}": { + "get": { + "tags": [ + "workflow" + ], + "description": "search workspace\n\u003cbr\u003e", + "operationId": "WorkflowController.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/{id}": { "get": { "tags": [ @@ -288,6 +334,73 @@ } } } + }, + "/workflow_execution/": { + "get": { + "tags": [ + "workflow_execution" + ], + "description": "find workflow by workflowid\n\u003cbr\u003e", + "operationId": "WorkflowExecutionController.GetAll", + "responses": { + "200": { + "description": "{workflow} models.workflow" + } + } + } + }, + "/workflow_execution/search/{start_date}/{end_date}": { + "get": { + "tags": [ + "workflow_execution" + ], + "description": "search workspace\n\u003cbr\u003e", + "operationId": "WorkflowExecutionController.Search", + "parameters": [ + { + "in": "path", + "name": "start_date", + "description": "the word search you want to get", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "end_date", + "description": "the word search you want to get", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "{workspace} models.workspace" + } + } + } + }, + "/workflow_execution/{id}": { + "get": { + "tags": [ + "workflow_execution" + ], + "description": "find workflow by workflowid\n\u003cbr\u003e", + "operationId": "WorkflowExecutionController.Get", + "parameters": [ + { + "in": "path", + "name": "id", + "description": "the workflowid you want to get", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "{workflow} models.workflow" + } + } + } } }, "definitions": { @@ -309,6 +422,10 @@ "name": "workflow/resource", "description": "Operations about workflow\n" }, + { + "name": "workflow_execution", + "description": "Operations about workflow\n" + }, { "name": "version", "description": "VersionController operations for Version\n" diff --git a/swagger/swagger.yml b/swagger/swagger.yml index 2ddb61a..8e16d0a 100644 --- a/swagger/swagger.yml +++ b/swagger/swagger.yml @@ -216,6 +216,90 @@ paths: 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: + - workflow + description: |- + search workspace +
+ operationId: WorkflowController.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_execution/: + get: + tags: + - workflow_execution + description: |- + find workflow by workflowid +
+ operationId: WorkflowExecutionController.GetAll + responses: + "200": + description: '{workflow} models.workflow' + /workflow_execution/{id}: + get: + tags: + - workflow_execution + description: |- + find workflow by workflowid +
+ operationId: WorkflowExecutionController.Get + parameters: + - in: path + name: id + description: the workflowid you want to get + required: true + type: string + responses: + "200": + description: '{workflow} models.workflow' + /workflow_execution/search/{start_date}/{end_date}: + get: + tags: + - workflow_execution + description: |- + search workspace +
+ operationId: WorkflowExecutionController.Search + parameters: + - in: path + name: start_date + description: the word search you want to get + required: true + type: string + - in: path + name: end_date + description: the word search you want to get + required: true + type: string + responses: + "200": + description: '{workspace} models.workspace' definitions: json: title: json @@ -230,6 +314,9 @@ tags: - name: workflow/resource description: | Operations about workflow +- name: workflow_execution + description: | + Operations about workflow - name: version description: | VersionController operations for Version