diff --git a/model/line_message_log.go b/model/line_message_log.go index 98c0487..bcf0597 100644 --- a/model/line_message_log.go +++ b/model/line_message_log.go @@ -18,9 +18,9 @@ type LineMessageLog struct { // LineMessageLogWithUG - type LineMessageLogWithUG struct { - LineMessageLog - GroupName string `db:"group_name" cc:"group_name"` - UserName string `db:"user_name" cc:"user_name"` + LineMessageLog `cc:"-,<<"` + GroupName string `db:"group_name" cc:"group_name"` + UserName string `db:"user_name" cc:"user_name"` } // AddLineMessageLog - diff --git a/module/utils/utils.go b/module/utils/utils.go index b84a83e..479934e 100644 --- a/module/utils/utils.go +++ b/module/utils/utils.go @@ -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 } diff --git a/module/utils/utils_test.go b/module/utils/utils_test.go index eaca3d8..f9f1224 100644 --- a/module/utils/utils_test.go +++ b/module/utils/utils_test.go @@ -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)