2024-07-11 11:40:11 +02:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
2024-08-21 12:35:06 +02:00
|
|
|
oclib "cloud.o-forge.io/core/oc-lib"
|
|
|
|
"cloud.o-forge.io/core/oc-lib/tools"
|
2024-07-11 11:40:11 +02:00
|
|
|
beego "github.com/beego/beego/v2/server/web"
|
|
|
|
)
|
|
|
|
|
|
|
|
// VersionController operations for Version
|
|
|
|
type VersionController struct {
|
|
|
|
beego.Controller
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Title GetAll
|
|
|
|
// @Description get version
|
|
|
|
// @Success 200
|
|
|
|
// @router / [get]
|
|
|
|
func (c *VersionController) GetAll() {
|
|
|
|
c.Data["json"] = map[string]string{"version": "1"}
|
|
|
|
c.ServeJSON()
|
|
|
|
}
|
2024-08-21 12:35:06 +02:00
|
|
|
|
|
|
|
// @Title Status
|
|
|
|
// @Description get status
|
|
|
|
// @Success 200
|
|
|
|
// @router /status [get]
|
|
|
|
func (c *VersionController) Status() {
|
|
|
|
errStr := ""
|
|
|
|
api := tools.API{}
|
|
|
|
state, code, err := api.GetState()
|
|
|
|
|
|
|
|
if state == tools.ALIVE {
|
|
|
|
state, _, err = api.CheckRemoteAPIs([]string{
|
|
|
|
"http://" + oclib.LibDataEnum(oclib.BOOKING).String() + oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
errStr = err.Error()
|
|
|
|
}
|
|
|
|
c.Data["json"] = map[string]interface{}{
|
|
|
|
"data": map[string]interface{}{
|
|
|
|
"state": state.String(),
|
|
|
|
"code": state,
|
|
|
|
},
|
|
|
|
"error": errStr,
|
|
|
|
"code": code,
|
|
|
|
}
|
|
|
|
c.ServeJSON()
|
|
|
|
}
|