Merge pull request #136 from dikstub-rssa/fix/anything-moko

Fix/anything moko
This commit is contained in:
Dwi Atmoko Purbo Sakti
2025-11-11 11:24:39 +07:00
committed by GitHub
8 changed files with 31 additions and 23 deletions
@@ -33,21 +33,21 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
}
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
dto := e.ReadDetailDto{}
sf.UrlQueryParam(&dto, *r.URL)
dto.Id = uint16(id)
dto.Code = &code
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 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
@@ -55,19 +55,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
return
}
dto.Id = uint16(id)
dto.Code = &code
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 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
dto := e.DeleteDto{}
dto.Id = uint16(id)
dto.Code = &code
res, err := u.Delete(dto)
rw.DataResponse(w, res, err)
}