tbc
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"net/http"
|
||||
eru "simrs-vx/internal/domain/references/upload"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
d "github.com/karincake/dodol"
|
||||
rw "github.com/karincake/risoles"
|
||||
@@ -57,12 +56,13 @@ func (obj myBase) Create(w http.ResponseWriter, r *http.Request) {
|
||||
MimeType: header.Header.Get("Content-Type"),
|
||||
}
|
||||
|
||||
errs := validateCreate(dto)
|
||||
if len(errs) > 0 {
|
||||
dataFail := validateCreate(dto)
|
||||
if dataFail != "" {
|
||||
rw.DataResponse(w, nil, d.FieldError{
|
||||
Code: "data-validation-fail",
|
||||
Message: strings.Join(errs, "\n"),
|
||||
Message: dataFail,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
res, err := u.Create(dto)
|
||||
|
||||
@@ -4,17 +4,16 @@ import (
|
||||
e "simrs-vx/internal/domain/main-entities/file-attachment"
|
||||
)
|
||||
|
||||
func validateCreate(dto e.CreateDto) []string {
|
||||
var errs []string
|
||||
func validateCreate(dto e.CreateDto) string {
|
||||
|
||||
switch {
|
||||
case dto.EntityType_Code == "":
|
||||
errs = append(errs, "entityType_code is required")
|
||||
return "entityType_code is required"
|
||||
case dto.Ref_Id == nil:
|
||||
errs = append(errs, "ref_id is required")
|
||||
return "ref_id is required"
|
||||
case dto.Type_Code == "":
|
||||
errs = append(errs, "type_code is required")
|
||||
return "type_code is required"
|
||||
}
|
||||
|
||||
return errs
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ func SetRoutes() http.Handler {
|
||||
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)
|
||||
hc.RegCrud(r, "POST /upload", fileattachment.O)
|
||||
hc.RegCrud(r, "/v1/upload", fileattachment.O)
|
||||
|
||||
/******************** actor ********************/
|
||||
hc.RegCrud(r, "/v1/person", person.O)
|
||||
|
||||
Reference in New Issue
Block a user