Debug booking

This commit is contained in:
mr 2024-08-26 11:18:26 +02:00
parent ad46694516
commit 5b320bb409
13 changed files with 158 additions and 49 deletions

View File

@ -12,7 +12,7 @@ RUN timeout 15 bee run -gendoc=true -downdoc=true -runmode=dev || :
RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' swagger/index.html RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' swagger/index.html
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" . RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o setup .
RUN ls /app RUN ls /app
@ -20,11 +20,11 @@ FROM scratch
WORKDIR /app WORKDIR /app
COPY --from=builder /app/oc-workflow /usr/bin/ COPY --from=builder /app/setup /usr/bin/
COPY --from=builder /app/swagger /app/swagger COPY --from=builder /app/swagger /app/swagger
COPY docker_workflow.json /etc/oc/workflow.json COPY docker_conf.json /etc/oc/conf.json
EXPOSE 8080 EXPOSE 8080
ENTRYPOINT ["oc-workflow"] ENTRYPOINT ["setup"]

View File

@ -1,9 +1,9 @@
package controllers package controllers
import ( import (
oclib "cloud.o-forge.io/core/oc-lib"
"cloud.o-forge.io/core/oc-lib/tools" "cloud.o-forge.io/core/oc-lib/tools"
beego "github.com/beego/beego/v2/server/web" beego "github.com/beego/beego/v2/server/web"
"github.com/nats-io/nats.go"
) )
// VersionController operations for Version // VersionController operations for Version
@ -30,9 +30,7 @@ func (c *VersionController) Status() {
state, code, err := api.GetState() state, code, err := api.GetState()
if state == tools.ALIVE { if state == tools.ALIVE {
state, _, err = api.CheckRemoteAPIs([]string{ _, err = nats.Connect(tools.GetConfig().NATSUrl)
"http://" + oclib.LibDataEnum(oclib.BOOKING).String() + oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)),
})
} }
if err != nil { if err != nil {
errStr = err.Error() errStr = err.Error()

View File

@ -3,11 +3,10 @@ package controllers
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"time" "fmt"
oclib "cloud.o-forge.io/core/oc-lib" oclib "cloud.o-forge.io/core/oc-lib"
"cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/models/utils"
w "cloud.o-forge.io/core/oc-lib/models/workflow"
"cloud.o-forge.io/core/oc-lib/tools" "cloud.o-forge.io/core/oc-lib/tools"
beego "github.com/beego/beego/v2/server/web" beego "github.com/beego/beego/v2/server/web"
) )
@ -41,6 +40,9 @@ func (o *WorkflowController) Put() {
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/", tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/",
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/:id", tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/:id",
}, },
utils.PEER.String(): {
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc",
},
} }
// store and return Id or post with UUID // store and return Id or post with UUID
var res map[string]interface{} var res map[string]interface{}
@ -63,6 +65,9 @@ func (o *WorkflowController) Post() {
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/", tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/",
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/:id", tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/:id",
}, },
utils.PEER.String(): {
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc",
},
} }
var res map[string]interface{} var res map[string]interface{}
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res) json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
@ -119,6 +124,9 @@ func (o *WorkflowController) Delete() {
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/", tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/",
tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/:id", tools.DELETE: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/:id",
}, },
utils.PEER.String(): {
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc",
},
} }
id := o.Ctx.Input.Param(":id") id := o.Ctx.Input.Param(":id")
caller := tools.NewHTTPCaller(paths) caller := tools.NewHTTPCaller(paths)
@ -128,15 +136,15 @@ func (o *WorkflowController) Delete() {
// @Title Check // @Title Check
// @Description check booking // @Description check booking
// @Param start_date path string "the booking start date" format "2006-01-02T15:04:05" // @Param id path string "the booking workflow id"
// @Param end_date path string "the booking end date" format "2006-01-02T15:04:05" // @Param start_date path string "the booking start date format "2006-01-02T15:04:05"
// @Param end_date path string "the booking end date" format 2006-01-02T15:04:05"
// @Success 200 {object} models.object // @Success 200 {object} models.object
// @router /check/:start_date/:end_date [get] // @router /check/:id/:start_date/:end_date [get]
func (o *WorkflowController) Check() { func (o *WorkflowController) Check() {
// store and return Id or post with UUID // store and return Id or post with UUID
date, err := time.Parse("2006-01-02T15:04:05", o.Ctx.Input.Param(":start_date")) id := o.Ctx.Input.Param(":id")
date2, err2 := time.Parse("2006-01-02T15:04:05", o.Ctx.Input.Param(":end_date")) if id == "" {
if err != nil || err2 != nil {
o.Data["json"] = map[string]interface{}{ o.Data["json"] = map[string]interface{}{
"data": map[string]interface{}{ "data": map[string]interface{}{
"is_available": false, "is_available": false,
@ -145,9 +153,19 @@ func (o *WorkflowController) Check() {
"error": errors.New("invalid date format"), "error": errors.New("invalid date format"),
} }
} else { } else {
workflow := &w.Workflow{} fmt.Println("id", id)
workflow.Schedule = &w.WorkflowSchedule{Start: &date, End: &date2} res := oclib.LoadOne(oclib.LibDataEnum(oclib.WORKFLOW), id)
isAvailable, err := workflow.CheckBooking(oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/check/:start_date/:end_date") if res.Code == 200 {
workflow := res.ToWorkflow()
caller := tools.NewHTTPCaller(map[string]map[tools.METHOD]string{
utils.PEER.String(): {
tools.POST: oclib.GetPath(oclib.LibDataEnum(oclib.PEER)) + "/oc",
},
utils.BOOKING.String(): {
tools.GET: oclib.GetPath(oclib.LibDataEnum(oclib.BOOKING)) + "/oc/booking/check/:id/" + o.Ctx.Input.Param(":start_date") + "/" + o.Ctx.Input.Param(":end_date"),
},
})
isAvailable, err := workflow.CheckBooking(caller)
code := 200 code := 200
if !isAvailable { if !isAvailable {
code = 409 code = 409
@ -159,6 +177,10 @@ func (o *WorkflowController) Check() {
"code": code, "code": code,
"error": err, "error": err,
} }
} else {
o.Data["json"] = res
}
} }
o.ServeJSON() o.ServeJSON()
} }

View File

@ -1 +0,0 @@
[]

8
docker_conf.json Normal file
View File

@ -0,0 +1,8 @@
{
"MONGO_URL":"mongodb://mongo:27017/",
"MONGO_DATABASE":"DC_myDC",
"BOOKING_PATH": ":8092",
"NATS_URL": "nats://nats:4222",
"HOSTNAME": "oc-workflow",
"PORT" : 8080
}

View File

@ -1,6 +0,0 @@
{
"MONGO_URL":"mongodb://mongo:27017/",
"MONGO_DATABASE":"DC_myDC",
"BOOKING_PATH": ":8089",
"NATS_URL": "nats://nats:4222"
}

4
go.mod
View File

@ -5,7 +5,7 @@ go 1.22.0
toolchain go1.22.4 toolchain go1.22.4
require ( require (
cloud.o-forge.io/core/oc-lib v0.0.0-20240821093044-f64563c9ff06 cloud.o-forge.io/core/oc-lib v0.0.0-20240826085916-d0e1474f8f34
github.com/beego/beego/v2 v2.2.2 github.com/beego/beego/v2 v2.2.2
github.com/goraz/onion v0.1.3 github.com/goraz/onion v0.1.3
github.com/nats-io/nats.go v1.37.0 github.com/nats-io/nats.go v1.37.0
@ -87,7 +87,7 @@ require (
golang.org/x/arch v0.8.0 // indirect golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.26.0 // indirect golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.19.0 // indirect golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect golang.org/x/sys v0.24.0 // indirect

62
go.sum
View File

@ -174,6 +174,66 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20240821085824-c5f45e03f365 h1:Oh5yP25jvfv1n
cloud.o-forge.io/core/oc-lib v0.0.0-20240821085824-c5f45e03f365/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU= cloud.o-forge.io/core/oc-lib v0.0.0-20240821085824-c5f45e03f365/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240821093044-f64563c9ff06 h1:sYveE1C/0mpSr+ZmOYxuZ3fTWID7mr5hPiq0jQenv3Q= cloud.o-forge.io/core/oc-lib v0.0.0-20240821093044-f64563c9ff06 h1:sYveE1C/0mpSr+ZmOYxuZ3fTWID7mr5hPiq0jQenv3Q=
cloud.o-forge.io/core/oc-lib v0.0.0-20240821093044-f64563c9ff06/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU= cloud.o-forge.io/core/oc-lib v0.0.0-20240821093044-f64563c9ff06/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240821140757-39030a0a80e8 h1:y4hngS1bedPKYXecTCcZk2WkuQNFazD11rMng9dmIzI=
cloud.o-forge.io/core/oc-lib v0.0.0-20240821140757-39030a0a80e8/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240821141151-cf6143887ef2 h1:kO/RodX7gaND3s/zLad9f4yFDmb0vGRzlzP/j8Yqe0c=
cloud.o-forge.io/core/oc-lib v0.0.0-20240821141151-cf6143887ef2/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240821143829-498ec3e9d8b5 h1:xgB9hmFg6kQfk0Hpb/yjdVK6Q3IzDihSPSbQfnOJQEY=
cloud.o-forge.io/core/oc-lib v0.0.0-20240821143829-498ec3e9d8b5/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240821151922-b8b62dc2c8bf h1:s+Ow2r6UPXRbxAEHalPx7+89M3f99Fpl1HMMpMFIcTI=
cloud.o-forge.io/core/oc-lib v0.0.0-20240821151922-b8b62dc2c8bf/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822065024-fb80e05d6a7b h1:A7NBwTXoHTg/oDbnxnnSdiT85kZY4VvhcbUeb3q7Irk=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822065024-fb80e05d6a7b/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822081914-4abf59a10d97 h1:6tbeTQvRnD0vDUl+5SLMgAh9ukjGxQ9WKjNcvvxN7cQ=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822081914-4abf59a10d97/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822083903-bfa176a7c5ce h1:nJqBNioYDdki6O6N8m6AKChbBjpzcSwt1ixvpkIg+so=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822083903-bfa176a7c5ce/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822095923-d766e3a7c34f h1:Zvz2KtaU2NRf5PeHpis3Qrt2cRuoDaGPCrxuKq7rs9Y=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822095923-d766e3a7c34f/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822102938-1d3620845d08 h1:pyiba9+2PUPzia21HK9dXWodG8lg0kRI4ujsfypjS50=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822102938-1d3620845d08/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822103656-ce343459148b h1:yg+FCQ4onXSHwTGie+A+16f1YyZxJzO5unvZZ9jRi3I=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822103656-ce343459148b/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822112243-e69e13d8daf8 h1:35Hrl4lwqUom5Rbfi9wLRg2yMou3bTeL2ZAaDY0N79Y=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822112243-e69e13d8daf8/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822122949-9c0107e87c71 h1:9ACkwlAOi4DVh4xeE4TtOG8evqRmGI0K55LgPrKoGpA=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822122949-9c0107e87c71/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822125632-c8a137785133 h1:PWixdgAdoIvPQgywHhLIi68BxKP7vQPMekMC0l63o2c=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822125632-c8a137785133/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822131859-a42b6198cb8e h1:UwGalgCxXLbMadhyMe4/qfl6sJ6TkEA3cAP2vsSl6wo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822131859-a42b6198cb8e/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822133827-d89826db44e0 h1:vy7/XwyvRv0ZjSjnwh1fs4xLB25pL2MsWaM1wL5ZH0c=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822133827-d89826db44e0/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822141307-d9b26e3fce6e h1:sBdqakykLKOE4Zb2Qg5++rtE3OnXgSSekuz4Qkmm65E=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822141307-d9b26e3fce6e/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822142821-3232cce1b4b6 h1:WOrh9TVPEXxYRWjA0wF3tqo0poboSLAChHat95w6O6U=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822142821-3232cce1b4b6/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822145413-fd2ad33f61db h1:RACtdyHFEDOkWgXsp7LtmRpUWGXIDAbikb0uEVdnIlg=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822145413-fd2ad33f61db/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822150931-37b7ed8d83fe h1:76XfxprM3O40tn1EgF6/iR0ZLagfKe5vEt9czStyQEQ=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822150931-37b7ed8d83fe/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823062324-2ad4c0bb911b h1:Fr0ORjIbXBsjM5IyvM0F7Oq/rAyV2ANQFr6ZvzKEZm4=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823062324-2ad4c0bb911b/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823082553-98fa1f6ca807 h1:BqqCAnV2pbrX09IoE3EaVgrKIJPTvzqPeMnt2nYhCs4=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823082553-98fa1f6ca807/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823091301-5b3779e4cb21 h1:OzsSJVL2jaLewUWfW4C30SVrY4y20+mxI3rbOGLCPyo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823091301-5b3779e4cb21/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823134312-1986143dd0db h1:yqXbsLcBgSbTzg12TKfb+vpgEQ8zETHigvWKNs0TgC8=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823134312-1986143dd0db/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823153529-fd730741a424 h1:QNyxS3NfwqbsPgpq4qN5FqF92GZksXQVOuoxhtVW8EU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823153529-fd730741a424/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823161829-dd3570fa3736 h1:LPMkli9xpgNBYKb0DWU6agkvxQlunnMcV93ErkyDNrU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823161829-dd3570fa3736/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823201703-762cc19c1437 h1:kUo8fL+XVaPsL8oLUSbbGDFwr3pT8TvYbPbr6+Ub53E=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823201703-762cc19c1437/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823210057-8e80fa88beeb h1:7/GQRm485qUHpuJnW1QayD0jk4RTmf5PAOqM0xBwM7E=
cloud.o-forge.io/core/oc-lib v0.0.0-20240823210057-8e80fa88beeb/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240826074207-144e7f85062d h1:4x29d4HwFmrjRaAJhF+TBSinQwSDh5vNAzEFK+4p4t8=
cloud.o-forge.io/core/oc-lib v0.0.0-20240826074207-144e7f85062d/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240826082633-7c44365f527c h1:qo27sWEWWPeVyeShE+fUkAL6Ia0ToYj2aUbrP8MHhWo=
cloud.o-forge.io/core/oc-lib v0.0.0-20240826082633-7c44365f527c/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240826085916-d0e1474f8f34 h1:40XQgwR9HxXSnouY+ZqE/xYCM4qa+U+RLA5GA5JSNyQ=
cloud.o-forge.io/core/oc-lib v0.0.0-20240826085916-d0e1474f8f34/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= 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 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
@ -643,6 +703,8 @@ golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

22
main.go
View File

@ -1,15 +1,19 @@
package main package main
import ( import (
"fmt"
_ "oc-workflow/routers" _ "oc-workflow/routers"
"os"
oclib "cloud.o-forge.io/core/oc-lib" oclib "cloud.o-forge.io/core/oc-lib"
"cloud.o-forge.io/core/oc-lib/tools" "cloud.o-forge.io/core/oc-lib/tools"
beego "github.com/beego/beego/v2/server/web" beego "github.com/beego/beego/v2/server/web"
"github.com/goraz/onion" "github.com/goraz/onion"
"golang.org/x/mod/modfile"
) )
const defaultConfigFile = "/etc/oc/workflow.json" const hostname = "oc-workflow"
const defaultConfigFile = "/etc/oc/conf.json"
func main() { func main() {
configFile := "" configFile := ""
@ -29,8 +33,10 @@ func main() {
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"), o.GetStringDefault("MONGO_DATABASE", "DC_myDC"),
o.GetStringDefault("NATS_URL", "nats://localhost:4222"), o.GetStringDefault("NATS_URL", "nats://localhost:4222"),
) )
oclib.Init("oc-workflow") fmt.Println("Config file:", o.GetStringDefault("HOSTNAME", "localhost"))
oclib.Init(hostname, o.GetStringDefault("HOSTNAME", "localhost"), o.GetStringDefault("PORT", "8088"))
oclib.AddPath(oclib.LibDataEnum(oclib.BOOKING), o.GetStringDefault("BOOKING_URL", ":8092")) oclib.AddPath(oclib.LibDataEnum(oclib.BOOKING), o.GetStringDefault("BOOKING_URL", ":8092"))
oclib.AddPath(oclib.LibDataEnum(oclib.PEER), o.GetStringDefault("PEER_URL", ":8093"))
// Normal beego init // Normal beego init
//if beego.BConfig.RunMode == "dev" { //if beego.BConfig.RunMode == "dev" {
beego.BConfig.WebConfig.DirectoryIndex = true beego.BConfig.WebConfig.DirectoryIndex = true
@ -38,3 +44,15 @@ func main() {
//} //}
beego.Run() beego.Run()
} }
func GetModuleName() string {
goModBytes, err := os.ReadFile("go.mod")
if err != nil {
return "prrr"
}
modName := modfile.ModulePath(goModBytes)
fmt.Fprintf(os.Stdout, "modName=%+v\n", modName)
return modName
}

Binary file not shown.

View File

@ -73,7 +73,7 @@ func init() {
beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowController"], beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowController"] = append(beego.GlobalControllerRouter["oc-workflow/controllers:WorkflowController"],
beego.ControllerComments{ beego.ControllerComments{
Method: "Check", Method: "Check",
Router: `/check/:start_date/:end_date`, Router: `/check/:id/:start_date/:end_date`,
AllowHTTPMethods: []string{"get"}, AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(), MethodParams: param.Make(),
Filters: nil, Filters: nil,

View File

@ -83,7 +83,7 @@
} }
} }
}, },
"/workflow/check/{start_date}/{end_date}": { "/workflow/check/{id}/{start_date}/{end_date}": {
"get": { "get": {
"tags": [ "tags": [
"workflow" "workflow"
@ -91,12 +91,17 @@
"description": "check booking\n\u003cbr\u003e", "description": "check booking\n\u003cbr\u003e",
"operationId": "WorkflowController.Check", "operationId": "WorkflowController.Check",
"parameters": [ "parameters": [
{
"in": "path",
"name": "id",
"description": "the booking workflow id",
"type": "string"
},
{ {
"in": "path", "in": "path",
"name": "start_date", "name": "start_date",
"description": "2006-01-02T15:04:05", "description": "the booking start date format 2006-01-02T15:04:05",
"type": "string", "type": "string"
"default": "the booking start date"
}, },
{ {
"in": "path", "in": "path",

View File

@ -121,7 +121,7 @@ paths:
responses: responses:
"200": "200":
description: '{string} delete success!' description: '{string} delete success!'
/workflow/check/{start_date}/{end_date}: /workflow/check/{id}/{start_date}/{end_date}:
get: get:
tags: tags:
- workflow - workflow
@ -131,10 +131,13 @@ paths:
operationId: WorkflowController.Check operationId: WorkflowController.Check
parameters: parameters:
- in: path - in: path
name: start_date name: id
description: 2006-01-02T15:04:05 description: the booking workflow id
type: string
- in: path
name: start_date
description: the booking start date format 2006-01-02T15:04:05
type: string type: string
default: the booking start date
- in: path - in: path
name: end_date name: end_date
description: 2006-01-02T15:04:05 description: 2006-01-02T15:04:05