add commad sys

This commit is contained in:
Jay
2019-07-09 15:05:36 +00:00
parent bdd2e0b0cc
commit 7cc675bfda
6 changed files with 140 additions and 66 deletions
+1
View File
@@ -84,6 +84,7 @@ func (p *DiscordServerModel) Write() error {
if err != nil {
return err
}
row.Next()
err = row.StructScan(p)
if err != nil {
return err
+3 -3
View File
@@ -21,7 +21,7 @@ type CommandModel struct {
// NewCommand -
func NewCommand(key, value, platform, binding string, requireManage, requireInit bool) (c *CommandModel, err error) {
if len(key) == 0 || len(value) == 0 {
return nil, errors.New("cmd, server or value is empty")
return nil, errors.New("key, server or value is empty")
}
c = &CommandModel{
@@ -100,10 +100,10 @@ func GetGlobalCommand(key string) (list []*CommandModel, err error) {
return nil, errors.New("key is empty")
}
db := models.GetConn()
query := `select "cmd", "server", "value", "require_manage", "require_init", "ctime", "mtime"
query := `select "key", "platform", "binding", "value", "require_manage", "require_init", "ctime", "mtime"
from "command"
where
"cmd" = $1
"key" = $1
and "platform" = ''
and "binding" = ''`
err = db.Select(&list, query, key)