feat/authentication

+ moved pkg/auth-helper to internal/lib/auth
+ update AuthInfo
+ cleaning
This commit is contained in:
2025-10-26 21:29:41 +07:00
parent b5b0a8183d
commit 2c432a7bef
33 changed files with 227 additions and 121 deletions
+16 -15
View File
@@ -135,6 +135,19 @@ func SetRoutes() http.Handler {
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,
"GET /{id}": encounter.O.GetDetail,
"POST /": encounter.O.Create,
"PATCH /{id}": encounter.O.Update,
"DELETE /{id}": encounter.O.Delete,
"PATCH /{id}/checkout": encounter.O.CheckOut,
"PATCH /{id}/proccess": encounter.O.Process,
"PATCH /{id}/cancel": encounter.O.Cancel,
"PATCH /{id}/reject": encounter.O.Reject,
"PATCH /{id}/skip": encounter.O.Skip,
})
hk.GroupRoutes("/v1/mcu-order", r, auth.GuardMW, hk.MapHandlerFunc{
"GET /": mcuorder.O.GetList,
"GET /{id}": mcuorder.O.GetDetail,
@@ -153,7 +166,7 @@ func SetRoutes() http.Handler {
"PATCH /{id}/complete": mcuorderitem.O.Complete,
"PATCH /{id}/set-schedule": mcuorderitem.O.SetSchedule,
})
hk.GroupRoutes("/v1/prescription", r, hk.MapHandlerFunc{
hk.GroupRoutes("/v1/prescription", r, auth.GuardMW, hk.MapHandlerFunc{
"GET /": prescription.O.GetList,
"GET /{id}": prescription.O.GetDetail,
"POST /": prescription.O.Create,
@@ -161,7 +174,7 @@ func SetRoutes() http.Handler {
"DELETE /{id}": prescription.O.Delete,
"PATCH /{id}/approve": prescription.O.Approve,
})
hk.GroupRoutes("/v1/mcu-order-sub-item", r, hk.MapHandlerFunc{
hk.GroupRoutes("/v1/mcu-order-sub-item", r, auth.GuardMW, hk.MapHandlerFunc{
"GET /": mcuordersubitem.O.GetList,
"GET /{id}": mcuordersubitem.O.GetDetail,
"POST /": mcuordersubitem.O.Create,
@@ -169,18 +182,6 @@ func SetRoutes() http.Handler {
"DELETE /{id}": mcuordersubitem.O.Delete,
"PATCH /{id}/complete": mcuordersubitem.O.Complete,
})
hk.GroupRoutes("/v1/encounter", r, auth.GuardMW, hk.MapHandlerFunc{
"GET /": encounter.O.GetList,
"GET /{id}": encounter.O.GetDetail,
"POST /": encounter.O.Create,
"PATCH /{id}": encounter.O.Update,
"DELETE /{id}": encounter.O.Delete,
"PATCH /{id}/checkout": encounter.O.CheckOut,
"PATCH /{id}/proccess": encounter.O.Process,
"PATCH /{id}/cancel": encounter.O.Cancel,
"PATCH /{id}/reject": encounter.O.Reject,
"PATCH /{id}/skip": encounter.O.Skip,
})
hk.GroupRoutes("/v1/medication", r, auth.GuardMW, hk.MapHandlerFunc{
"GET /": medication.O.GetList,
"GET /{id}": medication.O.GetDetail,
@@ -190,7 +191,7 @@ func SetRoutes() http.Handler {
"PATCH /{id}/complete": medication.O.Complete,
})
hk.GroupRoutes("/v1/medication-item", r, hk.MapHandlerFunc{
hk.GroupRoutes("/v1/medication-item", r, auth.GuardMW, hk.MapHandlerFunc{
"GET /": medicationitem.O.GetList,
"GET /{id}": medicationitem.O.GetDetail,
"POST /": medicationitem.O.Create,