From f58f61120a6952ac241ec21d985fb61d5967bf83 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 7 Sep 2020 16:57:34 +0800 Subject: [PATCH] 1 --- strutils.go | 8 ++++++++ sysutils.go | 20 ++++++++++++++++++++ timer.go | 4 ++++ xparams.go | 3 ++- xvalue.go | 11 ++++++++++- 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/strutils.go b/strutils.go index 9b1750d..884aa50 100644 --- a/strutils.go +++ b/strutils.go @@ -1,6 +1,14 @@ package q5 +import "crypto/md5" +import "encoding/hex" + func Test()(a string) { return "testb" } +func Md5Str(data string) string { + h := md5.New() + h.Write([]byte(data)) + return hex.EncodeToString(h.Sum(nil)) +} diff --git a/sysutils.go b/sysutils.go index 3b9c725..ccfaf29 100644 --- a/sysutils.go +++ b/sysutils.go @@ -1,5 +1,6 @@ package q5 +import "net/http" import "time" func GetDaySeconds(seconds int64) int64 { @@ -9,3 +10,22 @@ func GetDaySeconds(seconds int64) int64 { func GetTickCount() int64 { return time.Now().UnixNano() / 1e6 } + +func MkInt64(lo32 int32, hi32 int32) int64 { + return int64(lo32) + (int64(hi32) << 32) +} + +func Request(r *http.Request, name string) *XValue { + if r.Form == nil { + r.ParseForm() + } + v := &XValue{} + if vs, ok := r.Form[name]; ok { + if len(vs) > 0 { + v.SetString(vs[0]) + } else { + v.SetString("") + } + } + return v +} diff --git a/timer.go b/timer.go index cc3ac3c..dd00fdb 100644 --- a/timer.go +++ b/timer.go @@ -241,6 +241,10 @@ func (this *Timer) GetRunningTimer() *TimerList { return nil } +func (this *Timer) GetIdleMilliSeconds() int64 { + return 0 +} + func (this *Timer) detachTimer(timerList *TimerList) { if !timerList.entry.Empty() { timerList.entry.DelInit() diff --git a/xparams.go b/xparams.go index f560117..dc55fa9 100644 --- a/xparams.go +++ b/xparams.go @@ -11,6 +11,7 @@ func (this *XParams) Reset() *XParams { return this } -func (this *XParams) SetInt32(val int32) *XParams { +func (this *XParams) Init(initFunc func (*XParams)) *XParams { + initFunc(this) return this } diff --git a/xvalue.go b/xvalue.go index ae24579..5dd2ec1 100644 --- a/xvalue.go +++ b/xvalue.go @@ -57,6 +57,10 @@ func (this *XValue) SetUserData(val interface{}) *XValue { return this } +func (this *XValue) GetInt32() int32 { + return int32(this.GetInt64()) +} + func (this *XValue) GetInt64() int64 { switch this._type { case XVT_INT: @@ -81,5 +85,10 @@ func (this *XValue) GetInt64() int64 { } func (this *XValue) GetString() string { - return "" + switch this._type { + case XVT_STRING: + return *(this._val.(*string)) + default: + return "" + } }