Browse Source

preload fix

0x4a52466c696e74 1 month ago
parent
commit
e5757428bc
2 changed files with 0 additions and 12 deletions
  1. 0 3
      rest_gorm/preload.go
  2. 0 9
      rest_gorm/request_list.go

+ 0 - 3
rest_gorm/preload.go

@@ -2,7 +2,6 @@ package rest_gorm
 
 import (
 	"fmt"
-	"log"
 	"reflect"
 	"strings"
 
@@ -22,10 +21,8 @@ func preloadPrefix(obj any, fields rest.FieldList, q *gorm.DB, prefix string) (*
 	}
 	for _, name := range names {
 		if f, check := fields.Field(name.eName); check {
-			log.Println("preload", prefix+name.eName)
 			q = q.Preload(prefix + name.eName)
 			if f.IsObject() {
-				log.Println("is_object:" + prefix + name.eName)
 				if q, err = preloadPrefix(name.eValue, f.Names, q, prefix+name.eName+"."); err != nil {
 					return nil, err
 				}

+ 0 - 9
rest_gorm/request_list.go

@@ -2,7 +2,6 @@ package rest_gorm
 
 import (
 	"fmt"
-	"log"
 	"reflect"
 
 	"git.ali33.ru/fcg-xvii/go-tools/json"
@@ -84,23 +83,18 @@ func (s *List) Result(pg *gorm.DB, fields rest.FieldNamesList, res any) (count i
 		err = rest.ErrorFiled("ErrDB", pg.Error.Error())
 		return
 	}
-	log.Println(res)
 	return
 }
 
 func toAnySlice(slice any) []any {
 	v := reflect.ValueOf(slice)
-	log.Println("kk", v.Kind())
-
 	if v.Kind() == reflect.Ptr {
 		v = v.Elem()
 	}
-
 	// Check if the input is a slice
 	if v.Kind() != reflect.Slice {
 		return nil
 	}
-
 	result := make([]any, v.Len())
 	for i := 0; i < v.Len(); i++ {
 		result[i] = v.Index(i).Interface()
@@ -113,7 +107,6 @@ func (s *List) ResultAnswer(pg *gorm.DB, fields rest.FieldNamesList, res any, of
 	if err != nil {
 		return nil, err
 	}
-	log.Println("---", res)
 	rList := &ResultList{
 		Items:  toAnySlice(res),
 		Offset: offset,
@@ -129,14 +122,12 @@ func (s *List) ResultOut(pg *gorm.DB, model any, req rest.IRequestIn) rest.IRequ
 		return req.OutError(rest.ErrorMessage("ErrFileds", err.Error()))
 	}
 	// preload
-	log.Println("list preload...")
 	if pg, err = Preload(model, req.Fields(), pg); err != nil {
 		return req.OutError(rest.ErrorMessage("ErrPreload", err.Error()))
 	}
 
 	// Определяем тип элемента напрямую без использования reflect.ValueOf
 	elemType := reflect.TypeOf(model)
-	log.Println(elemType)
 	// Создаем срез нужного типа
 	sl := reflect.MakeSlice(reflect.SliceOf(elemType), 0, 0)
 	// Создаем указатель на этот срез