| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 | 
							- package ii
 
- import (
 
- 	"math"
 
- 	"reflect"
 
- 	"runtime"
 
- 	"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
 
- }
 
- // 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",
 
- 	}
 
- )
 
 
  |