add chemo protocol

This commit is contained in:
vanilia
2025-11-04 16:13:19 +07:00
parent fe9f12fbe8
commit 28927d4c8b
13 changed files with 787 additions and 38 deletions
@@ -0,0 +1,72 @@
package chemo_protocol
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/chemo-protocol"
u "simrs-vx/internal/use-case/main-use-case/chemo-protocol"
)
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{}
sf.UrlQueryParam(&dto, *r.URL)
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)
}
@@ -9,6 +9,7 @@ import (
ambulancetransportrequest "simrs-vx/internal/interface/main-handler/ambulance-transport-req"
auth "simrs-vx/internal/interface/main-handler/authentication"
chemo "simrs-vx/internal/interface/main-handler/chemo"
chemoprotocol "simrs-vx/internal/interface/main-handler/chemo-protocol"
consultation "simrs-vx/internal/interface/main-handler/consultation"
controlletter "simrs-vx/internal/interface/main-handler/control-letter"
counter "simrs-vx/internal/interface/main-handler/counter"
@@ -259,6 +260,7 @@ func SetRoutes() http.Handler {
hc.RegCrud(r, "/v1/responsible-doctor-hist", responsibledoctorhist.O)
hc.RegCrud(r, "/v1/adm-employee-hist", admemployeehist.O)
hc.RegCrud(r, "/v1/therapy-protocol", therapyprotocol.O)
hc.RegCrud(r, "/v1/chemo-protocol", chemoprotocol.O)
/******************** actor ********************/
hc.RegCrud(r, "/v1/person", person.O)