| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 | package iiimport (	"errors"	"fmt"	"math"	"reflect"	"runtime"	"strings"	"golib/features/mo")func getCallerName() string {	pc, _, _, _ := runtime.Caller(2)	return runtime.FuncForPC(pc).Name()}func valueType(v any) string {	if v == nil {		return "nil"	}	return reflect.ValueOf(v).Type().String()}func isMap(v any) bool {	if v == nil {		return false	}	return reflect.ValueOf(v).Type().Kind() == reflect.Map}func toFloat64Decimal(f float64, decimal int) float64 {	if decimal <= 0 {		return f	}	d := math.Pow10(decimal)	return math.Trunc((f+0.5/d)*d) / d}// SplitPATH 解析 path 为三段// path 必须以 /item 作为起始// 示例: /item/insertOne/test.user 将返回 insertOne,test.user,nilfunc SplitPATH(path string) (string, string, error) {	// "","item","insertOne","test.user"	pathList := strings.Split(path, "/")	if len(pathList) != 4 {		return "", "", fmt.Errorf("err path: %s", path)	}	if pathList[1] != "item" {		return "", "", errors.New("the first element of PATH must be: item")	}	return pathList[2], pathList[3], nil}// fieldEnableType 启用的数据类型// MongoDB 数据类型众多, 并非所有类型都适用于实际开发环境, 特在此处添加已启用的类型. 使用未启用的类型时会在 Unmarshal 时报错var (	fieldEnableType = map[mo.Type]struct{}{		mo.TypeDouble:   {},		mo.TypeString:   {},		mo.TypeObject:   {},		mo.TypeArray:    {},		mo.TypeObjectId: {},		mo.TypeBoolean:  {},		mo.TypeDate:     {},		mo.TypeLong:     {},	})func isEnabledType(t mo.Type) bool {	_, ok := fieldEnableType[t]	return ok}var (	idInfo = FieldInfo{		Name:     ID,		Type:     mo.TypeObjectId,		Required: true,		Unique:   true,		Label:    ID,		Default:  "new",	}	creator = FieldInfo{		Name:     Creator,		Type:     mo.TypeObjectId,		Required: true,		Unique:   false,		Label:    "创建人",	}	creationTime = FieldInfo{		Name:     CreationTime,		Type:     mo.TypeDate,		Required: true,		Unique:   false,		Label:    "创建时间",		Default:  "now",	})
 |