fix command struct

This commit is contained in:
Jay 2018-12-19 11:34:01 +08:00
parent 0f8d722e38
commit 09d018355d
2 changed files with 6 additions and 1 deletions

View File

@ -13,7 +13,7 @@ type Commands struct {
Message string `db:"message" cc:"message"` Message string `db:"message" cc:"message"`
Group string `db:"group" cc:"group"` Group string `db:"group" cc:"group"`
Ctime time.Time `db:"ctime" cc:"ctime"` Ctime time.Time `db:"ctime" cc:"ctime"`
Mtime time.Time `db:"mtime" cc:"ctime"` Mtime time.Time `db:"mtime" cc:"mtime"`
} }
// CommandsWithGroup - // CommandsWithGroup -

View File

@ -62,11 +62,16 @@ func ToMap(ss interface{}) map[string]interface{} {
smap := make(map[string]interface{}) smap := make(map[string]interface{})
mtag := regexp.MustCompile(`cc:\"(.+)\"`) mtag := regexp.MustCompile(`cc:\"(.+)\"`)
re := regexp.MustCompile(`^[A-Z]`)
for i := 0; i < t.NumField(); i++ { for i := 0; i < t.NumField(); i++ {
f := t.Field(i) f := t.Field(i)
tag := string(t.Type().Field(i).Tag) tag := string(t.Type().Field(i).Tag)
str := mtag.FindStringSubmatch(tag) str := mtag.FindStringSubmatch(tag)
name := t.Type().Field(i).Name name := t.Type().Field(i).Name
if !re.Match([]byte(name)) {
continue
}
leveling := false leveling := false
if len(str) > 1 { if len(str) > 1 {
strArr := strings.Split(str[1], ",") strArr := strings.Split(str[1], ",")