修复部分bug,增加DB SUM函数,以及优化IN性能,增加分析接口

This commit is contained in:
hoteas 2023-03-22 03:17:33 +08:00
parent 8337cdec0c
commit 8cac1f5393
5 changed files with 437 additions and 435 deletions

View File

@ -102,7 +102,7 @@ func (that Map) GetBool(key string, err ...*Error) bool {
} }
func (that Map) GetTime(key string, err ...*Error) time.Time { func (that Map) GetTime(key string, err ...*Error) *time.Time {
v := ObjToTime((that)[key], err...) v := ObjToTime((that)[key], err...)
return v return v

View File

@ -20,7 +20,7 @@ func (that *Obj) ToInt(err ...Error) int {
return ObjToInt(that.Data, &that.Error) return ObjToInt(that.Data, &that.Error)
} }
func (that *Obj) ToTime(err ...Error) time.Time { func (that *Obj) ToTime(err ...Error) *time.Time {
if len(err) != 0 { if len(err) != 0 {
that.Error = err[0] that.Error = err[0]
} }

View File

@ -98,7 +98,7 @@ func ObjToSlice(obj interface{}, e ...*Error) Slice {
return v return v
} }
func ObjToTime(obj interface{}, e ...*Error) time.Time { func ObjToTime(obj interface{}, e ...*Error) *time.Time {
tInt := ObjToInt64(obj) tInt := ObjToInt64(obj)
//字符串类型只支持标准mysql datetime格式 //字符串类型只支持标准mysql datetime格式
@ -123,27 +123,27 @@ func ObjToTime(obj interface{}, e ...*Error) time.Time {
if len(tStr) > 18 { if len(tStr) > 18 {
t, e := time.Parse("2006-01-02 15:04:05", tStr) t, e := time.Parse("2006-01-02 15:04:05", tStr)
if e == nil { if e == nil {
return t return &t
} }
} else if len(tStr) > 15 { } else if len(tStr) > 15 {
t, e := time.Parse("2006-01-02 15:04", tStr) t, e := time.Parse("2006-01-02 15:04", tStr)
if e == nil { if e == nil {
return t return &t
} }
} else if len(tStr) > 12 { } else if len(tStr) > 12 {
t, e := time.Parse("2006-01-02 15", tStr) t, e := time.Parse("2006-01-02 15", tStr)
if e == nil { if e == nil {
return t return &t
} }
} else if len(tStr) > 9 { } else if len(tStr) > 9 {
t, e := time.Parse("2006-01-02", tStr) t, e := time.Parse("2006-01-02", tStr)
if e == nil { if e == nil {
return t return &t
} }
} else if len(tStr) > 6 { } else if len(tStr) > 6 {
t, e := time.Parse("2006-01", tStr) t, e := time.Parse("2006-01", tStr)
if e == nil { if e == nil {
return t return &t
} }
} }
@ -151,28 +151,32 @@ func ObjToTime(obj interface{}, e ...*Error) time.Time {
//纳秒级别 //纳秒级别
if len(ObjToStr(tInt)) > 16 { if len(ObjToStr(tInt)) > 16 {
t := time.Time{}.Add(time.Nanosecond * time.Duration(tInt)) //t := time.Time{}.Add(time.Nanosecond * time.Duration(tInt))
return t t := time.UnixMicro(tInt / 1000)
return &t
//微秒级别 //微秒级别
} else if len(ObjToStr(tInt)) > 13 { } else if len(ObjToStr(tInt)) > 13 {
t := time.Time{}.Add(time.Microsecond * time.Duration(tInt)) //t := time.Time{}.Add(time.Microsecond * time.Duration(tInt))
return t t := time.UnixMicro(tInt)
return &t
//毫秒级别 //毫秒级别
} else if len(ObjToStr(tInt)) > 10 { } else if len(ObjToStr(tInt)) > 10 {
t := time.Time{}.Add(time.Millisecond * time.Duration(tInt)) //t := time.Time{}.Add(time.Millisecond * time.Duration(tInt))
return t t := time.UnixMilli(tInt)
return &t
//秒级别 //秒级别
} else if len(ObjToStr(tInt)) > 9 { } else if len(ObjToStr(tInt)) > 9 {
t := time.Time{}.Add(time.Second * time.Duration(tInt)) //t := time.Time{}.Add(time.Second * time.Duration(tInt))
return t t := time.Unix(tInt, 0)
return &t
} else if len(ObjToStr(tInt)) > 3 { } else if len(ObjToStr(tInt)) > 3 {
t, e := time.Parse("2006", ObjToStr(tInt)) t, e := time.Parse("2006", ObjToStr(tInt))
if e == nil { if e == nil {
return t return &t
} }
} }
return time.Time{} return nil
} }
func ObjToFloat64(obj interface{}, e ...*Error) float64 { func ObjToFloat64(obj interface{}, e ...*Error) float64 {

View File

@ -15,7 +15,7 @@ func (that Slice) GetString(key int, err ...*Error) string {
return ObjToStr((that)[key]) return ObjToStr((that)[key])
} }
func (that Slice) GetTime(key int, err ...*Error) time.Time { func (that Slice) GetTime(key int, err ...*Error) *time.Time {
v := ObjToTime((that)[key], err...) v := ObjToTime((that)[key], err...)
return v return v

File diff suppressed because it is too large Load Diff