entry to upload datas
This commit is contained in:
57
controllers/general.go
Executable file
57
controllers/general.go
Executable file
@@ -0,0 +1,57 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Operations about compute
|
||||||
|
type GeneralController struct {
|
||||||
|
beego.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title GetAll
|
||||||
|
// @Description find compute by id
|
||||||
|
// @Param file formData file true "File to upload"
|
||||||
|
// @Success 200 {compute} models.workflow
|
||||||
|
// @Failure 406 {string} string "Bad request"
|
||||||
|
// @router / [get]
|
||||||
|
func (o *GeneralController) GetAll() {
|
||||||
|
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||||
|
file, _, err := o.Ctx.Request.FormFile("file")
|
||||||
|
if err != nil {
|
||||||
|
o.Data["json"] = map[string]interface{}{
|
||||||
|
"data": nil,
|
||||||
|
"code": 406,
|
||||||
|
"error": err.Error(),
|
||||||
|
}
|
||||||
|
o.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
newWorkflow := &w.Workflow{}
|
||||||
|
req := &tools.APIRequest{
|
||||||
|
Username: user,
|
||||||
|
PeerID: peerID,
|
||||||
|
Groups: groups,
|
||||||
|
}
|
||||||
|
newWorkflow, err = newWorkflow.ExtractFromPlantUML(file, req)
|
||||||
|
if err != nil {
|
||||||
|
o.Data["json"] = map[string]interface{}{
|
||||||
|
"data": nil,
|
||||||
|
"code": 406,
|
||||||
|
"error": err.Error(),
|
||||||
|
}
|
||||||
|
o.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
o.Data["json"] = map[string]interface{}{
|
||||||
|
"data": newWorkflow,
|
||||||
|
"code": 200,
|
||||||
|
"error": nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
o.ServeJSON()
|
||||||
|
}
|
||||||
2
go.mod
2
go.mod
@@ -5,7 +5,7 @@ go 1.23.0
|
|||||||
toolchain go1.24.0
|
toolchain go1.24.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250624102227-e600fedcab06
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260112132629-be770ec763b1
|
||||||
github.com/beego/beego/v2 v2.3.4
|
github.com/beego/beego/v2 v2.3.4
|
||||||
github.com/smartystreets/goconvey v1.7.2
|
github.com/smartystreets/goconvey v1.7.2
|
||||||
)
|
)
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -50,6 +50,10 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20250624095852-147c7bc3a1d5 h1:0eV0E3kBZkOyo
|
|||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250624095852-147c7bc3a1d5/go.mod h1:vHWauJsS6ryf7UDqq8hRXoYD5RsONxcFTxeZPOztEuI=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250624095852-147c7bc3a1d5/go.mod h1:vHWauJsS6ryf7UDqq8hRXoYD5RsONxcFTxeZPOztEuI=
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250624102227-e600fedcab06 h1:+RSv62uIC7wsmibsp1XTanQMNznNeOGgPpfhb6ZHT4c=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250624102227-e600fedcab06 h1:+RSv62uIC7wsmibsp1XTanQMNznNeOGgPpfhb6ZHT4c=
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250624102227-e600fedcab06/go.mod h1:vHWauJsS6ryf7UDqq8hRXoYD5RsONxcFTxeZPOztEuI=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20250624102227-e600fedcab06/go.mod h1:vHWauJsS6ryf7UDqq8hRXoYD5RsONxcFTxeZPOztEuI=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260112110032-27f295f17e05 h1:3d/ulu/bVexfD2RgP8hdWFtZCByWmxWKc+cxP40nhh0=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260112110032-27f295f17e05/go.mod h1:vHWauJsS6ryf7UDqq8hRXoYD5RsONxcFTxeZPOztEuI=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260112132629-be770ec763b1 h1:MOllR71ruHvBZK3nxeOAnHa9xjnotnlngMEGZqEBp2g=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260112132629-be770ec763b1/go.mod h1:vHWauJsS6ryf7UDqq8hRXoYD5RsONxcFTxeZPOztEuI=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/beego/beego/v2 v2.3.4 h1:HurQEOGIEhLlPFCTR6ZDuQkybrUl2Ag2i6CdVD2rGiI=
|
github.com/beego/beego/v2 v2.3.4 h1:HurQEOGIEhLlPFCTR6ZDuQkybrUl2Ag2i6CdVD2rGiI=
|
||||||
github.com/beego/beego/v2 v2.3.4/go.mod h1:5cqHsOHJIxkq44tBpRvtDe59GuVRVv/9/tyVDxd5ce4=
|
github.com/beego/beego/v2 v2.3.4/go.mod h1:5cqHsOHJIxkq44tBpRvtDe59GuVRVv/9/tyVDxd5ce4=
|
||||||
|
|||||||
BIN
oc-catalog
BIN
oc-catalog
Binary file not shown.
@@ -232,6 +232,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["oc-catalog/controllers:GeneralController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:GeneralController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetAll",
|
||||||
|
Router: `/`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["oc-catalog/controllers:ProcessingController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:ProcessingController"],
|
beego.GlobalControllerRouter["oc-catalog/controllers:ProcessingController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:ProcessingController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "Post",
|
Method: "Post",
|
||||||
@@ -286,6 +295,42 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["oc-catalog/controllers:PurchaseController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:PurchaseController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "Post",
|
||||||
|
Router: `/`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["oc-catalog/controllers:PurchaseController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:PurchaseController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetAll",
|
||||||
|
Router: `/`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["oc-catalog/controllers:PurchaseController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:PurchaseController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "Get",
|
||||||
|
Router: `/:id`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["oc-catalog/controllers:PurchaseController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:PurchaseController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "Search",
|
||||||
|
Router: `/search/:search`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"],
|
beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:ResourceController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetAll",
|
Method: "GetAll",
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
ns := beego.NewNamespace("/oc/",
|
ns := beego.NewNamespace("/oc/",
|
||||||
|
beego.NSNamespace("/generic",
|
||||||
|
beego.NSInclude(
|
||||||
|
&controllers.GeneralController{},
|
||||||
|
),
|
||||||
|
),
|
||||||
beego.NSNamespace("/purchase",
|
beego.NSNamespace("/purchase",
|
||||||
beego.NSInclude(
|
beego.NSInclude(
|
||||||
&controllers.PurchaseController{},
|
&controllers.PurchaseController{},
|
||||||
|
|||||||
@@ -476,6 +476,32 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/generic/": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"generic"
|
||||||
|
],
|
||||||
|
"description": "find compute by id\n\u003cbr\u003e",
|
||||||
|
"operationId": "GeneralController.GetAll",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "formData",
|
||||||
|
"name": "file",
|
||||||
|
"description": "File to upload",
|
||||||
|
"required": true,
|
||||||
|
"type": "file"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{compute} models.workflow"
|
||||||
|
},
|
||||||
|
"406": {
|
||||||
|
"description": "{string} string \"Bad request\""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/processing/": {
|
"/processing/": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -624,6 +650,103 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/purchase/": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"purchase"
|
||||||
|
],
|
||||||
|
"description": "find compute by id\n\u003cbr\u003e",
|
||||||
|
"operationId": "PurchaseController.GetAll",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "is_draft",
|
||||||
|
"description": "draft wished",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{compute} models.compute"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"purchase"
|
||||||
|
],
|
||||||
|
"description": "create compute\n\u003cbr\u003e",
|
||||||
|
"operationId": "PurchaseController.Create",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "body",
|
||||||
|
"name": "compute",
|
||||||
|
"description": "body for compute content (Json format)",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{compute} models.compute"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/purchase/search/{search}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"purchase"
|
||||||
|
],
|
||||||
|
"description": "find compute by key word\n\u003cbr\u003e",
|
||||||
|
"operationId": "PurchaseController.Get",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "search",
|
||||||
|
"description": "the search you want to get",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "is_draft",
|
||||||
|
"description": "draft wished",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{compute} models.compute"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/purchase/{id}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"purchase"
|
||||||
|
],
|
||||||
|
"description": "find compute by id\n\u003cbr\u003e",
|
||||||
|
"operationId": "PurchaseController.Get",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"description": "the id you want to get",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{compute} models.compute"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/resource/": {
|
"/resource/": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -1071,6 +1194,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tags": [
|
"tags": [
|
||||||
|
{
|
||||||
|
"name": "generic",
|
||||||
|
"description": "Operations about compute\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "purchase",
|
||||||
|
"description": "Operations about compute\n"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "resource",
|
"name": "resource",
|
||||||
"description": "Operations about resource\n"
|
"description": "Operations about resource\n"
|
||||||
|
|||||||
@@ -359,6 +359,25 @@ paths:
|
|||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: '{resource} models.resource'
|
description: '{resource} models.resource'
|
||||||
|
/generic/:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- generic
|
||||||
|
description: |-
|
||||||
|
find compute by id
|
||||||
|
<br>
|
||||||
|
operationId: GeneralController.GetAll
|
||||||
|
parameters:
|
||||||
|
- in: formData
|
||||||
|
name: file
|
||||||
|
description: File to upload
|
||||||
|
required: true
|
||||||
|
type: file
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{compute} models.workflow'
|
||||||
|
"406":
|
||||||
|
description: '{string} string "Bad request"'
|
||||||
/processing/:
|
/processing/:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -468,6 +487,77 @@ paths:
|
|||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: '{processing} models.processing'
|
description: '{processing} models.processing'
|
||||||
|
/purchase/:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- purchase
|
||||||
|
description: |-
|
||||||
|
find compute by id
|
||||||
|
<br>
|
||||||
|
operationId: PurchaseController.GetAll
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: is_draft
|
||||||
|
description: draft wished
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{compute} models.compute'
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- purchase
|
||||||
|
description: |-
|
||||||
|
create compute
|
||||||
|
<br>
|
||||||
|
operationId: PurchaseController.Create
|
||||||
|
parameters:
|
||||||
|
- in: body
|
||||||
|
name: compute
|
||||||
|
description: body for compute content (Json format)
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/json'
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{compute} models.compute'
|
||||||
|
/purchase/{id}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- purchase
|
||||||
|
description: |-
|
||||||
|
find compute by id
|
||||||
|
<br>
|
||||||
|
operationId: PurchaseController.Get
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: id
|
||||||
|
description: the id you want to get
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{compute} models.compute'
|
||||||
|
/purchase/search/{search}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- purchase
|
||||||
|
description: |-
|
||||||
|
find compute by key word
|
||||||
|
<br>
|
||||||
|
operationId: PurchaseController.Get
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: search
|
||||||
|
description: the search you want to get
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: is_draft
|
||||||
|
description: draft wished
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{compute} models.compute'
|
||||||
/resource/:
|
/resource/:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -798,6 +888,12 @@ definitions:
|
|||||||
title: workflow
|
title: workflow
|
||||||
type: object
|
type: object
|
||||||
tags:
|
tags:
|
||||||
|
- name: generic
|
||||||
|
description: |
|
||||||
|
Operations about compute
|
||||||
|
- name: purchase
|
||||||
|
description: |
|
||||||
|
Operations about compute
|
||||||
- name: resource
|
- name: resource
|
||||||
description: |
|
description: |
|
||||||
Operations about resource
|
Operations about resource
|
||||||
|
|||||||
Reference in New Issue
Block a user