Merge branch 'feat/sync-setting' into feat/sync-from-simgos-161
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package mcusrccategory
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
sf "github.com/karincake/semprit"
|
||||
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/mcu-src-category"
|
||||
u "simrs-vx/internal/use-case/main-use-case/mcu-src-category"
|
||||
)
|
||||
|
||||
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) GetList(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
intId := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if intId <= 0 {
|
||||
return
|
||||
}
|
||||
id := uint16(intId)
|
||||
dto := e.ReadDetailDto{}
|
||||
dto.Id = &id
|
||||
res, err := u.ReadDetail(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
intId := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if intId <= 0 {
|
||||
return
|
||||
}
|
||||
id := uint16(intId)
|
||||
|
||||
dto := e.UpdateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
dto.Id = &id
|
||||
res, err := u.Update(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
intId := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if intId <= 0 {
|
||||
return
|
||||
}
|
||||
id := uint16(intId)
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
dto.Id = &id
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package antibioticsrc
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
sf "github.com/karincake/semprit"
|
||||
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/antibiotic-src"
|
||||
u "simrs-vx/internal/use-case/main-use-case/antibiotic-src"
|
||||
)
|
||||
|
||||
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) GetList(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.ReadListDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
res, err := u.ReadList(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
dto.Id = uint16(id)
|
||||
res, err := u.ReadDetail(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
|
||||
}
|
||||
dto.Id = uint16(id)
|
||||
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{}
|
||||
dto.Id = uint16(id)
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
@@ -13,6 +13,8 @@ import (
|
||||
mf "simrs-vx/internal/domain/main-entities/user-fes"
|
||||
pa "simrs-vx/internal/lib/auth"
|
||||
s "simrs-vx/internal/use-case/main-use-case/authentication"
|
||||
|
||||
esga "simrs-vx/internal/domain/sync-entities/authentication"
|
||||
)
|
||||
|
||||
func Login(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -67,6 +69,24 @@ func Logout(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func GuardMW(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// Check if it's from sync
|
||||
credential := esga.CredentialDto{}
|
||||
credential.Source = r.Header.Get("X-Sync-Source")
|
||||
credential.SecretKey = r.Header.Get("X-Sync-SecretKey")
|
||||
credential.UserName = r.Header.Get("X-Sync-UserName")
|
||||
if credential.Source != "" || credential.SecretKey != "" || credential.UserName != "" {
|
||||
// TODO: ngecall fungsi untuk dapat dari DB menlengkapi authinfo
|
||||
accessDetail, err := s.GetAuthInfoByUserName(credential.UserName)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, err.(d.FieldError), nil)
|
||||
return
|
||||
}
|
||||
ctx := context.WithValue(r.Context(), pa.AuthKey{}, accessDetail)
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
return
|
||||
}
|
||||
|
||||
// Normal flow goes here
|
||||
accessDetail, err := s.ExtractToken(r, s.AccessToken)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, err.(d.FieldError), nil)
|
||||
|
||||
@@ -70,6 +70,11 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
@@ -80,29 +85,39 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
dto.Id = uint16(id)
|
||||
dto.AuthInfo = *authInfo
|
||||
|
||||
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
|
||||
}
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.DeleteDto{}
|
||||
dto.Id = uint16(id)
|
||||
dto.AuthInfo = *authInfo
|
||||
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CheckOut(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.DischargeDto{}
|
||||
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
@@ -118,12 +133,20 @@ func (obj myBase) CheckOut(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
dto.Id = uint(id)
|
||||
dto.AuthInfo = *authInfo
|
||||
|
||||
res, err := u.CheckOut(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) CheckIn(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.CheckinDto{}
|
||||
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
@@ -139,6 +162,8 @@ func (obj myBase) CheckIn(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
dto.Id = uint(id)
|
||||
dto.AuthInfo = *authInfo
|
||||
|
||||
res, err := u.CheckIn(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ import (
|
||||
gs "simrs-vx/internal/infra/gorm-setting"
|
||||
minio "simrs-vx/internal/infra/minio"
|
||||
ssdb "simrs-vx/internal/infra/ss-db"
|
||||
simgossync "simrs-vx/internal/infra/sync-cfg"
|
||||
sync "simrs-vx/internal/infra/sync-consumer-cfg"
|
||||
|
||||
/******************** pkg ********************/
|
||||
cmw "simrs-vx/pkg/cors-manager-mw"
|
||||
@@ -74,6 +74,8 @@ import (
|
||||
zlc "simrs-vx/pkg/zerolog-ctx"
|
||||
|
||||
/******************** sources ********************/
|
||||
antibioticsrc "simrs-vx/internal/interface/main-handler/antibiotic-src"
|
||||
antibioticsrccat "simrs-vx/internal/interface/main-handler/antibiotic-src-category"
|
||||
device "simrs-vx/internal/interface/main-handler/device"
|
||||
diagnosesrc "simrs-vx/internal/interface/main-handler/diagnose-src"
|
||||
division "simrs-vx/internal/interface/main-handler/division"
|
||||
@@ -133,7 +135,7 @@ func SetRoutes() http.Handler {
|
||||
a.RegisterExtCall(mh.I.SetClient)
|
||||
a.RegisterExtCall(ibpjs.SetConfig)
|
||||
a.RegisterExtCall(validation.RegisterValidation)
|
||||
a.RegisterExtCall(simgossync.SetConfig)
|
||||
a.RegisterExtCall(sync.SetConfig)
|
||||
a.RegisterExtCall(docscfg.ParseCfg)
|
||||
|
||||
r := http.NewServeMux()
|
||||
@@ -150,11 +152,14 @@ func SetRoutes() http.Handler {
|
||||
hc.RegCrudByCode(r, "/v1/medicine-form", medicineform.O)
|
||||
hc.RegCrud(r, "/v1/medicine-mix", medicicinemix.O)
|
||||
hc.RegCrud(r, "/v1/medicine-mix-item", medicicinemixitem.O)
|
||||
hc.RegCrud(r, "/v1/antibiotic-src-category", antibioticsrccat.O)
|
||||
hc.RegCrud(r, "/v1/antibiotic-src", antibioticsrc.O)
|
||||
hc.RegCrud(r, "/v1/soapi", auth.GuardMW, soapi.O)
|
||||
hc.RegCrud(r, "/v1/adime", auth.GuardMW, adime.O)
|
||||
hc.RegCrud(r, "/v1/sbar", auth.GuardMW, sbar.O)
|
||||
hc.RegCrud(r, "/v1/prescription-item", prescriptionitem.O)
|
||||
hc.RegCrud(r, "/v1/device-order-item", deviceorderitem.O)
|
||||
|
||||
hc.RegCrud(r, "/v1/material-order-item", materialorderitem.O)
|
||||
hk.GroupRoutes("/v1/encounter", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": encounter.O.GetList,
|
||||
@@ -177,6 +182,7 @@ func SetRoutes() http.Handler {
|
||||
"POST /": mcuorder.O.Create,
|
||||
"PATCH /{id}": mcuorder.O.Update,
|
||||
"DELETE /{id}": mcuorder.O.Delete,
|
||||
"PATCH /{id}/submit": mcuorder.O.Submit,
|
||||
"PATCH /{id}/complete": mcuorder.O.Complete,
|
||||
"PATCH /{id}/set-schedule": mcuorder.O.SetSchedule,
|
||||
})
|
||||
@@ -303,7 +309,7 @@ func SetRoutes() http.Handler {
|
||||
"PATCH /{id}/active": user.O.Active,
|
||||
})
|
||||
hc.RegCrud(r, "/v1/user-fes", userfes.O)
|
||||
hk.GroupRoutes("/v1/patient", r, hk.MapHandlerFunc{
|
||||
hk.GroupRoutes("/v1/patient", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": patient.O.GetList,
|
||||
"GET /{id}": patient.O.GetDetail,
|
||||
"POST /": patient.O.Create,
|
||||
|
||||
@@ -85,6 +85,18 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Submit(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
dto := e.ReadDetailDto{}
|
||||
dto.Id = uint(id)
|
||||
res, err := u.Submit(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Complete(w http.ResponseWriter, r *http.Request) {
|
||||
id := rw.ValidateInt(w, "id", r.PathValue("id"))
|
||||
if id <= 0 {
|
||||
|
||||
@@ -2,6 +2,7 @@ package patient
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
pa "simrs-vx/internal/lib/auth"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
sf "github.com/karincake/semprit"
|
||||
@@ -19,10 +20,17 @@ type myBase struct{}
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
authInfo, err := pa.GetAuthInfo(r)
|
||||
if err != nil {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": err.Error()}, nil)
|
||||
}
|
||||
|
||||
dto := e.CreateDto{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
dto.AuthInfo = *authInfo
|
||||
res, err := u.Create(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ import (
|
||||
regency "simrs-vx/internal/domain/main-entities/regency"
|
||||
rehab "simrs-vx/internal/domain/main-entities/rehab"
|
||||
responsibledoctorhist "simrs-vx/internal/domain/main-entities/responsible-doctor-hist"
|
||||
resume "simrs-vx/internal/domain/main-entities/resume"
|
||||
room "simrs-vx/internal/domain/main-entities/room"
|
||||
sbar "simrs-vx/internal/domain/main-entities/sbar"
|
||||
soapi "simrs-vx/internal/domain/main-entities/soapi"
|
||||
@@ -102,6 +103,7 @@ import (
|
||||
|
||||
///BPJS
|
||||
vclaimmember "simrs-vx/internal/domain/bpjs-entities/vclaim-member"
|
||||
vclaimreference "simrs-vx/internal/domain/bpjs-entities/vclaim-reference"
|
||||
vclaimsep "simrs-vx/internal/domain/bpjs-entities/vclaim-sep"
|
||||
vclaimsepcontrolletter "simrs-vx/internal/domain/bpjs-entities/vclaim-sep-control-letter"
|
||||
vclaimsephist "simrs-vx/internal/domain/bpjs-entities/vclaim-sep-hist"
|
||||
@@ -213,5 +215,7 @@ func getMainEntities() []any {
|
||||
&chemoprotocol.ChemoProtocol{},
|
||||
&fileattachemnt.EncounterDocument{},
|
||||
&vclaimsepcontrolletter.VclaimSepControlLetter{},
|
||||
&resume.Resume{},
|
||||
&vclaimreference.VclaimReference{},
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -8,7 +8,8 @@ import (
|
||||
|
||||
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"
|
||||
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/new/division"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
@@ -0,0 +1,88 @@
|
||||
package encounter
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
rw "github.com/karincake/risoles"
|
||||
// ua "github.com/karincake/tumpeng/auth/svc"
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/encounter"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/new/encounter"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
|
||||
var O myBase
|
||||
|
||||
func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.Encounter{}
|
||||
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) {
|
||||
dto := e.Encounter{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
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{}
|
||||
dto.Id = uint16(id)
|
||||
|
||||
res, err := u.Delete(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Checkin(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.Encounter{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
res, err := u.CheckIn(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Checkout(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.Encounter{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
res, err := u.CheckOut(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) Cancel(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.Encounter{}
|
||||
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
|
||||
return
|
||||
}
|
||||
|
||||
res, err := u.Cancel(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
+2
-1
@@ -8,7 +8,8 @@ import (
|
||||
|
||||
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"
|
||||
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/new/installation"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
+2
-1
@@ -8,7 +8,8 @@ import (
|
||||
|
||||
e "simrs-vx/internal/domain/main-entities/patient"
|
||||
esync "simrs-vx/internal/domain/sync-entities/log"
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/patient"
|
||||
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/new/patient"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
+2
-1
@@ -8,7 +8,8 @@ import (
|
||||
|
||||
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"
|
||||
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/new/specialist"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
+1
-1
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
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"
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/new/subspecialist"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
+2
-1
@@ -8,7 +8,8 @@ import (
|
||||
|
||||
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"
|
||||
|
||||
u "simrs-vx/internal/use-case/simgos-sync-use-case/new/unit"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
@@ -0,0 +1,52 @@
|
||||
package authentication
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
rw "github.com/karincake/risoles"
|
||||
|
||||
sc "simrs-vx/internal/lib/sync-credential"
|
||||
|
||||
e "simrs-vx/internal/domain/sync-entities/authentication"
|
||||
is "simrs-vx/internal/infra/sync-cfg"
|
||||
)
|
||||
|
||||
func NewGuardMW(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// check the data format
|
||||
input := e.CredentialDto{}
|
||||
if success := sc.CheckCredentialData(&input, r, w); !success {
|
||||
return
|
||||
}
|
||||
|
||||
// check the validity
|
||||
if input.Source != is.O.NewSource || input.SecretKey != is.O.NewSecretKey {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "invalid consumer credential"}, nil)
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.WithValue(r.Context(), e.SyncKey{}, input)
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
})
|
||||
}
|
||||
|
||||
func OldGuardMW(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// check the data format
|
||||
input := e.CredentialDto{}
|
||||
if success := sc.CheckCredentialData(&input, r, w); !success {
|
||||
return
|
||||
}
|
||||
|
||||
// check the validity
|
||||
if input.Source != is.O.OldSource || input.SecretKey != is.O.OldSecretKey {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "invalid consumer credential"}, nil)
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.WithValue(r.Context(), e.SyncKey{}, input)
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
})
|
||||
}
|
||||
@@ -1,31 +1,35 @@
|
||||
package simgossynchandler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
hc "simrs-vx/pkg/handler-crud-helper"
|
||||
|
||||
/******************** infra ********************/
|
||||
gs "simrs-vx/internal/infra/gorm-setting"
|
||||
simgosdb "simrs-vx/internal/infra/simgos-db"
|
||||
sync "simrs-vx/internal/infra/sync-consumer-cfg"
|
||||
|
||||
/******************** pkg ********************/
|
||||
cmw "simrs-vx/pkg/cors-manager-mw"
|
||||
hc "simrs-vx/pkg/handler-crud-helper"
|
||||
lh "simrs-vx/pkg/lang-helper"
|
||||
handlerlogger "simrs-vx/pkg/middleware/handler-logger"
|
||||
zlc "simrs-vx/pkg/zerolog-ctx"
|
||||
|
||||
/******************** 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"
|
||||
oldPatient "simrs-vx/internal/interface/simgos-sync-handler/old/patient"
|
||||
patient "simrs-vx/internal/interface/simgos-sync-handler/patient"
|
||||
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"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/division"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/encounter"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/installation"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/patient"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/specialist"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/subspecialist"
|
||||
"simrs-vx/internal/interface/simgos-sync-handler/new/unit"
|
||||
|
||||
oauth "simrs-vx/internal/interface/simgos-sync-handler/old/authentication" // just a reminder, an openauth
|
||||
)
|
||||
|
||||
func SetRoutes() http.Handler {
|
||||
@@ -33,6 +37,7 @@ func SetRoutes() http.Handler {
|
||||
a.RegisterExtCall(gs.Adjust)
|
||||
a.RegisterExtCall(zlc.Adjust)
|
||||
a.RegisterExtCall(lh.Populate)
|
||||
a.RegisterExtCall(sync.SetConfig)
|
||||
a.RegisterExtCall(simgosdb.SetInstance)
|
||||
|
||||
r := http.NewServeMux()
|
||||
@@ -40,18 +45,32 @@ func SetRoutes() http.Handler {
|
||||
/******************** Main ********************/
|
||||
r.HandleFunc("/", home.Home)
|
||||
|
||||
/******************** Source ******************/
|
||||
prefix := "/new-to-old"
|
||||
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)
|
||||
hc.SyncCrud(r, prefix+"/v1/patient", patient.O)
|
||||
r.HandleFunc(fmt.Sprintf("GET %s/v1/patient-nomr-generator", prefix), patient.O.GenerateNomr)
|
||||
/******************** SvcToOld ******************/
|
||||
prefixnew := "/new-to-old"
|
||||
hc.SyncCrud(r, prefixnew+"/v1/installation", installation.O)
|
||||
hc.SyncCrud(r, prefixnew+"/v1/unit", unit.O)
|
||||
hc.SyncCrud(r, prefixnew+"/v1/division", division.O)
|
||||
hc.SyncCrud(r, prefixnew+"/v1/specialist", specialist.O)
|
||||
hc.SyncCrud(r, prefixnew+"/v1/subspecialist", subspecialist.O)
|
||||
hk.GroupRoutes(prefixnew+"/v1/patient", r, hk.MapHandlerFunc{
|
||||
"POST /": patient.O.Create,
|
||||
"POST /log": patient.O.CreateLog,
|
||||
"PATCH /{id}": patient.O.Update,
|
||||
"DELETE /{id}": patient.O.Delete,
|
||||
"POST /nomr": patient.O.GenerateNomr,
|
||||
})
|
||||
hk.GroupRoutes(prefixnew+"/v1/encounter", r, hk.MapHandlerFunc{
|
||||
"POST /": encounter.O.Create,
|
||||
"POST /log": encounter.O.CreateLog,
|
||||
"PATCH /{id}": encounter.O.Update,
|
||||
"DELETE /{id}": encounter.O.Delete,
|
||||
"PATCH /{id}/checkin": encounter.O.Checkin,
|
||||
"PATCH /{id}/checkout": encounter.O.Checkout,
|
||||
"PATCH /{id}/cancel": encounter.O.Cancel,
|
||||
})
|
||||
|
||||
/*********** Source old-to-new ****************/
|
||||
oldPrefix := "/old-to-new"
|
||||
hc.SyncCrud(r, oldPrefix+"/v1/patient", oldPatient.O)
|
||||
/******************** SvcToNew ******************/
|
||||
prefixold := "/old-to-new"
|
||||
hk.GroupRoutes(prefixold+"/v1/patient", r, oauth.OldGuardMW, hk.MapHandlerFunc{}) // FINISH THIS
|
||||
return cmw.SetCors(handlerlogger.SetLog(r))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user