Commit 1b1030cc authored by 张振华's avatar 张振华 Committed by 33cn

optimize

parent 209dceff
...@@ -37,12 +37,12 @@ func (g *Guess) updateIndex(log *gty.ReceiptGuessGame) (kvs []*types.KeyValue) { ...@@ -37,12 +37,12 @@ func (g *Guess) updateIndex(log *gty.ReceiptGuessGame) (kvs []*types.KeyValue) {
game := log.Game game := log.Game
log.Game = nil log.Game = nil
err = tablejoin.MustGetTable("game").Replace(game) err = gameTable.Add(game)
if err != nil { if err != nil {
return nil return nil
} }
kvs, _ = tablejoin.Save() kvs, _ = gameTable.Save()
return kvs return kvs
} else if log.Status == gty.GuessGameStatusBet { } else if log.Status == gty.GuessGameStatusBet {
//用户下注,game表发生更新(game中下注信息有更新),user表新增下注记录 //用户下注,game表发生更新(game中下注信息有更新),user表新增下注记录
......
...@@ -32,7 +32,7 @@ const ( ...@@ -32,7 +32,7 @@ const (
ListASC = int32(1) ListASC = int32(1)
//DefaultCount 默认一次获取的记录数 //DefaultCount 默认一次获取的记录数
DefaultCount = int32(6) DefaultCount = int32(10)
//DefaultCategory 默认分类 //DefaultCategory 默认分类
DefaultCategory = "default" DefaultCategory = "default"
...@@ -768,6 +768,10 @@ func (action *Action) GameAbort(pbend *gty.GuessGameAbort) (*types.Receipt, erro ...@@ -768,6 +768,10 @@ func (action *Action) GameAbort(pbend *gty.GuessGameAbort) (*types.Receipt, erro
//getOptions 获得竞猜选项,并判断是否符合约定格式,类似"A:xxxx;B:xxxx;C:xxx",“:”前为选项名称,不能重复,":"后为选项说明。 //getOptions 获得竞猜选项,并判断是否符合约定格式,类似"A:xxxx;B:xxxx;C:xxx",“:”前为选项名称,不能重复,":"后为选项说明。
func getOptions(strOptions string) (options []string, legal bool) { func getOptions(strOptions string) (options []string, legal bool) {
if len(strOptions) == 0 {
return nil, false
}
legal = true legal = true
items := strings.Split(strOptions, ";") items := strings.Split(strOptions, ";")
for i := 0; i < len(items); i++ { for i := 0; i < len(items); i++ {
...@@ -779,14 +783,23 @@ func getOptions(strOptions string) (options []string, legal bool) { ...@@ -779,14 +783,23 @@ func getOptions(strOptions string) (options []string, legal bool) {
} }
} }
options = append(options, item[0]) options = append(options, trimStr(item[0]))
} }
return options, legal return options, legal
} }
//trimStr 去除字符串中的空格、制表符、换行符
func trimStr(str string) string {
str = strings.Replace(str, " ", "", -1)
str = strings.Replace(str, "\t", "", -1)
str = strings.Replace(str, "\n", "", -1)
return str
}
//isLegalOption 判断选项是否为合法选项 //isLegalOption 判断选项是否为合法选项
func isLegalOption(options []string, option string) bool { func isLegalOption(options []string, option string) bool {
option = trimStr(option)
for i := 0; i < len(options); i++ { for i := 0; i < len(options); i++ {
if options[i] == option { if options[i] == option {
return true return true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment