add installation
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/installation"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/installation"
|
||||
)
|
||||
|
||||
@@ -23,29 +24,38 @@ func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
code := rw.ValidateString(w, "code", r.PathValue("code"))
|
||||
if code == "" {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.UpdateDto{}
|
||||
func (obj myBase) CreateLog(w http.ResponseWriter, r *http.Request) {
|
||||
dto := esync.SimxLogDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.Code = &code
|
||||
res, err := u.Update(dto)
|
||||
res, err := u.CreateSimxLog(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
//code := rw.ValidateString(w, "code", r.PathValue("code"))
|
||||
//if code == "" {
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//dto := e.UpdateDto{}
|
||||
//if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
// return
|
||||
//}
|
||||
//dto.Code = &code
|
||||
//res, err := u.Update(dto)
|
||||
//rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
code := rw.ValidateString(w, "code", r.PathValue("code"))
|
||||
if code == "" {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
dto.Code = &code
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
//code := rw.ValidateString(w, "code", r.PathValue("code"))
|
||||
//if code == "" {
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//dto := e.DeleteDto{}
|
||||
//dto.Code = &code
|
||||
//res, err := u.Delete(dto)
|
||||
//rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@ package simgossynchandler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
/******************** infra ********************/
|
||||
gs "simrs-vx/internal/infra/gorm-setting"
|
||||
simgosdb "simrs-vx/internal/infra/simgos-db"
|
||||
simgossync "simrs-vx/internal/infra/sync-cfg"
|
||||
|
||||
/******************** pkg ********************/
|
||||
cmw "simrs-vx/pkg/cors-manager-mw"
|
||||
@@ -25,6 +28,8 @@ func SetRoutes() http.Handler {
|
||||
a.RegisterExtCall(gs.Adjust)
|
||||
a.RegisterExtCall(zlc.Adjust)
|
||||
a.RegisterExtCall(lh.Populate)
|
||||
a.RegisterExtCall(simgossync.SetConfig)
|
||||
a.RegisterExtCall(simgosdb.SetInstance)
|
||||
|
||||
r := http.NewServeMux()
|
||||
|
||||
@@ -32,8 +37,9 @@ func SetRoutes() http.Handler {
|
||||
r.HandleFunc("/", home.Home)
|
||||
|
||||
/******************** Source ******************/
|
||||
hk.GroupRoutes("/v1/installation", r, hk.MapHandlerFunc{
|
||||
hk.GroupRoutes("/new-to-old/v1/installation", r, hk.MapHandlerFunc{
|
||||
"POST /": installation.O.Create,
|
||||
"POST /log": installation.O.CreateLog,
|
||||
"PATCH /{id}": installation.O.Update,
|
||||
"DELETE /{id}": installation.O.Delete,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user