on going installation
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
|||||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||||
|
|
||||||
e "simrs-vx/internal/domain/main-entities/installation"
|
e "simrs-vx/internal/domain/main-entities/installation"
|
||||||
u "simrs-vx/internal/use-case/main-use-case/installation"
|
u "simrs-vx/internal/use-case/simgos-sync-use-case/installation"
|
||||||
)
|
)
|
||||||
|
|
||||||
type myBase struct{}
|
type myBase struct{}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package simgossynchandler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
hc "simrs-vx/pkg/handler-crud-helper"
|
|
||||||
|
|
||||||
/******************** infra ********************/
|
/******************** infra ********************/
|
||||||
gs "simrs-vx/internal/infra/gorm-setting"
|
gs "simrs-vx/internal/infra/gorm-setting"
|
||||||
|
|
||||||
@@ -15,11 +13,10 @@ import (
|
|||||||
|
|
||||||
/******************** external ********************/
|
/******************** external ********************/
|
||||||
a "github.com/karincake/apem"
|
a "github.com/karincake/apem"
|
||||||
|
hk "github.com/karincake/hongkue"
|
||||||
|
|
||||||
/******************** internal ********************/
|
/******************** internal ********************/
|
||||||
"simrs-vx/internal/interface/main-handler/home"
|
"simrs-vx/internal/interface/main-handler/home"
|
||||||
|
|
||||||
/********************* source *********************/
|
|
||||||
installation "simrs-vx/internal/interface/simgos-sync-handler/installation"
|
installation "simrs-vx/internal/interface/simgos-sync-handler/installation"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,7 +32,11 @@ func SetRoutes() http.Handler {
|
|||||||
r.HandleFunc("/", home.Home)
|
r.HandleFunc("/", home.Home)
|
||||||
|
|
||||||
/******************** Source ******************/
|
/******************** Source ******************/
|
||||||
hc.RegCrudByCode(r, "/v1/installation", installation.O)
|
hk.GroupRoutes("/v1/installation", r, hk.MapHandlerFunc{
|
||||||
|
"POST /": installation.O.Create,
|
||||||
|
"PATCH /{id}": installation.O.Update,
|
||||||
|
"DELETE /{id}": installation.O.Delete,
|
||||||
|
})
|
||||||
|
|
||||||
return cmw.SetCors(handlerlogger.SetLog(r))
|
return cmw.SetCors(handlerlogger.SetLog(r))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package installation
|
package installation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
e "simrs-vx/internal/domain/main-entities/installation"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
dg "github.com/karincake/apem/db-gorm-pg"
|
dg "github.com/karincake/apem/db-gorm-pg"
|
||||||
@@ -11,6 +10,8 @@ import (
|
|||||||
pu "simrs-vx/pkg/use-case-helper"
|
pu "simrs-vx/pkg/use-case-helper"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
|
e "simrs-vx/internal/domain/main-entities/installation"
|
||||||
)
|
)
|
||||||
|
|
||||||
const source = "installation"
|
const source = "installation"
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ func Create(input e.CreateDto) (*d.Data, error) {
|
|||||||
pl.SetLogInfo(&event, input, "started", "create")
|
pl.SetLogInfo(&event, input, "started", "create")
|
||||||
|
|
||||||
err := dg.I.Transaction(func(tx *gorm.DB) error {
|
err := dg.I.Transaction(func(tx *gorm.DB) error {
|
||||||
|
// TODO: Insert
|
||||||
|
|
||||||
|
// TODO: InsertSimxLog
|
||||||
|
|
||||||
if resData, err := CreateData(input, &event, tx); err != nil {
|
if resData, err := CreateData(input, &event, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ package installation
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
e "simrs-vx/internal/domain/main-entities/installation"
|
e "simrs-vx/internal/domain/main-entities/installation"
|
||||||
|
esimgos "simrs-vx/internal/domain/simgos-entities/installation"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Installation) {
|
func setDataSimgos[T *e.CreateDto | *e.UpdateDto](input T, data *esimgos.MInstalasi) {
|
||||||
var inputSrc *e.CreateDto
|
var inputSrc *e.CreateDto
|
||||||
if inputT, ok := any(input).(*e.CreateDto); ok {
|
if inputT, ok := any(input).(*e.CreateDto); ok {
|
||||||
inputSrc = inputT
|
inputSrc = inputT
|
||||||
@@ -17,6 +18,8 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Installation) {
|
|||||||
inputSrc = &inputTemp.CreateDto
|
inputSrc = &inputTemp.CreateDto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.NamaInstalasi = inputSrc.Name
|
||||||
|
data.StatusRawatInap = 1
|
||||||
data.Code = *inputSrc.Code
|
data.Code = *inputSrc.Code
|
||||||
data.Name = inputSrc.Name
|
data.Name = inputSrc.Name
|
||||||
data.EncounterClass_Code = inputSrc.EncounterClass_Code
|
data.EncounterClass_Code = inputSrc.EncounterClass_Code
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package installation
|
package installation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
e "simrs-vx/internal/domain/main-entities/installation"
|
|
||||||
|
|
||||||
plh "simrs-vx/pkg/lib-helper"
|
plh "simrs-vx/pkg/lib-helper"
|
||||||
pl "simrs-vx/pkg/logger"
|
pl "simrs-vx/pkg/logger"
|
||||||
pu "simrs-vx/pkg/use-case-helper"
|
pu "simrs-vx/pkg/use-case-helper"
|
||||||
@@ -10,12 +8,15 @@ import (
|
|||||||
dg "github.com/karincake/apem/db-gorm-pg"
|
dg "github.com/karincake/apem/db-gorm-pg"
|
||||||
gh "github.com/karincake/getuk"
|
gh "github.com/karincake/getuk"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
|
e "simrs-vx/internal/domain/main-entities/installation"
|
||||||
|
esimgos "simrs-vx/internal/domain/simgos-entities/installation"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*e.Installation, error) {
|
func CreateSimgosData(input e.CreateDto, event *pl.Event, dbx ...*gorm.DB) (*esimgos.MInstalasi, error) {
|
||||||
pl.SetLogInfo(event, nil, "started", "DBCreate")
|
pl.SetLogInfo(event, nil, "started", "DBCreate")
|
||||||
|
|
||||||
data := e.Installation{}
|
data := esimgos.MInstalasi{}
|
||||||
setData(&input, &data)
|
setData(&input, &data)
|
||||||
|
|
||||||
var tx *gorm.DB
|
var tx *gorm.DB
|
||||||
|
|||||||
@@ -74,67 +74,3 @@ func RegCrudByCode(r *http.ServeMux, path string, mwAndRouter ...any) {
|
|||||||
"DELETE /{code}": c.Delete,
|
"DELETE /{code}": c.Delete,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegCrudSimgosSync(r *http.ServeMux, path string, mwAndRouter ...any) {
|
|
||||||
sLength := len(mwAndRouter)
|
|
||||||
|
|
||||||
mwCandidates := mwAndRouter[:sLength-1]
|
|
||||||
mwList := []hk.HandlerMw{}
|
|
||||||
for i := range mwCandidates {
|
|
||||||
// have to do it manually, since casting directly results unexpected result
|
|
||||||
myType := reflect.TypeOf(mwCandidates[i])
|
|
||||||
if myType.String() != "func(http.Handler) http.Handler" {
|
|
||||||
panic("non middleware included as middleware")
|
|
||||||
}
|
|
||||||
mwList = append(mwList, mwCandidates[i].(func(http.Handler) http.Handler))
|
|
||||||
|
|
||||||
// if g, okHandler := mwCandidates[i].(func(http.Handler) http.Handler); !okHandler {
|
|
||||||
// panic("non middleware included")
|
|
||||||
// } else {
|
|
||||||
// mwList = append(mwList, g)
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
c, ok := mwAndRouter[sLength-1].(CrudBase)
|
|
||||||
if !ok {
|
|
||||||
panic("non CrudBase used in the last paramter")
|
|
||||||
}
|
|
||||||
|
|
||||||
hk.GroupRoutes(path, r, mwList, hk.MapHandlerFunc{
|
|
||||||
"POST /": c.Create,
|
|
||||||
"PATCH /{id}": c.Update,
|
|
||||||
"DELETE /{id}": c.Delete,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegCrudByCodeSimgosSync(r *http.ServeMux, path string, mwAndRouter ...any) {
|
|
||||||
sLength := len(mwAndRouter)
|
|
||||||
|
|
||||||
mwCandidates := mwAndRouter[:sLength-1]
|
|
||||||
mwList := []hk.HandlerMw{}
|
|
||||||
for i := range mwCandidates {
|
|
||||||
// have to do it manually, since casting directly results unexpected result
|
|
||||||
myType := reflect.TypeOf(mwCandidates[i])
|
|
||||||
if myType.String() != "func(http.Handler) http.Handler" {
|
|
||||||
panic("non middleware included as middleware")
|
|
||||||
}
|
|
||||||
mwList = append(mwList, mwCandidates[i].(func(http.Handler) http.Handler))
|
|
||||||
|
|
||||||
// if g, okHandler := mwCandidates[i].(func(http.Handler) http.Handler); !okHandler {
|
|
||||||
// panic("non middleware included")
|
|
||||||
// } else {
|
|
||||||
// mwList = append(mwList, g)
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
c, ok := mwAndRouter[sLength-1].(CrudBase)
|
|
||||||
if !ok {
|
|
||||||
panic("non CrudBase used in the last paramter")
|
|
||||||
}
|
|
||||||
|
|
||||||
hk.GroupRoutes(path, r, mwList, hk.MapHandlerFunc{
|
|
||||||
"POST /": c.Create,
|
|
||||||
"PATCH /{code}": c.Update,
|
|
||||||
"DELETE /{code}": c.Delete,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user