0x4a52466c696e74 1 settimana fa
parent
commit
40dfd05911
1 ha cambiato i file con 16 aggiunte e 0 eliminazioni
  1. 16 0
      rest_gorm/request_list.go

+ 16 - 0
rest_gorm/request_list.go

@@ -115,6 +115,14 @@ func (s *List) ResultAnswer(pg *gorm.DB, fields rest.FieldNamesList, res any, of
 	return rList, nil
 }
 
+func (s *List) ResultOut(pg *gorm.DB, fields rest.FieldNamesList, res any, req rest.IRequestIn) rest.IRequestOut {
+	rList, err := s.ResultAnswer(pg, fields, res, s.Offset, s.Limit)
+	if err != nil {
+		return req.OutError(err)
+	}
+	return rList.Out(req)
+}
+
 type ResultList struct {
 	Items  []any `json:"Items" rest:"fixed"`
 	Offset int   `json:"Offset" rest:"fixed"`
@@ -140,3 +148,11 @@ func (s *ResultList) Map(req rest.IRequestIn) (json.Map, rest.IErrorArgs) {
 	}
 	return res, nil
 }
+
+func (s *ResultList) Out(req rest.IRequestIn) rest.IRequestOut {
+	m, ierr := s.Map(req)
+	if ierr != nil {
+		return req.OutError(ierr)
+	}
+	return req.OutSuccess(m, nil)
+}