Merge branch 'dev' of github.com:dikstub-rssa/simrs-be into feat/file-generator-169
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package division
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/division"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/division"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CreateLog(w http.ResponseWriter, r *http.Request) {
|
||||
dto := esync.SimxLogDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.CreateSimxLog(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.UpdateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
val := uint16(id)
|
||||
dto.Id = &val
|
||||
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
val := uint16(id)
|
||||
dto.Id = &val
|
||||
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package simgossynchandler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
hc "simrs-vx/pkg/handler-crud-helper"
|
||||
|
||||
/******************** infra ********************/
|
||||
gs "simrs-vx/internal/infra/gorm-setting"
|
||||
@@ -14,11 +15,13 @@ import (
|
||||
|
||||
/******************** external ********************/
|
||||
a "github.com/karincake/apem"
|
||||
hk "github.com/karincake/hongkue"
|
||||
|
||||
/******************** internal ********************/
|
||||
"simrs-vx/internal/interface/main-handler/home"
|
||||
division "simrs-vx/internal/interface/simgos-sync-handler/division"
|
||||
installation "simrs-vx/internal/interface/simgos-sync-handler/installation"
|
||||
specialist "simrs-vx/internal/interface/simgos-sync-handler/specialist"
|
||||
subspecialist "simrs-vx/internal/interface/simgos-sync-handler/subspecialist"
|
||||
unit "simrs-vx/internal/interface/simgos-sync-handler/unit"
|
||||
)
|
||||
|
||||
func SetRoutes() http.Handler {
|
||||
@@ -35,12 +38,11 @@ func SetRoutes() http.Handler {
|
||||
|
||||
/******************** Source ******************/
|
||||
prefix := "/new-to-old"
|
||||
hk.GroupRoutes(prefix+"/v1/installation", r, hk.MapHandlerFunc{
|
||||
"POST /": installation.O.Create,
|
||||
"POST /log": installation.O.CreateLog,
|
||||
"PATCH /{id}": installation.O.Update,
|
||||
"DELETE /{id}": installation.O.Delete,
|
||||
})
|
||||
hc.SyncCrud(r, prefix+"/v1/installation", installation.O)
|
||||
hc.SyncCrud(r, prefix+"/v1/unit", unit.O)
|
||||
hc.SyncCrud(r, prefix+"/v1/division", division.O)
|
||||
hc.SyncCrud(r, prefix+"/v1/specialist", specialist.O)
|
||||
hc.SyncCrud(r, prefix+"/v1/subspecialist", subspecialist.O)
|
||||
|
||||
return cmw.SetCors(handlerlogger.SetLog(r))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package specialist
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/specialist"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/specialist"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CreateLog(w http.ResponseWriter, r *http.Request) {
|
||||
dto := esync.SimxLogDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.CreateSimxLog(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.UpdateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
val := uint16(id)
|
||||
dto.Id = &val
|
||||
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
val := uint16(id)
|
||||
dto.Id = &val
|
||||
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package subspecialist
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/subspecialist"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/subspecialist"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CreateLog(w http.ResponseWriter, r *http.Request) {
|
||||
dto := esync.SimxLogDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.CreateSimxLog(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.UpdateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
val := uint16(id)
|
||||
dto.Id = &val
|
||||
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
val := uint16(id)
|
||||
dto.Id = &val
|
||||
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/unit"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/unit"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CreateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CreateLog(w http.ResponseWriter, r *http.Request) {
|
||||
dto := esync.SimxLogDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
res, err := u.CreateSimxLog(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.UpdateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
val := uint16(id)
|
||||
dto.Id = &val
|
||||
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
val := uint16(id)
|
||||
dto.Id = &val
|
||||
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
Reference in New Issue
Block a user