i
merge branch 'migration into feat/vehicle-src-75 .
This commit is contained in:
@@ -12,6 +12,10 @@ import (
|
||||
u "simrs-vx/internal/use-case/main-use-case/encounter"
|
||||
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
|
||||
pa "simrs-vx/pkg/auth-helper"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
@@ -19,10 +23,15 @@ 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)
|
||||
}
|
||||
@@ -40,6 +49,7 @@ func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
dto := e.ReadDetailDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
dto.Id = uint16(id)
|
||||
res, err := u.ReadDetail(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
|
||||
@@ -39,6 +39,7 @@ import (
|
||||
person "simrs-vx/internal/interface/main-handler/person"
|
||||
personaddress "simrs-vx/internal/interface/main-handler/person-address"
|
||||
personcontact "simrs-vx/internal/interface/main-handler/person-contact"
|
||||
personinsurance "simrs-vx/internal/interface/main-handler/person-insurance"
|
||||
pharmacist "simrs-vx/internal/interface/main-handler/pharmacist"
|
||||
user "simrs-vx/internal/interface/main-handler/user"
|
||||
|
||||
@@ -116,7 +117,6 @@ func SetRoutes() http.Handler {
|
||||
r.HandleFunc("/", home.Home)
|
||||
|
||||
r.HandleFunc("POST /v1/authentication/login", auth.Login)
|
||||
// r.HandleFunc("POST /v1/authentication/logout", auth.Logout)
|
||||
hk.Route("POST /v1/authentication/logout", r, auth.GuardMW, auth.Logout)
|
||||
hc.RegCrud(r, "/v1/practice-schedule", practiceschedule.O)
|
||||
hc.RegCrud(r, "/v1/counter", counter.O)
|
||||
@@ -162,7 +162,7 @@ func SetRoutes() http.Handler {
|
||||
"DELETE /{id}": mcuordersubitem.O.Delete,
|
||||
"PATCH /{id}/complete": mcuordersubitem.O.Complete,
|
||||
})
|
||||
hk.GroupRoutes("/v1/encounter", r, hk.MapHandlerFunc{
|
||||
hk.GroupRoutes("/v1/encounter", r, auth.GuardMW, hk.MapHandlerFunc{
|
||||
"GET /": encounter.O.GetList,
|
||||
"GET /{id}": encounter.O.GetDetail,
|
||||
"POST /": encounter.O.Create,
|
||||
@@ -244,6 +244,7 @@ func SetRoutes() http.Handler {
|
||||
hc.RegCrud(r, "/v1/person", person.O)
|
||||
hc.RegCrud(r, "/v1/person-address", personaddress.O)
|
||||
hc.RegCrud(r, "/v1/person-contact", personcontact.O)
|
||||
hc.RegCrud(r, "/v1/person-insurance", personinsurance.O)
|
||||
hc.RegCrud(r, "/v1/employee", employee.O)
|
||||
hc.RegCrud(r, "/v1/doctor", doctor.O)
|
||||
hc.RegCrud(r, "/v1/nurse", nurse.O)
|
||||
@@ -259,13 +260,14 @@ func SetRoutes() http.Handler {
|
||||
"PATCH /{id}/active": user.O.Active,
|
||||
})
|
||||
hk.GroupRoutes("/v1/patient", r, hk.MapHandlerFunc{
|
||||
"GET /": patient.O.GetList,
|
||||
"GET /{id}": patient.O.GetDetail,
|
||||
"POST /": patient.O.Create,
|
||||
"PATCH /{id}": patient.O.Update,
|
||||
"DELETE /{id}": patient.O.Delete,
|
||||
"GET /by-identifier": patient.O.Search,
|
||||
"POST /{id}/upload": patient.O.Upload,
|
||||
"GET /": patient.O.GetList,
|
||||
"GET /{id}": patient.O.GetDetail,
|
||||
"POST /": patient.O.Create,
|
||||
"PATCH /{id}": patient.O.Update,
|
||||
"DELETE /{id}": patient.O.Delete,
|
||||
"GET /search/{keyword}": patient.O.Search,
|
||||
"GET /by-resident-identity": patient.O.SearchByResidentIdentity,
|
||||
"POST /{id}/upload": patient.O.Upload,
|
||||
})
|
||||
|
||||
/******************** sources ********************/
|
||||
|
||||
@@ -12,6 +12,8 @@ import (
|
||||
u "simrs-vx/internal/use-case/main-use-case/patient"
|
||||
|
||||
ere "simrs-vx/internal/domain/references/encounter"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
)
|
||||
|
||||
type myBase struct{}
|
||||
@@ -73,8 +75,21 @@ func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (obj myBase) Search(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.SearchDto{}
|
||||
keyword := rw.ValidateString(w, "keyword", r.PathValue("keyword"))
|
||||
if keyword == "" {
|
||||
rw.WriteJSON(w, http.StatusUnauthorized, d.IS{"message": "keyword is required"}, nil)
|
||||
}
|
||||
dto.Mode = e.SMIdent
|
||||
dto.Search = keyword
|
||||
res, err := u.Search(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
func (obj myBase) SearchByResidentIdentity(w http.ResponseWriter, r *http.Request) {
|
||||
dto := e.SearchDto{}
|
||||
sf.UrlQueryParam(&dto, *r.URL)
|
||||
dto.Mode = e.SMNik
|
||||
res, err := u.Search(dto)
|
||||
rw.DataResponse(w, res, err)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package personinsurance
|
||||
|
||||
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/person-insurance"
|
||||
u "simrs-vx/internal/use-case/main-use-case/person-insurance"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user