Oc Catalog Full Controllers

This commit is contained in:
mr 2024-07-30 10:07:34 +02:00
parent 8be1828ddc
commit 1bb89db5c8
12 changed files with 196 additions and 157 deletions

View File

@ -52,7 +52,7 @@ func (o *DataController) GetAll() {
// @Description find data by key word
// @Param search path string true "the search you want to get"
// @Success 200 {data} models.data
// @router /:search [get]
// @router /search/:search [get]
func (o *DataController) Search() {
search := o.Ctx.Input.Param(":search")
o.Data["json"] = oclib.Search(search, oclib.LibDataEnum(oclib.DATA_RESOURCE))

View File

@ -52,7 +52,7 @@ func (o *DatacenterController) GetAll() {
// @Description find datacenter by key word
// @Param search path string true "the search you want to get"
// @Success 200 {datacenter} models.datacenter
// @router /:search [get]
// @router /search/:search [get]
func (o *DatacenterController) Search() {
search := o.Ctx.Input.Param(":search")
o.Data["json"] = oclib.Search(search, oclib.LibDataEnum(oclib.DATACENTER_RESOURCE))

View File

@ -52,7 +52,7 @@ func (o *ProcessingController) GetAll() {
// @Description find processing by key word
// @Param search path string true "the search you want to get"
// @Success 200 {processing} models.processing
// @router /:search [get]
// @router /search/:search [get]
func (o *ProcessingController) Search() {
search := o.Ctx.Input.Param(":search")
o.Data["json"] = oclib.Search(search, oclib.LibDataEnum(oclib.PROCESSING_RESOURCE))

View File

@ -17,7 +17,12 @@ type ResourceController struct {
func (o *ResourceController) GetAll() {
results := map[string]interface{}{}
for _, resource := range []oclib.LibDataEnum{oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.STORAGE_RESOURCE), oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} {
results[resource.String()] = oclib.LoadAll(resource)
d := oclib.LoadAll(resource)
if d.Code != 200 || len(d.Data) == 0 {
results[resource.String()] = []interface{}{}
} else {
results[resource.String()] = d
}
}
o.Data["json"] = results
o.ServeJSON()
@ -27,12 +32,17 @@ func (o *ResourceController) GetAll() {
// @Description find resource by key word
// @Param search path string true "the search you want to get"
// @Success 200 {resource} models.resource
// @router /:search [get]
// @router /search/:search [get]
func (o *ResourceController) Search() {
search := o.Ctx.Input.Param(":search")
results := map[string]interface{}{}
for _, resource := range []oclib.LibDataEnum{oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.STORAGE_RESOURCE), oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} {
results[resource.String()] = oclib.Search(search, resource)
d := oclib.Search(search, resource)
if d.Code != 200 || len(d.Data) == 0 {
results[resource.String()] = []interface{}{}
} else {
results[resource.String()] = d
}
}
o.Data["json"] = results
o.ServeJSON()
@ -46,8 +56,14 @@ func (o *ResourceController) Search() {
func (o *ResourceController) Get() {
id := o.Ctx.Input.Param(":id")
results := map[string]interface{}{}
for _, resource := range []oclib.LibDataEnum{oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.STORAGE_RESOURCE), oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} {
results[resource.String()] = oclib.LoadOne(resource, id)
for _, resource := range []oclib.LibDataEnum{oclib.LibDataEnum(oclib.DATACENTER_RESOURCE),
oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.STORAGE_RESOURCE), oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} {
d := oclib.LoadOne(resource, id)
if d.Code != 200 {
results[resource.String()] = nil
} else {
results[resource.String()] = d
}
}
o.Data["json"] = results
o.ServeJSON()
@ -62,7 +78,12 @@ func (o *ResourceController) Delete() {
id := o.Ctx.Input.Param(":id")
results := map[string]interface{}{}
for _, resource := range []oclib.LibDataEnum{oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.STORAGE_RESOURCE), oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} {
results[resource.String()] = oclib.DeleteOne(resource, id)
d := oclib.DeleteOne(resource, id)
if d.Code != 200 {
results[resource.String()] = nil
} else {
results[resource.String()] = d
}
}
o.Data["json"] = results
o.ServeJSON()

View File

@ -31,7 +31,7 @@ func (o *StorageController) Put() {
// @Description find storage by key word
// @Param search path string true "the search you want to get"
// @Success 200 {storage} models.storage
// @router /:search [get]
// @router /search/:search [get]
func (o *StorageController) Search() {
search := o.Ctx.Input.Param(":search")
o.Data["json"] = oclib.Search(search, oclib.LibDataEnum(oclib.STORAGE_RESOURCE))

View File

@ -31,7 +31,7 @@ func (o *WorkflowController) Put() {
// @Description find workflow by key word
// @Param search path string true "the search you want to get"
// @Success 200 {workflow} models.workflow
// @router /:search [get]
// @router /search/:search [get]
func (o *WorkflowController) Search() {
search := o.Ctx.Input.Param(":search")
o.Data["json"] = oclib.Search(search, oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE))

2
go.mod
View File

@ -11,7 +11,7 @@ require (
)
require (
cloud.o-forge.io/core/oc-lib v0.0.0-20240726144711-ff286583aada // indirect
cloud.o-forge.io/core/oc-lib v0.0.0-20240730072752-250fefd0d85e // 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

18
go.sum
View File

@ -98,6 +98,24 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20240726131936-87b7cda0ce28 h1:nx7xOMXuQHDJN
cloud.o-forge.io/core/oc-lib v0.0.0-20240726131936-87b7cda0ce28/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240726144711-ff286583aada h1:pUe+iliStLC0vcK9Qkn5PZlE39QtcrCntH5cxduxZjE=
cloud.o-forge.io/core/oc-lib v0.0.0-20240726144711-ff286583aada/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240729121948-e2f722e17bb6 h1:EDwuA0giARIo5UFicOVGAkTIK0xQCk9HQJvNxcflflQ=
cloud.o-forge.io/core/oc-lib v0.0.0-20240729121948-e2f722e17bb6/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240729130759-8c3b92143e0e h1:abhr0aePGHBhBkuP7OYvCYPmOAVCTA9hlgeJltSpSOM=
cloud.o-forge.io/core/oc-lib v0.0.0-20240729130759-8c3b92143e0e/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240729132214-d77a403150d8 h1:SWTfZIJ7Nq+1cfrfMEKG95DTxwXISyz1ul0N9zexWK8=
cloud.o-forge.io/core/oc-lib v0.0.0-20240729132214-d77a403150d8/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240729135315-2f6fab2f7b23 h1:EyWdP+NCgVSdHW9jZbp0nlAwNVLro+yzWZL9mrgdZRM=
cloud.o-forge.io/core/oc-lib v0.0.0-20240729135315-2f6fab2f7b23/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240729142352-3e72510d53d8 h1:eZJVDix6Kq0CHLi78pKFp3keUcibJInk4NIzaBMegeQ=
cloud.o-forge.io/core/oc-lib v0.0.0-20240729142352-3e72510d53d8/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240729150539-dc30412f2edc h1:Q70pRG2f6fULpw+BE7ECQO7wk/Wy9VreZPrpuUXJ9yA=
cloud.o-forge.io/core/oc-lib v0.0.0-20240729150539-dc30412f2edc/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240730063928-0e96b5c01a4f h1:AQuTEgzKJCd05QKyI9yx6v65L4IbPQX7nQLaLvO+ots=
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-20240730072752-250fefd0d85e h1:1rBqh6/cGgCukaRhj0I5Ypb6ydA9/EHUsH/pw+1yJQ4=
cloud.o-forge.io/core/oc-lib v0.0.0-20240730072752-250fefd0d85e/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=

Binary file not shown.

View File

@ -55,7 +55,7 @@ func init() {
beego.GlobalControllerRouter["oc-catalog/controllers:DataController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:DataController"],
beego.ControllerComments{
Method: "Search",
Router: `/:search`,
Router: `/search/:search`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
@ -109,7 +109,7 @@ func init() {
beego.GlobalControllerRouter["oc-catalog/controllers:DatacenterController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:DatacenterController"],
beego.ControllerComments{
Method: "Search",
Router: `/:search`,
Router: `/search/:search`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
@ -163,7 +163,7 @@ func init() {
beego.GlobalControllerRouter["oc-catalog/controllers:ProcessingController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:ProcessingController"],
beego.ControllerComments{
Method: "Search",
Router: `/:search`,
Router: `/search/:search`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
@ -199,7 +199,7 @@ func init() {
beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"],
beego.ControllerComments{
Method: "Search",
Router: `/:search`,
Router: `/search/:search`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
@ -253,7 +253,7 @@ func init() {
beego.GlobalControllerRouter["oc-catalog/controllers:StorageController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:StorageController"],
beego.ControllerComments{
Method: "Search",
Router: `/:search`,
Router: `/search/:search`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
@ -316,7 +316,7 @@ func init() {
beego.GlobalControllerRouter["oc-catalog/controllers:WorkflowController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:WorkflowController"],
beego.ControllerComments{
Method: "Search",
Router: `/:search`,
Router: `/search/:search`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,

View File

@ -52,6 +52,29 @@
}
}
},
"/data/search/{search}": {
"get": {
"tags": [
"data"
],
"description": "find data by key word\n\u003cbr\u003e",
"operationId": "DataController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{data} models.data"
}
}
}
},
"/data/{id}": {
"get": {
"tags": [
@ -126,29 +149,6 @@
}
}
},
"/data/{search}": {
"get": {
"tags": [
"data"
],
"description": "find data by key word\n\u003cbr\u003e",
"operationId": "DataController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{data} models.data"
}
}
}
},
"/datacenter/": {
"get": {
"tags": [
@ -186,6 +186,29 @@
}
}
},
"/datacenter/search/{search}": {
"get": {
"tags": [
"datacenter"
],
"description": "find datacenter by key word\n\u003cbr\u003e",
"operationId": "DatacenterController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{datacenter} models.datacenter"
}
}
}
},
"/datacenter/{id}": {
"get": {
"tags": [
@ -260,29 +283,6 @@
}
}
},
"/datacenter/{search}": {
"get": {
"tags": [
"datacenter"
],
"description": "find datacenter by key word\n\u003cbr\u003e",
"operationId": "DatacenterController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{datacenter} models.datacenter"
}
}
}
},
"/processing/": {
"get": {
"tags": [
@ -320,6 +320,29 @@
}
}
},
"/processing/search/{search}": {
"get": {
"tags": [
"processing"
],
"description": "find processing by key word\n\u003cbr\u003e",
"operationId": "ProcessingController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{processing} models.processing"
}
}
}
},
"/processing/{id}": {
"get": {
"tags": [
@ -394,13 +417,27 @@
}
}
},
"/processing/{search}": {
"/resource/": {
"get": {
"tags": [
"processing"
"resource"
],
"description": "find processing by key word\n\u003cbr\u003e",
"operationId": "ProcessingController.Get",
"description": "find resource by id\n\u003cbr\u003e",
"operationId": "ResourceController.GetAll",
"responses": {
"200": {
"description": "{resource} models.resource"
}
}
}
},
"/resource/search/{search}": {
"get": {
"tags": [
"resource"
],
"description": "find resource by key word\n\u003cbr\u003e",
"operationId": "ResourceController.Get",
"parameters": [
{
"in": "path",
@ -410,20 +447,6 @@
"type": "string"
}
],
"responses": {
"200": {
"description": "{processing} models.processing"
}
}
}
},
"/resource/": {
"get": {
"tags": [
"resource"
],
"description": "find resource by id\n\u003cbr\u003e",
"operationId": "ResourceController.GetAll",
"responses": {
"200": {
"description": "{resource} models.resource"
@ -475,29 +498,6 @@
}
}
},
"/resource/{search}": {
"get": {
"tags": [
"resource"
],
"description": "find resource by key word\n\u003cbr\u003e",
"operationId": "ResourceController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{resource} models.resource"
}
}
}
},
"/storage/": {
"get": {
"tags": [
@ -535,6 +535,29 @@
}
}
},
"/storage/search/{search}": {
"get": {
"tags": [
"storage"
],
"description": "find storage by key word\n\u003cbr\u003e",
"operationId": "StorageController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{storage} models.storage"
}
}
}
},
"/storage/{id}": {
"get": {
"tags": [
@ -609,29 +632,6 @@
}
}
},
"/storage/{search}": {
"get": {
"tags": [
"storage"
],
"description": "find storage by key word\n\u003cbr\u003e",
"operationId": "StorageController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{storage} models.storage"
}
}
}
},
"/version/": {
"get": {
"tags": [
@ -683,6 +683,29 @@
}
}
},
"/workflow/search/{search}": {
"get": {
"tags": [
"workflow"
],
"description": "find workflow by key word\n\u003cbr\u003e",
"operationId": "WorkflowController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{workflow} models.workflow"
}
}
}
},
"/workflow/{id}": {
"get": {
"tags": [
@ -756,29 +779,6 @@
}
}
}
},
"/workflow/{search}": {
"get": {
"tags": [
"workflow"
],
"description": "find workflow by key word\n\u003cbr\u003e",
"operationId": "WorkflowController.Get",
"parameters": [
{
"in": "path",
"name": "search",
"description": "the search you want to get",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "{workflow} models.workflow"
}
}
}
}
},
"definitions": {

View File

@ -95,7 +95,7 @@ paths:
responses:
"200":
description: '{data} delete success!'
/data/{search}:
/data/search/{search}:
get:
tags:
- data
@ -195,7 +195,7 @@ paths:
responses:
"200":
description: '{datacenter} delete success!'
/datacenter/{search}:
/datacenter/search/{search}:
get:
tags:
- datacenter
@ -295,7 +295,7 @@ paths:
responses:
"200":
description: '{processing} delete success!'
/processing/{search}:
/processing/search/{search}:
get:
tags:
- processing
@ -356,7 +356,7 @@ paths:
responses:
"200":
description: '{resource} delete success!'
/resource/{search}:
/resource/search/{search}:
get:
tags:
- resource
@ -456,7 +456,7 @@ paths:
responses:
"200":
description: '{storage} delete success!'
/storage/{search}:
/storage/search/{search}:
get:
tags:
- storage
@ -567,7 +567,7 @@ paths:
responses:
"200":
description: '{workflow} delete success!'
/workflow/{search}:
/workflow/search/{search}:
get:
tags:
- workflow