This commit is contained in:
Jay 2018-12-13 15:30:36 +08:00
parent 727e67fa5b
commit 24cfe6f09e
3 changed files with 39 additions and 6 deletions

View File

@ -18,7 +18,7 @@ type LineMessageLog struct {
// LineMessageLogWithUG -
type LineMessageLogWithUG struct {
LineMessageLog
LineMessageLog `cc:"-,<<"`
GroupName string `db:"group_name" cc:"group_name"`
UserName string `db:"user_name" cc:"user_name"`
}

View File

@ -98,13 +98,13 @@ func ToMap(ss interface{}) map[string]interface{} {
continue
}
tmp := ToMap(f.Interface())
if leveling == true {
tmp := ToMap(f.Interface())
for k, v := range tmp {
smap[k] = v
}
} else if name != "-" && leveling == false {
smap[name] = tmp
smap[name] = f.Interface()
}
continue
}

View File

@ -1,6 +1,39 @@
package utils
import "testing"
import (
"testing"
"time"
)
// Commands - struct
type Commands struct {
Cmd string `db:"cmd" cc:"cmd"`
Message string `db:"message" cc:"message"`
Group string `db:"group" cc:"group"`
Ctime time.Time `db:"ctime" cc:"ctime"`
Mtime time.Time `db:"mtime" cc:"ctime"`
}
// CommandsWithGroup -
type CommandsWithGroup struct {
Commands `cc:"-,<<"`
GroupName string `db:"group_name" cc:"group_name"`
}
func TestToMap(t *testing.T) {
cmd := Commands{}
cmd.Cmd = "test"
cmd.Message = "test message"
cmd.Group = ""
cmd.Ctime = time.Now()
cmd.Mtime = time.Now()
cmdWGroup := CommandsWithGroup{}
cmdWGroup.Commands = cmd
cmdWGroup.GroupName = "asd"
ToMap(cmdWGroup)
}
func TestCalcPage(t *testing.T) {
page := CalcPage(10, 1, 10)