58 lines
1.2 KiB
Go
Executable File
58 lines
1.2 KiB
Go
Executable File
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()
|
|
}
|