0x4a52466c696e74 1 hafta önce
ebeveyn
işleme
d234a63fa2
1 değiştirilmiş dosya ile 10 ekleme ve 1 silme
  1. 10 1
      rest_gorm/request_list.go

+ 10 - 1
rest_gorm/request_list.go

@@ -115,7 +115,16 @@ 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 {
+func (s *List) ResultOut(pg *gorm.DB, model any, req rest.IRequestIn) rest.IRequestOut {
+	fieldNames, err := rest.FieldNames(model)
+	if err != nil {
+		return req.OutError(rest.ErrorMessage("ErrFileds", err.Error()))
+	}
+	sl := reflect.MakeSlice(reflect.ValueOf(model).Type(), 0, 0).Interface()
+	return s.ResultOutNames(pg, fieldNames, sl, req)
+}
+
+func (s *List) ResultOutNames(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)